mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 10:03:43 +00:00
Move undeletable tag to identity component, preparation for allowing units without health component.
Also fix a missing init from D750/7e1646afd5 Patch By: temple Differential Revision: https://code.wildfiregames.com/D341 This was SVN commit r20573.
This commit is contained in:
@@ -1440,7 +1440,7 @@ function isUndeletable(entState)
|
||||
if (entState.capturePoints && entState.capturePoints[entState.player] < entState.maxCapturePoints / 2)
|
||||
return translate("You cannot destroy this entity as you own less than half the capture points");
|
||||
|
||||
if (!entState.canDelete)
|
||||
if (!entState.identity.canDelete)
|
||||
return translate("This entity is undeletable");
|
||||
|
||||
return false;
|
||||
|
||||
@@ -30,7 +30,7 @@ const aWaypointFlag = "actor|props/special/common/waypoint_flag.xml";
|
||||
const pForest1 = [tForestFloor2 + TERRAIN_SEPARATOR + oTree1, tForestFloor2 + TERRAIN_SEPARATOR + oTree2, tForestFloor2];
|
||||
const pForest2 = [tForestFloor1 + TERRAIN_SEPARATOR + oTree4, tForestFloor1 + TERRAIN_SEPARATOR + oTree5, tForestFloor1];
|
||||
|
||||
const oTreasureSeeker = "skirmish/units/default_support_female_citizen";
|
||||
const oTreasureSeeker = "undeletable|skirmish/units/default_support_female_citizen";
|
||||
|
||||
const triggerPointAttacker = "trigger/trigger_point_A";
|
||||
const triggerPointTreasures = [
|
||||
|
||||
@@ -178,9 +178,6 @@ Trigger.prototype.InitStartingUnits = function()
|
||||
|
||||
let cmpDamageReceiver = Engine.QueryInterface(entity, IID_DamageReceiver);
|
||||
cmpDamageReceiver.SetInvulnerability(true);
|
||||
|
||||
let cmpHealth = Engine.QueryInterface(entity, IID_Health);
|
||||
cmpHealth.SetUndeletable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,8 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
|
||||
"rank": cmpIdentity.GetRank(),
|
||||
"classes": cmpIdentity.GetClassesList(),
|
||||
"visibleClasses": cmpIdentity.GetVisibleClassesList(),
|
||||
"selectionGroupName": cmpIdentity.GetSelectionGroupName()
|
||||
"selectionGroupName": cmpIdentity.GetSelectionGroupName(),
|
||||
"canDelete": !cmpIdentity.IsUndeletable()
|
||||
};
|
||||
|
||||
let cmpPosition = Engine.QueryInterface(ent, IID_Position);
|
||||
@@ -294,7 +295,6 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
|
||||
ret.maxHitpoints = cmpHealth.GetMaxHitpoints();
|
||||
ret.needsRepair = cmpHealth.IsRepairable() && cmpHealth.GetHitpoints() < cmpHealth.GetMaxHitpoints();
|
||||
ret.needsHeal = !cmpHealth.IsUnhealable();
|
||||
ret.canDelete = !cmpHealth.IsUndeletable();
|
||||
}
|
||||
|
||||
let cmpCapturable = QueryMiragedInterface(ent, IID_Capturable);
|
||||
|
||||
@@ -47,9 +47,6 @@ Health.prototype.Schema =
|
||||
"<text/>" +
|
||||
"</element>" +
|
||||
"</optional>" +
|
||||
"<element name='Undeletable' a:help='Prevent players from deleting this entity.'>" +
|
||||
"<data type='boolean'/>" +
|
||||
"</element>" +
|
||||
"<element name='Unhealable' a:help='Indicates that the entity can not be healed by healer units'>" +
|
||||
"<data type='boolean'/>" +
|
||||
"</element>";
|
||||
@@ -63,7 +60,6 @@ Health.prototype.Init = function()
|
||||
this.hitpoints = +(this.template.Initial || this.GetMaxHitpoints());
|
||||
this.regenRate = ApplyValueModificationsToEntity("Health/RegenRate", +this.template.RegenRate, this.entity);
|
||||
this.idleRegenRate = ApplyValueModificationsToEntity("Health/IdleRegenRate", +this.template.IdleRegenRate, this.entity);
|
||||
this.undeletable = this.template.Undeletable == "true";
|
||||
this.CheckRegenTimer();
|
||||
this.UpdateActor();
|
||||
};
|
||||
@@ -122,16 +118,6 @@ Health.prototype.IsUnhealable = function()
|
||||
|| this.GetHitpoints() >= this.GetMaxHitpoints());
|
||||
};
|
||||
|
||||
Health.prototype.IsUndeletable = function()
|
||||
{
|
||||
return this.undeletable;
|
||||
};
|
||||
|
||||
Health.prototype.SetUndeletable = function(undeletable)
|
||||
{
|
||||
this.undeletable = undeletable;
|
||||
};
|
||||
|
||||
Health.prototype.GetIdleRegenRate = function()
|
||||
{
|
||||
return this.idleRegenRate;
|
||||
|
||||
@@ -86,8 +86,10 @@ Identity.prototype.Schema =
|
||||
"<element name='RequiredTechnology' a:help='Optional name of a technology which must be researched before the entity can be produced.'>" +
|
||||
"<text/>" +
|
||||
"</element>" +
|
||||
"</optional>";
|
||||
|
||||
"</optional>" +
|
||||
"<element name='Undeletable' a:help='Prevent players from deleting this entity.'>" +
|
||||
"<data type='boolean'/>" +
|
||||
"</element>";
|
||||
|
||||
Identity.prototype.Init = function()
|
||||
{
|
||||
@@ -159,4 +161,9 @@ Identity.prototype.GetGenericName = function()
|
||||
return this.template.GenericName;
|
||||
};
|
||||
|
||||
Identity.prototype.IsUndeletable = function()
|
||||
{
|
||||
return this.template.Undeletable == "true";
|
||||
};
|
||||
|
||||
Engine.RegisterComponentType(IID_Identity, "Identity", Identity);
|
||||
|
||||
@@ -15,6 +15,8 @@ Mirage.prototype.Init = function()
|
||||
|
||||
this.miragedIids = new Set();
|
||||
|
||||
this.classesList = [];
|
||||
|
||||
this.buildPercentage = 0;
|
||||
this.numBuilders = 0;
|
||||
|
||||
@@ -22,7 +24,6 @@ Mirage.prototype.Init = function()
|
||||
this.hitpoints = null;
|
||||
this.repairable = null;
|
||||
this.unhealable = null;
|
||||
this.undeletable = null;
|
||||
|
||||
this.capturePoints = [];
|
||||
this.maxCapturePoints = 0;
|
||||
@@ -92,14 +93,12 @@ Mirage.prototype.CopyHealth = function(cmpHealth)
|
||||
this.hitpoints = cmpHealth.GetHitpoints();
|
||||
this.repairable = cmpHealth.IsRepairable();
|
||||
this.unhealable = cmpHealth.IsUnhealable();
|
||||
this.undeletable = cmpHealth.IsUndeletable();
|
||||
};
|
||||
|
||||
Mirage.prototype.GetMaxHitpoints = function() { return this.maxHitpoints; };
|
||||
Mirage.prototype.GetHitpoints = function() { return this.hitpoints; };
|
||||
Mirage.prototype.IsRepairable = function() { return this.repairable; };
|
||||
Mirage.prototype.IsUnhealable = function() { return this.unhealable; };
|
||||
Mirage.prototype.IsUndeletable = function() { return this.undeletable; };
|
||||
|
||||
// Capture data
|
||||
|
||||
|
||||
@@ -40,6 +40,15 @@ SkirmishReplacer.prototype.ReplaceEntities = function()
|
||||
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
|
||||
var templateName = cmpTemplateManager.GetCurrentTemplateName(this.entity);
|
||||
|
||||
let specialFilter = "";
|
||||
let specialFilterPos = templateName.lastIndexOf("|");
|
||||
|
||||
if (specialFilterPos != -1)
|
||||
{
|
||||
specialFilter = templateName.substr(0, specialFilterPos + 1);
|
||||
templateName = templateName.substr(specialFilterPos);
|
||||
}
|
||||
|
||||
if (templateName in replacementEntities)
|
||||
templateName = replacementEntities[templateName];
|
||||
else if (this.template && "general" in this.template)
|
||||
@@ -53,7 +62,7 @@ SkirmishReplacer.prototype.ReplaceEntities = function()
|
||||
return;
|
||||
}
|
||||
|
||||
templateName = templateName.replace(/\{civ\}/g, civ);
|
||||
templateName = specialFilter + templateName.replace(/\{civ\}/g, civ);
|
||||
|
||||
var cmpCurPosition = Engine.QueryInterface(this.entity, IID_Position);
|
||||
var replacement = Engine.AddEntity(templateName);
|
||||
|
||||
@@ -566,8 +566,7 @@ AddMock(10, IID_Health, {
|
||||
GetHitpoints: function() { return 50; },
|
||||
GetMaxHitpoints: function() { return 60; },
|
||||
IsRepairable: function() { return false; },
|
||||
IsUnhealable: function() { return false; },
|
||||
IsUndeletable: function() { return false; }
|
||||
IsUnhealable: function() { return false; }
|
||||
});
|
||||
|
||||
AddMock(10, IID_Identity, {
|
||||
@@ -575,7 +574,8 @@ AddMock(10, IID_Identity, {
|
||||
GetVisibleClassesList: function() { return ["class3", "class4"]; },
|
||||
GetRank: function() { return "foo"; },
|
||||
GetSelectionGroupName: function() { return "Selection Group Name"; },
|
||||
HasClass: function() { return true; }
|
||||
HasClass: function() { return true; },
|
||||
IsUndeletable: function() { return false; }
|
||||
});
|
||||
|
||||
AddMock(10, IID_Position, {
|
||||
@@ -614,7 +614,8 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetEntityState(-1, 10), {
|
||||
rank: "foo",
|
||||
classes: ["class1", "class2"],
|
||||
visibleClasses: ["class3", "class4"],
|
||||
selectionGroupName: "Selection Group Name"
|
||||
selectionGroupName: "Selection Group Name",
|
||||
canDelete: true
|
||||
},
|
||||
fogging: null,
|
||||
foundation: null,
|
||||
@@ -637,8 +638,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetEntityState(-1, 10), {
|
||||
hitpoints: 50,
|
||||
maxHitpoints: 60,
|
||||
needsRepair: false,
|
||||
needsHeal: true,
|
||||
canDelete: true
|
||||
needsHeal: true
|
||||
});
|
||||
|
||||
TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedEntityState(-1, 10), {
|
||||
|
||||
@@ -386,10 +386,10 @@ var g_Commands = {
|
||||
{
|
||||
for (let ent of data.entities)
|
||||
{
|
||||
let cmpHealth = QueryMiragedInterface(ent, IID_Health);
|
||||
if (!data.controlAllUnits)
|
||||
{
|
||||
if (cmpHealth && cmpHealth.IsUndeletable())
|
||||
let cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
|
||||
if (cmpIdentity && cmpIdentity.IsUndeletable())
|
||||
continue;
|
||||
|
||||
let cmpCapturable = QueryMiragedInterface(ent, IID_Capturable);
|
||||
@@ -412,8 +412,11 @@ var g_Commands = {
|
||||
Engine.DestroyEntity(cmpMirage.parent);
|
||||
|
||||
Engine.DestroyEntity(ent);
|
||||
continue;
|
||||
}
|
||||
else if (cmpHealth)
|
||||
|
||||
let cmpHealth = Engine.QueryInterface(ent, IID_Health);
|
||||
if (cmpHealth)
|
||||
cmpHealth.Kill();
|
||||
else
|
||||
Engine.DestroyEntity(ent);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<Tooltip merge=""/>
|
||||
<History merge=""/>
|
||||
<Icon merge=""/>
|
||||
<Undeletable merge=""/>
|
||||
</Identity>
|
||||
<Minimap merge=""/>
|
||||
<Mirage replace=""/>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity merge="">
|
||||
<Identity merge="">
|
||||
<Undeletable>true</Undeletable>
|
||||
</Identity>
|
||||
</Entity>
|
||||
@@ -56,6 +56,7 @@
|
||||
<Civ/>
|
||||
<GenericName>Player</GenericName>
|
||||
<Classes datatype="tokens">Player</Classes>
|
||||
<Undeletable>true</Undeletable>
|
||||
</Identity>
|
||||
<Player>
|
||||
<BarterMultiplier>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<Classes datatype="tokens">Spy</Classes>
|
||||
<GenericName>Spy</GenericName>
|
||||
<RequiredTechnology>unlock_spies</RequiredTechnology>
|
||||
<Undeletable>true</Undeletable>
|
||||
</Identity>
|
||||
<VisionSharing>
|
||||
<Bribable>false</Bribable>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<Identity>
|
||||
<Civ>gaia</Civ>
|
||||
<GenericName>Gaia</GenericName>
|
||||
<Undeletable>true</Undeletable>
|
||||
</Identity>
|
||||
<Obstruction>
|
||||
<Active>true</Active>
|
||||
|
||||
@@ -53,12 +53,12 @@
|
||||
<DeathType>corpse</DeathType>
|
||||
<RegenRate>0</RegenRate>
|
||||
<IdleRegenRate>0</IdleRegenRate>
|
||||
<Undeletable>false</Undeletable>
|
||||
<Unhealable>true</Unhealable>
|
||||
</Health>
|
||||
<Identity>
|
||||
<GenericName>Structure</GenericName>
|
||||
<Classes datatype="tokens">Structure ConquestCritical</Classes>
|
||||
<Undeletable>false</Undeletable>
|
||||
</Identity>
|
||||
<Loot>
|
||||
<xp>0</xp>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<GenericName>City Wall</GenericName>
|
||||
<Tooltip>Wall off your town for a stout defense.</Tooltip>
|
||||
<RequiredTechnology>phase_town</RequiredTechnology>
|
||||
<Undeletable>true</Undeletable>
|
||||
</Identity>
|
||||
<WallSet>
|
||||
<MaxTowerOverlap>0.85</MaxTowerOverlap>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<SpecificName>Settlement</SpecificName>
|
||||
<Tooltip>Build a Civic Center at this location to expand your territory.</Tooltip>
|
||||
<Icon>gaia/special_settlement.png</Icon>
|
||||
<Undeletable>true</Undeletable>
|
||||
</Identity>
|
||||
<Minimap>
|
||||
<Type>settlement</Type>
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<Max>100</Max>
|
||||
<RegenRate>0</RegenRate>
|
||||
<IdleRegenRate>0</IdleRegenRate>
|
||||
<Undeletable>false</Undeletable>
|
||||
<Unhealable>false</Unhealable>
|
||||
</Health>
|
||||
<Identity>
|
||||
@@ -50,6 +49,7 @@
|
||||
special/formations/flank
|
||||
special/formations/battle_line
|
||||
</Formations>
|
||||
<Undeletable>false</Undeletable>
|
||||
</Identity>
|
||||
<Looter/>
|
||||
<Minimap>
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
<Height>2.0</Height>
|
||||
<Square width="5.0" depth="12.0"/>
|
||||
</Footprint>
|
||||
<Health>
|
||||
<Undeletable>true</Undeletable>
|
||||
</Health>
|
||||
<Identity>
|
||||
<Civ>gaia</Civ>
|
||||
<Classes datatype="tokens">-ConquestCritical</Classes>
|
||||
@@ -21,6 +18,7 @@
|
||||
<Icon>units/catafalque.png</Icon>
|
||||
<SelectionGroupName>template_unit_catafalque</SelectionGroupName>
|
||||
<Tooltip>A catafalque that holds the remains of a great leader.</Tooltip>
|
||||
<Undeletable>true</Undeletable>
|
||||
<VisibleClasses datatype="tokens">Relic</VisibleClasses>
|
||||
</Identity>
|
||||
<Minimap>
|
||||
|
||||
Reference in New Issue
Block a user