From b20a8d193e1b528f1cd31208b8115e02fe2f39a3 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 23 Apr 2010 20:42:17 +1200 Subject: [PATCH] use a tag trait to determine what actors must be destroyed in order to win/lose --- .../Traits/Player/VictoryConditions.cs | 20 +++++++++---------- mods/cnc/defaults.yaml | 1 + mods/cnc/vehicles.yaml | 1 + mods/ra/defaults.yaml | 1 + mods/ra/vehicles.yaml | 1 + 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/OpenRA.Game/Traits/Player/VictoryConditions.cs b/OpenRA.Game/Traits/Player/VictoryConditions.cs index f38c6b4fee..d9b376d488 100644 --- a/OpenRA.Game/Traits/Player/VictoryConditions.cs +++ b/OpenRA.Game/Traits/Player/VictoryConditions.cs @@ -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(); - var hasAnyBuildings = self.World.Queries.OwnedBy[self.Owner] - .WithTrait().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().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 { } + class MustBeDestroyed { } } diff --git a/mods/cnc/defaults.yaml b/mods/cnc/defaults.yaml index 60f5ac9d22..bfa1513613 100644 --- a/mods/cnc/defaults.yaml +++ b/mods/cnc/defaults.yaml @@ -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 diff --git a/mods/cnc/vehicles.yaml b/mods/cnc/vehicles.yaml index 5aecbb3abf..74a8958b02 100644 --- a/mods/cnc/vehicles.yaml +++ b/mods/cnc/vehicles.yaml @@ -23,6 +23,7 @@ MCV: TransformSounds: constru2.aud, hvydoor1.aud NoTransformSounds: deploy1.aud RenderUnit: + MustBeDestroyed: HARV: Inherits: ^Vehicle diff --git a/mods/ra/defaults.yaml b/mods/ra/defaults.yaml index 6e35172fe6..4d5ee2c65d 100644 --- a/mods/ra/defaults.yaml +++ b/mods/ra/defaults.yaml @@ -55,6 +55,7 @@ RenderBuilding: EmitInfantryOnSell: ActorTypes: e1,e1,e1,c1,c2,e6 + MustBeDestroyed: ^Wall: Category: Building diff --git a/mods/ra/vehicles.yaml b/mods/ra/vehicles.yaml index e410e9f148..2256c2bc2d 100644 --- a/mods/ra/vehicles.yaml +++ b/mods/ra/vehicles.yaml @@ -280,6 +280,7 @@ MCV: TransformSounds: placbldg.aud, build5.aud NoTransformSounds: nodeply1.aud RenderUnit: + MustBeDestroyed: JEEP: Inherits: ^Vehicle