From bf55acadaa845cad32ca2e6c90d6cb20e347029b Mon Sep 17 00:00:00 2001 From: historic_bruno Date: Fri, 28 Sep 2012 22:02:13 +0000 Subject: [PATCH] Implements SpawnEntityOnDeath property for entities (i.e. rubble). Fixes #1166. Adds some placeholder rubble entities. They currently reuse foundation actors until proper rubble models are created. This was SVN commit r12717. --- .../public/simulation/components/Health.js | 35 +++++++++++++++++-- .../templates/rubble/rubble_1x1.xml | 6 ++++ .../templates/rubble/rubble_1x1pal.xml | 6 ++++ .../templates/rubble/rubble_1x3pal.xml | 6 ++++ .../templates/rubble/rubble_2x2.xml | 6 ++++ .../templates/rubble/rubble_2x4.xml | 6 ++++ .../templates/rubble/rubble_3x3.xml | 6 ++++ .../templates/rubble/rubble_3x6.xml | 6 ++++ .../templates/rubble/rubble_4x2.xml | 6 ++++ .../templates/rubble/rubble_4x4.xml | 6 ++++ .../templates/rubble/rubble_4x4_dock.xml | 6 ++++ .../templates/rubble/rubble_4x6.xml | 6 ++++ .../templates/rubble/rubble_5x5.xml | 6 ++++ .../templates/rubble/rubble_6x4.xml | 6 ++++ .../templates/rubble/rubble_6x4_dock.xml | 6 ++++ .../templates/rubble/rubble_6x6.xml | 6 ++++ .../templates/rubble/rubble_8x8.xml | 6 ++++ .../templates/rubble/rubble_wall.xml | 6 ++++ .../simulation/templates/template_rubble.xml | 24 +++++++++++++ 19 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_1x1.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_1x1pal.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_1x3pal.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_2x2.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_2x4.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_3x3.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_3x6.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_4x2.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_4x4.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_4x4_dock.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_4x6.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_5x5.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_6x4.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_6x4_dock.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_6x6.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_8x8.xml create mode 100644 binaries/data/mods/public/simulation/templates/rubble/rubble_wall.xml create mode 100644 binaries/data/mods/public/simulation/templates/template_rubble.xml diff --git a/binaries/data/mods/public/simulation/components/Health.js b/binaries/data/mods/public/simulation/components/Health.js index bbbd295136..6be516eba1 100644 --- a/binaries/data/mods/public/simulation/components/Health.js +++ b/binaries/data/mods/public/simulation/components/Health.js @@ -15,6 +15,11 @@ Health.prototype.Schema = "" + "" + "" + + "" + + "" + + "" + + "" + + "" + "" + "" + "" + @@ -112,9 +117,13 @@ Health.prototype.Reduce = function(amount) if (this.hitpoints) { state.killed = true; - + PlaySound("death", this.entity); + // If SpawnEntityOnDeath is set, spawn the entity + if(this.template.SpawnEntityOnDeath) + this.CreateDeathSpawnedEntity(); + if (this.template.DeathType == "corpse") { this.CreateCorpse(); @@ -134,7 +143,7 @@ Health.prototype.Reduce = function(amount) var old = this.hitpoints; this.hitpoints = 0; - + Engine.PostMessage(this.entity, MT_HealthChanged, { "from": old, "to": this.hitpoints }); } @@ -210,6 +219,28 @@ Health.prototype.CreateCorpse = function(leaveResources) return corpse; }; +Health.prototype.CreateDeathSpawnedEntity = function() +{ + // If the unit died while not in the world, don't spawn a death entity for it + // since there's nowhere for it to be placed + var cmpPosition = Engine.QueryInterface(this.entity, IID_Position); + if (!cmpPosition.IsInWorld()) + return INVALID_ENTITY; + + // Create SpawnEntityOnDeath entity + var spawnedEntity = Engine.AddLocalEntity(this.template.SpawnEntityOnDeath); + + // Move to same position + var cmpSpawnedPosition = Engine.QueryInterface(spawnedEntity, IID_Position); + var pos = cmpPosition.GetPosition(); + cmpSpawnedPosition.JumpTo(pos.x, pos.z); + var rot = cmpPosition.GetRotation(); + cmpSpawnedPosition.SetYRotation(rot.y); + cmpSpawnedPosition.SetXZRotation(rot.x, rot.z); + + return spawnedEntity; +}; + Health.prototype.Repair = function(builderEnt, work) { var damage = this.GetMaxHitpoints() - this.GetHitpoints(); diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_1x1.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_1x1.xml new file mode 100644 index 0000000000..1e8da645e9 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_1x1.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_1x1.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_1x1pal.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_1x1pal.xml new file mode 100644 index 0000000000..ab2b919461 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_1x1pal.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_1x1pal.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_1x3pal.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_1x3pal.xml new file mode 100644 index 0000000000..3cc0e7bb15 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_1x3pal.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_1x3pal.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_2x2.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_2x2.xml new file mode 100644 index 0000000000..d52f4aa9da --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_2x2.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_2x2.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_2x4.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_2x4.xml new file mode 100644 index 0000000000..b7fb01d0f3 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_2x4.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_2x4.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_3x3.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_3x3.xml new file mode 100644 index 0000000000..3098035ba7 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_3x3.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_3x3.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_3x6.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_3x6.xml new file mode 100644 index 0000000000..15d3555c4d --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_3x6.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_3x6.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_4x2.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_4x2.xml new file mode 100644 index 0000000000..95001be9ef --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_4x2.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_4x2.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_4x4.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_4x4.xml new file mode 100644 index 0000000000..e719411588 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_4x4.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_4x4.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_4x4_dock.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_4x4_dock.xml new file mode 100644 index 0000000000..8065369cc2 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_4x4_dock.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_4x4_dock.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_4x6.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_4x6.xml new file mode 100644 index 0000000000..2c437a9ff8 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_4x6.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_4x6.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_5x5.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_5x5.xml new file mode 100644 index 0000000000..f75c81d05d --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_5x5.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_5x5.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_6x4.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_6x4.xml new file mode 100644 index 0000000000..1659ccfde6 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_6x4.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_6x4.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_6x4_dock.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_6x4_dock.xml new file mode 100644 index 0000000000..140de62204 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_6x4_dock.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_6x4_dock.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_6x6.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_6x6.xml new file mode 100644 index 0000000000..a8c369a721 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_6x6.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_6x6.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_8x8.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_8x8.xml new file mode 100644 index 0000000000..33d3f73e43 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_8x8.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_8x8.xml + + diff --git a/binaries/data/mods/public/simulation/templates/rubble/rubble_wall.xml b/binaries/data/mods/public/simulation/templates/rubble/rubble_wall.xml new file mode 100644 index 0000000000..06f423d314 --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/rubble/rubble_wall.xml @@ -0,0 +1,6 @@ + + + + structures/fndn_wall.xml + + diff --git a/binaries/data/mods/public/simulation/templates/template_rubble.xml b/binaries/data/mods/public/simulation/templates/template_rubble.xml new file mode 100644 index 0000000000..280a1b1e8f --- /dev/null +++ b/binaries/data/mods/public/simulation/templates/template_rubble.xml @@ -0,0 +1,24 @@ + + + + 10.0 + 0.2 + 0 + + + 0 + upright + false + 6.0 + + + 0 + true + false + + + structures/fndn_1x1.xml + false + false + + \ No newline at end of file