diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 82cb4ac824..1358ef9ef4 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -44,7 +44,9 @@ namespace OpenRA public Player Owner; [Sync] public int Health; - IActivity currentActivity; + + IActivity currentActivity; + public Group Group; public Actor(World world, string name, int2 location, Player owner) { diff --git a/OpenRA.Game/Group.cs b/OpenRA.Game/Group.cs new file mode 100644 index 0000000000..dafd135a74 --- /dev/null +++ b/OpenRA.Game/Group.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRA +{ + public class Group + { + List actors; + int id; + + static int nextGroup; + + public IEnumerable Actors { get { return actors; } } + + public Group(IEnumerable actors) + { + this.actors = actors.ToList(); + + foreach (var a in actors) + a.Group = this; + + id = nextGroup++; + } + + public void Dump() + { + /* debug crap */ + Game.Debug("Group #{0}: {1}".F( + id, string.Join(",", actors.Select(a => "#{0} {1}".F(a.ActorID, a.Info.Name)).ToArray()))); + } + + /* todo: add lazy group path crap, groupleader, pruning, etc */ + } +} diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 976f812613..7a716137b1 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -79,6 +79,7 @@ + diff --git a/OpenRA.Game/Traits/Player/ActorGroupProxy.cs b/OpenRA.Game/Traits/Player/ActorGroupProxy.cs index d96c21ebc3..c112555617 100644 --- a/OpenRA.Game/Traits/Player/ActorGroupProxy.cs +++ b/OpenRA.Game/Traits/Player/ActorGroupProxy.cs @@ -14,7 +14,13 @@ namespace OpenRA.Traits if (order.OrderString == "CreateGroup") { /* create a group */ + var actors = order.TargetString.Split(',') + .Select(id => uint.Parse(id)) + .Select(id => self.World.Actors.FirstOrDefault(a => a.ActorID == id)) + .Where(a => a != null); + var g = new Group(actors); + g.Dump(); } } }