Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Health.js
Show First 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | Health.prototype.CreateCorpse = function(leaveResources) | ||||
// If the unit died while not in the world, don't create any corpse for it | // If the unit died while not in the world, don't create any corpse for it | ||||
// since there's nowhere for the corpse to be placed | // since there's nowhere for the corpse to be placed | ||||
let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | ||||
if (!cmpPosition.IsInWorld()) | if (!cmpPosition.IsInWorld()) | ||||
return INVALID_ENTITY; | return INVALID_ENTITY; | ||||
// Either creates a static local version of the current entity, or a | // Either creates a static local version of the current entity, or a | ||||
// persistent corpse retaining the ResourceSupply element of the parent. | // persistent corpse retaining the ResourceSupply element of the parent. | ||||
let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | ||||
let templateName = cmpTemplateManager.GetCurrentTemplateName(this.entity); | let templateName = cmpTemplateManager.GetCurrentTemplateName(this.entity); | ||||
let corpse; | let corpse; | ||||
elexis: (You probably want to commit the linting patch) | |||||
Done Inline ActionsStan: D1771 | |||||
if (leaveResources) | if (leaveResources) | ||||
{ | |||||
let cmpResourceSupply = Engine.QueryInterface(this.entity, IID_ResourceSupply); | |||||
if (cmpResourceSupply) | |||||
{ | |||||
corpse = Engine.AddEntity("resource|" + templateName); | corpse = Engine.AddEntity("resource|" + templateName); | ||||
Done Inline Actions(Do I recall that we use the ent prefix for entityIDs, i.e entCorpse?) elexis: (Do I recall that we use the `ent` prefix for entityIDs, i.e `entCorpse`?) | |||||
Done Inline ActionsCould work. Bigger the patch. Stan: Could work. Bigger the patch. | |||||
let cmpCorpseResourceSupply = Engine.QueryInterface(corpse, IID_ResourceSupply); | |||||
Done Inline Actionsentity component instances should always start with cmp for consistency (followed by the name of that component would make it even more consistent) elexis: entity component instances should always start with `cmp` for consistency (followed by the name… | |||||
cmpCorpseResourceSupply.SetAmount(cmpResourceSupply.GetCurrentAmount()); | |||||
Done Inline Actions(Using cmpResourceSupplyCorpse would mean that all entity components start with the component name) elexis: (Using `cmpResourceSupplyCorpse` would mean that all entity components start with the component… | |||||
Done Inline ActionsSure. Stan: Sure. | |||||
} | |||||
} | |||||
else | else | ||||
corpse = Engine.AddLocalEntity("corpse|" + templateName); | corpse = Engine.AddLocalEntity("corpse|" + templateName); | ||||
Done Inline Actions(So was my suspicion that the rest of the code uses entFoo actually true or did we act on suspicion? I didn't search the code. Otherwise, the entFoo seems more informative than Foo) elexis: (So was my suspicion that the rest of the code uses entFoo actually true or did we act on… | |||||
Done Inline ActionsI didn't check but the request sounded fair. Stan: I didn't check but the request sounded fair. | |||||
// Copy various parameters so it looks just like us | // Copy various parameters so it looks just like us | ||||
let cmpCorpsePosition = Engine.QueryInterface(corpse, IID_Position); | let cmpCorpsePosition = Engine.QueryInterface(corpse, IID_Position); | ||||
let pos = cmpPosition.GetPosition(); | let pos = cmpPosition.GetPosition(); | ||||
cmpCorpsePosition.JumpTo(pos.x, pos.z); | cmpCorpsePosition.JumpTo(pos.x, pos.z); | ||||
let rot = cmpPosition.GetRotation(); | let rot = cmpPosition.GetRotation(); | ||||
cmpCorpsePosition.SetYRotation(rot.y); | cmpCorpsePosition.SetYRotation(rot.y); | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
(You probably want to commit the linting patch)