optimizations + bugfixes

* Bombs explode on damage/explosion
* Orbits spell fixed
* Performance: implemented shared component indexes,
compiled Lua caching, and updates only for changed projectile fields.
Also removed accumulating hidden entity slots.
This commit is contained in:
Gaël committed 2026-10-20 11:02:18 +02:00
1 parent 87bff164f1
commit a34f42d53e
17 files changed
+727 -131

No files matched your search

+4 -1
View File
@@ -26,6 +26,7 @@ struct ProjDef {
bool on_collision_die = true;
int bounces_left = 0; // ProjectileComponent bounces_left: grenades bounce this often before they explode
bool friendly_fire = false; // ProjectileComponent.friendly_fire: hurts the herd of the shooter too
bool orbiting = false; // orbit_projectile: attached hazards can hit their caster after launch grace
bool dont_hit_player = false; // dont_hit_player: never hurts the player, whatever the herds
int collide_with_shooter_frames = 0; // the shooter itself is not hit during the first frames
// HitEffectComponent (of the projectile and of its extra entities): what a hit does to the victim
@@ -53,7 +54,7 @@ struct ProjDef {
bool die_on_liquid = false; // die_on_liquid_collision
float liquid_drag = 1.0f; // VelocityComponent liquid_drag (constructor default 1.0): the share of the speed lost per liquid cell around, per second
bool displace_liquid = true; // ProjectileComponent displace_liquid: the liquid around is pushed aside (the constructor default is not recovered, the explicit values of the data are honoured)
bool physics = false; // a thrown physics body (bombs): bounces and rolls, explodes only when its fuse runs out
bool physics = false; // a thrown physics body (bombs): bounces and rolls; fuse expiry or damage can detonate it
bool creature = false; // a cast creature (SUMMON_WANDGHOST's wand_ghost_player.xml: no ProjectileComponent, an AI): the host spawns it as a whole entity, the GPU projectile only carries it out of the wand
float break_speed = 0; // a breakable thrown body (SUMMON_EGG's egg_monster.xml: PhysicsBodyCollisionDamage + DamageModel + ExplodeOnDamage): an impact faster than this (px/s) kills it and it explodes with the ExplodeOnDamage config
bool explode_on_death = false;
@@ -147,6 +148,8 @@ public:
const ProjDef* def(const std::string& file);
// A definition built from an entity description that is not a file (the runtime copy of a projectile after the scripts changed it), stored under `key`.
const ProjDef* def_from(const std::string& key, const EntityDef& entity, const std::string& extras = ""); // + the extra entities of the shot (emitters, light, hit effects, homing)
// Stable identity for a script's projectile definition; host scheduling state is per instance.
static std::string script_definition_key(const EntityDef& entity);
EntityDb& db() { return db_; }
// The projectile with the extra entities a shot carries (c.extra_entities, comma separated): their particle emitters and light are added.
const ProjDef* def(const std::string& file, const std::string& extras);