synced group creation
This commit is contained in:
@@ -44,7 +44,9 @@ namespace OpenRA
|
||||
public Player Owner;
|
||||
[Sync]
|
||||
public int Health;
|
||||
|
||||
IActivity currentActivity;
|
||||
public Group Group;
|
||||
|
||||
public Actor(World world, string name, int2 location, Player owner)
|
||||
{
|
||||
|
||||
36
OpenRA.Game/Group.cs
Normal file
36
OpenRA.Game/Group.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
public class Group
|
||||
{
|
||||
List<Actor> actors;
|
||||
int id;
|
||||
|
||||
static int nextGroup;
|
||||
|
||||
public IEnumerable<Actor> Actors { get { return actors; } }
|
||||
|
||||
public Group(IEnumerable<Actor> 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 */
|
||||
}
|
||||
}
|
||||
@@ -79,6 +79,7 @@
|
||||
<Compile Include="Chrome.cs" />
|
||||
<Compile Include="Effects\GravityBomb.cs" />
|
||||
<Compile Include="GameRules\WeaponInfo.cs" />
|
||||
<Compile Include="Group.cs" />
|
||||
<Compile Include="Orders\GenericSelectTarget.cs" />
|
||||
<Compile Include="Traits\Activities\Leap.cs" />
|
||||
<Compile Include="Traits\AI\EmitInfantryOnSell.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user