started working on the Player-Actor.
This commit is contained in:
@@ -6,7 +6,6 @@ namespace OpenRa.Game
|
||||
{
|
||||
sealed class Order
|
||||
{
|
||||
public readonly Player Player;
|
||||
public readonly string OrderString;
|
||||
readonly uint SubjectId;
|
||||
readonly uint TargetActorId;
|
||||
@@ -16,16 +15,16 @@ namespace OpenRa.Game
|
||||
|
||||
public Actor Subject { get { return ActorFromUInt(SubjectId); } }
|
||||
public Actor TargetActor { get { return ActorFromUInt(TargetActorId); } }
|
||||
public Player Player { get { return Subject.Owner; } }
|
||||
|
||||
public Order(Player player, string orderString, Actor subject,
|
||||
public Order(string orderString, Actor subject,
|
||||
Actor targetActor, int2 targetLocation, string targetString)
|
||||
: this( player, orderString, UIntFromActor( subject ),
|
||||
: this( orderString, UIntFromActor( subject ),
|
||||
UIntFromActor( targetActor ), targetLocation, targetString ) {}
|
||||
|
||||
Order(Player player, string orderString, uint subjectId,
|
||||
Order(string orderString, uint subjectId,
|
||||
uint targetActorId, int2 targetLocation, string targetString)
|
||||
{
|
||||
this.Player = player;
|
||||
this.OrderString = orderString;
|
||||
this.SubjectId = subjectId;
|
||||
this.TargetActorId = targetActorId;
|
||||
@@ -68,7 +67,6 @@ namespace OpenRa.Game
|
||||
var ret = new MemoryStream();
|
||||
var w = new BinaryWriter(ret);
|
||||
w.Write( (byte)0xFF );
|
||||
w.Write( (uint)Player.Index );
|
||||
w.Write(OrderString);
|
||||
w.Write(SubjectId);
|
||||
w.Write(TargetActorId);
|
||||
@@ -95,7 +93,6 @@ namespace OpenRa.Game
|
||||
{
|
||||
case 0xFF:
|
||||
{
|
||||
var playerID = r.ReadUInt32();
|
||||
var order = r.ReadString();
|
||||
var subjectId = r.ReadUInt32();
|
||||
var targetActorId = r.ReadUInt32();
|
||||
@@ -105,9 +102,7 @@ namespace OpenRa.Game
|
||||
if (r.ReadBoolean())
|
||||
targetString = r.ReadString();
|
||||
|
||||
return new Order( LookupPlayer(playerID),
|
||||
order, subjectId, targetActorId, targetLocation,
|
||||
targetString);
|
||||
return new Order( order, subjectId, targetActorId, targetLocation, targetString);
|
||||
}
|
||||
|
||||
case 0xfe:
|
||||
@@ -116,8 +111,7 @@ namespace OpenRa.Game
|
||||
var name = r.ReadString();
|
||||
var data = r.ReadString();
|
||||
|
||||
return new Order(LookupPlayer(playerID),
|
||||
name, null, null, int2.Zero, data) { IsImmediate = true };
|
||||
return new Order( name, LookupPlayer( playerID ).PlayerActor, null, int2.Zero, data ) { IsImmediate = true };
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -141,58 +135,58 @@ namespace OpenRa.Game
|
||||
// Now that Orders are resolved by individual Actors, these are weird; you unpack orders manually, but not pack them.
|
||||
public static Order Chat(Player subject, string text)
|
||||
{
|
||||
return new Order(subject, "Chat", null, null, int2.Zero, text)
|
||||
return new Order("Chat", subject.PlayerActor, null, int2.Zero, text)
|
||||
{ IsImmediate = true };
|
||||
}
|
||||
|
||||
public static Order Attack(Actor subject, Actor target)
|
||||
{
|
||||
return new Order(subject.Owner, "Attack", subject, target, int2.Zero, null);
|
||||
return new Order("Attack", subject, target, int2.Zero, null);
|
||||
}
|
||||
|
||||
public static Order Move(Actor subject, int2 target)
|
||||
{
|
||||
return new Order(subject.Owner, "Move", subject, null, target, null);
|
||||
return new Order("Move", subject, null, target, null);
|
||||
}
|
||||
|
||||
public static Order DeployMcv(Actor subject)
|
||||
{
|
||||
return new Order(subject.Owner, "DeployMcv", subject, null, int2.Zero, null);
|
||||
return new Order("DeployMcv", subject, null, int2.Zero, null);
|
||||
}
|
||||
|
||||
public static Order PlaceBuilding(Player subject, int2 target, string buildingName)
|
||||
{
|
||||
return new Order(subject, "PlaceBuilding", null, null, target, buildingName);
|
||||
return new Order("PlaceBuilding", subject.PlayerActor, null, target, buildingName);
|
||||
}
|
||||
|
||||
public static Order DeliverOre(Actor subject, Actor target)
|
||||
{
|
||||
return new Order(subject.Owner, "DeliverOre", subject, target, int2.Zero, null);
|
||||
return new Order("DeliverOre", subject, target, int2.Zero, null);
|
||||
}
|
||||
|
||||
public static Order Harvest(Actor subject, int2 target)
|
||||
{
|
||||
return new Order(subject.Owner, "Harvest", subject, null, target, null);
|
||||
return new Order("Harvest", subject, null, target, null);
|
||||
}
|
||||
|
||||
public static Order StartProduction(Player subject, string item)
|
||||
{
|
||||
return new Order(subject, "StartProduction", null, null, int2.Zero, item );
|
||||
return new Order("StartProduction", subject.PlayerActor, null, int2.Zero, item );
|
||||
}
|
||||
|
||||
public static Order PauseProduction(Player subject, string item, bool pause)
|
||||
{
|
||||
return new Order( subject, "PauseProduction", null, null, new int2(pause ?1:0,0), item );
|
||||
return new Order("PauseProduction", subject.PlayerActor, null, new int2( pause ? 1 : 0, 0 ), item);
|
||||
}
|
||||
|
||||
public static Order CancelProduction(Player subject, string item)
|
||||
{
|
||||
return new Order( subject, "CancelProduction", null, null, int2.Zero, item );
|
||||
return new Order("CancelProduction", subject.PlayerActor, null, int2.Zero, item);
|
||||
}
|
||||
|
||||
public static Order SetRallyPoint(Actor subject, int2 target)
|
||||
{
|
||||
return new Order(subject.Owner, "SetRallyPoint", subject, null, target, null );
|
||||
return new Order("SetRallyPoint", subject, null, target, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user