From a3ba286b06be54fa0d7f9b4914bd8d32cdbab215 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 14 Jan 2010 17:17:23 +1300 Subject: [PATCH] unhacking Player and World actors --- OpenRa.Game/Chrome.cs | 2 +- OpenRa.Game/Game.cs | 7 ++----- OpenRa.Game/Graphics/Viewport.cs | 4 +++- OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs | 5 +---- OpenRa.Game/Traits/WaterPaletteRotation.cs | 5 +---- defaults.yaml | 6 ++++++ 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index dc59dfc338..60a6275b4a 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -120,7 +120,7 @@ namespace OpenRa.Game u => u.Key, u => SpriteSheetBuilder.LoadAllSprites(u.Value.Image)[0]); - var groups = Rules.NewUnitInfo.Values.Select( x => x.Category ).Distinct().ToList(); + var groups = Rules.NewUnitInfo.Values.Select( x => x.Category ).Distinct().Where( g => g != null ).ToList(); tabImageNames = groups.Select( (g, i) => Pair.New(g, diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 3f052a1f1a..dc992e574c 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -70,16 +70,13 @@ namespace OpenRa.Game var race = players.ContainsKey(i) ? players[i].Race : Race.Allies; var name = players.ContainsKey(i) ? players[i].PlayerName : "Player {0}".F(i+1); - var a = new Actor(null, new int2(int.MaxValue, int.MaxValue), null); + var a = new Actor("Player", new int2(int.MaxValue, int.MaxValue), null); players[i] = new Player(a, i, (PaletteType) i, name, race, "Multi{0}".F(i)); a.Owner = players[i]; - a.traits.Add(new Traits.ProductionQueue(a)); Game.world.Add(a); } - var worldActor = new Actor(null, new int2(int.MaxValue, int.MaxValue), null); - worldActor.traits.Add(new WaterPaletteRotation(worldActor)); - worldActor.traits.Add(new ChronoshiftPaletteEffect(worldActor)); + var worldActor = new Actor("World", new int2(int.MaxValue, int.MaxValue), null); Game.world.Add(worldActor); Rules.Map.InitOreDensity(); diff --git a/OpenRa.Game/Graphics/Viewport.cs b/OpenRa.Game/Graphics/Viewport.cs index 9a35a4ef5b..e761e718ed 100644 --- a/OpenRa.Game/Graphics/Viewport.cs +++ b/OpenRa.Game/Graphics/Viewport.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; +using OpenRa.Game.Traits; namespace OpenRa.Game.Graphics { @@ -97,7 +98,8 @@ namespace OpenRa.Game.Graphics public void GoToStartLocation() { - Center(Game.world.Actors.Where(a => a.Info != null && a.Owner == Game.LocalPlayer)); + Center(Game.world.Actors.Where(a => a.Info != null + && a.traits.Contains() && a.Owner == Game.LocalPlayer)); } } } diff --git a/OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs b/OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs index dc2ef912e2..218919b93a 100644 --- a/OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs +++ b/OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs @@ -3,16 +3,13 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { - // this is NOT bound through rules (it belongs on the world actor!) - // so no *Info required + class ChronoshiftPaletteEffectInfo : StatelessTraitInfo { } class ChronoshiftPaletteEffect : IPaletteModifier, ITick { const int chronoEffectLength = 20; int remainingFrames; - public ChronoshiftPaletteEffect(Actor self) { } - public void DoChronoshift() { remainingFrames = chronoEffectLength; diff --git a/OpenRa.Game/Traits/WaterPaletteRotation.cs b/OpenRa.Game/Traits/WaterPaletteRotation.cs index cba52f71a5..8b15caa8cb 100644 --- a/OpenRa.Game/Traits/WaterPaletteRotation.cs +++ b/OpenRa.Game/Traits/WaterPaletteRotation.cs @@ -2,13 +2,10 @@ namespace OpenRa.Game.Traits { - // this is NOT bound through rules (it belongs on the world actor!) - // so no *Info required + class WaterPaletteRotationInfo : StatelessTraitInfo { } class WaterPaletteRotation : ITick, IPaletteModifier { - public WaterPaletteRotation(Actor self) { } - float t = 0; public void Tick(Actor self) { diff --git a/defaults.yaml b/defaults.yaml index 515857f7c5..20e836d3bf 100644 --- a/defaults.yaml +++ b/defaults.yaml @@ -42,3 +42,9 @@ Priority: 3 Building: +Player: + ProductionQueue: + +World: + WaterPaletteRotation: + ChronoshiftPaletteEffect: \ No newline at end of file