Index: binaries/data/mods/public/simulation/components/Fogging.js
===================================================================
--- binaries/data/mods/public/simulation/components/Fogging.js
+++ binaries/data/mods/public/simulation/components/Fogging.js
@@ -8,6 +8,20 @@
"Allows this entity to be replaced by mirage entities in the fog-of-war." +
"";
+/**
+ * The components that we want to mirage when present.
+ * Assumes that a function "Mirage()" is present.
+ */
+Fogging.prototype.componentsToMirage = [
+ IID_Capturable,
+ IID_Foundation,
+ IID_Health,
+ IID_Identity,
+ IID_Market,
+ IID_Repairable,
+ IID_ResourceSupply
+];
+
Fogging.prototype.Init = function()
{
this.activated = false;
@@ -106,33 +120,8 @@
cmpMirageVisualActor.SetActorSeed(cmpParentVisualActor.GetActorSeed());
// Store valuable information into the mirage component (especially for the GUI).
- let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
- if (cmpIdentity)
- cmpMirage.CopyIdentity(cmpIdentity);
-
- let cmpFoundation = Engine.QueryInterface(this.entity, IID_Foundation);
- if (cmpFoundation)
- cmpMirage.CopyFoundation(cmpFoundation);
-
- let cmpRepairable = Engine.QueryInterface(this.entity, IID_Repairable);
- if (cmpRepairable && !cmpFoundation)
- cmpMirage.CopyRepairable(cmpRepairable);
-
- let cmpHealth = Engine.QueryInterface(this.entity, IID_Health);
- if (cmpHealth)
- cmpMirage.CopyHealth(cmpHealth);
-
- let cmpCapturable = Engine.QueryInterface(this.entity, IID_Capturable);
- if (cmpCapturable)
- cmpMirage.CopyCapturable(cmpCapturable);
-
- let cmpResourceSupply = Engine.QueryInterface(this.entity, IID_ResourceSupply);
- if (cmpResourceSupply)
- cmpMirage.CopyResourceSupply(cmpResourceSupply);
-
- let cmpMarket = Engine.QueryInterface(this.entity, IID_Market);
- if (cmpMarket)
- cmpMirage.CopyMarket(cmpMarket);
+ for (let component of this.componentsToMirage)
+ cmpMirage.CopyComponent(component);
// Notify the GUI the entity has been replaced by a mirage, in case it is selected at this moment.
Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface).AddMiragedEntity(player, this.entity, this.mirages[player]);
Index: binaries/data/mods/public/simulation/components/Mirage.js
===================================================================
--- binaries/data/mods/public/simulation/components/Mirage.js
+++ binaries/data/mods/public/simulation/components/Mirage.js
@@ -49,39 +49,14 @@
// ============================
// Parent entity data
-Mirage.prototype.CopyCapturable = function(cmpCapturable)
-{
- this.miragedIids.set(IID_Capturable, cmpCapturable.Mirage());
-};
-
-Mirage.prototype.CopyFoundation = function(cmpFoundation)
-{
- this.miragedIids.set(IID_Foundation, cmpFoundation.Mirage());
-};
-
-Mirage.prototype.CopyHealth = function(cmpHealth)
-{
- this.miragedIids.set(IID_Health, cmpHealth.Mirage());
-};
-
-Mirage.prototype.CopyIdentity = function(cmpIdentity)
-{
- this.miragedIids.set(IID_Identity, cmpIdentity.Mirage());
-};
-
-Mirage.prototype.CopyMarket = function(cmpMarket)
-{
- this.miragedIids.set(IID_Market, cmpMarket.Mirage(this.entity, this.player));
-};
-
-Mirage.prototype.CopyRepairable = function(cmpRepairable)
-{
- this.miragedIids.set(IID_Repairable, cmpRepairable.Mirage());
-};
-
-Mirage.prototype.CopyResourceSupply = function(cmpResourceSupply)
-{
- this.miragedIids.set(IID_ResourceSupply, cmpResourceSupply.Mirage());
+/**
+ * @param {number} iid - The component to mirage.
+ */
+Mirage.prototype.CopyComponent = function(iid)
+{
+ let cmp = Engine.QueryInterface(this.parent, iid);
+ if (cmp)
+ this.miragedIids.set(iid, cmp.Mirage(this.entity, this.player));
};
// ============================