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 HasWon { get; private set; }
|
||||
|
||||
public VictoryConditions(Actor self)
|
||||
{
|
||||
}
|
||||
public VictoryConditions(Actor self) { }
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var info = self.Info.Traits.Get<VictoryConditionsInfo>();
|
||||
var hasAnyBuildings = self.World.Queries.OwnedBy[self.Owner]
|
||||
.WithTrait<Building>().Any();
|
||||
var hasAnyShortGameUnits = self.World.Queries.OwnedBy[self.Owner]
|
||||
.Any(a => info.ShortGameUnits.Contains(a.Info.Name));
|
||||
var hasAnything = self.World.Queries.OwnedBy[self.Owner]
|
||||
.WithTrait<MustBeDestroyed>().Any();
|
||||
|
||||
var hasLost = !(hasAnyBuildings || hasAnyShortGameUnits);
|
||||
if (hasLost && !HasLost)
|
||||
if (!hasAnything && !HasLost)
|
||||
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:
|
||||
EmitInfantryOnSell:
|
||||
ActorTypes: c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,e1,e1,e1,e1,e1,e1,e1
|
||||
MustBeDestroyed:
|
||||
|
||||
^Tree:
|
||||
Category: Building
|
||||
|
||||
@@ -23,6 +23,7 @@ MCV:
|
||||
TransformSounds: constru2.aud, hvydoor1.aud
|
||||
NoTransformSounds: deploy1.aud
|
||||
RenderUnit:
|
||||
MustBeDestroyed:
|
||||
|
||||
HARV:
|
||||
Inherits: ^Vehicle
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
RenderBuilding:
|
||||
EmitInfantryOnSell:
|
||||
ActorTypes: e1,e1,e1,c1,c2,e6
|
||||
MustBeDestroyed:
|
||||
|
||||
^Wall:
|
||||
Category: Building
|
||||
|
||||
@@ -280,6 +280,7 @@ MCV:
|
||||
TransformSounds: placbldg.aud, build5.aud
|
||||
NoTransformSounds: nodeply1.aud
|
||||
RenderUnit:
|
||||
MustBeDestroyed:
|
||||
|
||||
JEEP:
|
||||
Inherits: ^Vehicle
|
||||
|
||||
Reference in New Issue
Block a user