use a tag trait to determine what actors must be destroyed in order to win/lose
This commit is contained in:
@@ -18,23 +18,23 @@ namespace OpenRA.Traits
|
|||||||
public bool HasLost { get; private set; }
|
public bool HasLost { get; private set; }
|
||||||
public bool HasWon { get; private set; }
|
public bool HasWon { get; private set; }
|
||||||
|
|
||||||
public VictoryConditions(Actor self)
|
public VictoryConditions(Actor self) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
var info = self.Info.Traits.Get<VictoryConditionsInfo>();
|
var info = self.Info.Traits.Get<VictoryConditionsInfo>();
|
||||||
var hasAnyBuildings = self.World.Queries.OwnedBy[self.Owner]
|
var hasAnything = self.World.Queries.OwnedBy[self.Owner]
|
||||||
.WithTrait<Building>().Any();
|
.WithTrait<MustBeDestroyed>().Any();
|
||||||
var hasAnyShortGameUnits = self.World.Queries.OwnedBy[self.Owner]
|
|
||||||
.Any(a => info.ShortGameUnits.Contains(a.Info.Name));
|
|
||||||
|
|
||||||
var hasLost = !(hasAnyBuildings || hasAnyShortGameUnits);
|
if (!hasAnything && !HasLost)
|
||||||
if (hasLost && !HasLost)
|
|
||||||
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
|
Game.Debug("{0} is defeated.".F(self.Owner.PlayerName));
|
||||||
|
|
||||||
HasLost = hasLost;
|
HasLost = !hasAnything;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* tag trait for things that must be destroyed for a short game to end */
|
||||||
|
|
||||||
|
class MustBeDestroyedInfo : TraitInfo<MustBeDestroyed> { }
|
||||||
|
class MustBeDestroyed { }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
CriticalBuildingState:
|
CriticalBuildingState:
|
||||||
EmitInfantryOnSell:
|
EmitInfantryOnSell:
|
||||||
ActorTypes: c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,e1,e1,e1,e1,e1,e1,e1
|
ActorTypes: c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,e1,e1,e1,e1,e1,e1,e1
|
||||||
|
MustBeDestroyed:
|
||||||
|
|
||||||
^Tree:
|
^Tree:
|
||||||
Category: Building
|
Category: Building
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ MCV:
|
|||||||
TransformSounds: constru2.aud, hvydoor1.aud
|
TransformSounds: constru2.aud, hvydoor1.aud
|
||||||
NoTransformSounds: deploy1.aud
|
NoTransformSounds: deploy1.aud
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
|
MustBeDestroyed:
|
||||||
|
|
||||||
HARV:
|
HARV:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Vehicle
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
RenderBuilding:
|
RenderBuilding:
|
||||||
EmitInfantryOnSell:
|
EmitInfantryOnSell:
|
||||||
ActorTypes: e1,e1,e1,c1,c2,e6
|
ActorTypes: e1,e1,e1,c1,c2,e6
|
||||||
|
MustBeDestroyed:
|
||||||
|
|
||||||
^Wall:
|
^Wall:
|
||||||
Category: Building
|
Category: Building
|
||||||
|
|||||||
@@ -280,6 +280,7 @@ MCV:
|
|||||||
TransformSounds: placbldg.aud, build5.aud
|
TransformSounds: placbldg.aud, build5.aud
|
||||||
NoTransformSounds: nodeply1.aud
|
NoTransformSounds: nodeply1.aud
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
|
MustBeDestroyed:
|
||||||
|
|
||||||
JEEP:
|
JEEP:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Vehicle
|
||||||
|
|||||||
Reference in New Issue
Block a user