unhacking Player and World actors

This commit is contained in:
Chris Forbes
2010-01-14 17:17:23 +13:00
parent 1557a77fec
commit a3ba286b06
6 changed files with 14 additions and 15 deletions

View File

@@ -120,7 +120,7 @@ namespace OpenRa.Game
u => u.Key, u => u.Key,
u => SpriteSheetBuilder.LoadAllSprites(u.Value.Image)[0]); 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( tabImageNames = groups.Select(
(g, i) => Pair.New(g, (g, i) => Pair.New(g,

View File

@@ -70,16 +70,13 @@ namespace OpenRa.Game
var race = players.ContainsKey(i) ? players[i].Race : Race.Allies; var race = players.ContainsKey(i) ? players[i].Race : Race.Allies;
var name = players.ContainsKey(i) ? players[i].PlayerName : "Player {0}".F(i+1); 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)); players[i] = new Player(a, i, (PaletteType) i, name, race, "Multi{0}".F(i));
a.Owner = players[i]; a.Owner = players[i];
a.traits.Add(new Traits.ProductionQueue(a));
Game.world.Add(a); Game.world.Add(a);
} }
var worldActor = new Actor(null, new int2(int.MaxValue, int.MaxValue), null); var worldActor = new Actor("World", new int2(int.MaxValue, int.MaxValue), null);
worldActor.traits.Add(new WaterPaletteRotation(worldActor));
worldActor.traits.Add(new ChronoshiftPaletteEffect(worldActor));
Game.world.Add(worldActor); Game.world.Add(worldActor);
Rules.Map.InitOreDensity(); Rules.Map.InitOreDensity();

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using OpenRa.Game.Traits;
namespace OpenRa.Game.Graphics namespace OpenRa.Game.Graphics
{ {
@@ -97,7 +98,8 @@ namespace OpenRa.Game.Graphics
public void GoToStartLocation() 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<Selectable>() && a.Owner == Game.LocalPlayer));
} }
} }
} }

View File

@@ -3,16 +3,13 @@ using OpenRa.Game.Graphics;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
// this is NOT bound through rules (it belongs on the world actor!) class ChronoshiftPaletteEffectInfo : StatelessTraitInfo<ChronoshiftPaletteEffect> { }
// so no *Info required
class ChronoshiftPaletteEffect : IPaletteModifier, ITick class ChronoshiftPaletteEffect : IPaletteModifier, ITick
{ {
const int chronoEffectLength = 20; const int chronoEffectLength = 20;
int remainingFrames; int remainingFrames;
public ChronoshiftPaletteEffect(Actor self) { }
public void DoChronoshift() public void DoChronoshift()
{ {
remainingFrames = chronoEffectLength; remainingFrames = chronoEffectLength;

View File

@@ -2,13 +2,10 @@
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
// this is NOT bound through rules (it belongs on the world actor!) class WaterPaletteRotationInfo : StatelessTraitInfo<WaterPaletteRotation> { }
// so no *Info required
class WaterPaletteRotation : ITick, IPaletteModifier class WaterPaletteRotation : ITick, IPaletteModifier
{ {
public WaterPaletteRotation(Actor self) { }
float t = 0; float t = 0;
public void Tick(Actor self) public void Tick(Actor self)
{ {

View File

@@ -42,3 +42,9 @@
Priority: 3 Priority: 3
Building: Building:
Player:
ProductionQueue:
World:
WaterPaletteRotation:
ChronoshiftPaletteEffect: