Add plumbing to issue orders against a generic Target.

This commit is contained in:
Paul Chote
2017-09-07 18:01:06 +01:00
committed by reaperrr
parent 19b2c33514
commit 4896a90b8d
2 changed files with 26 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
using System;
using System.IO;
using OpenRA.Network;
using OpenRA.Traits;
namespace OpenRA
{
@@ -63,6 +64,21 @@ namespace OpenRA
ExtraData = extraData;
}
Order(string orderString, Actor subject, Target target, bool queued, CPos extraLocation, uint extraData)
{
var targetType = target.SerializableType;
OrderString = orderString;
Subject = subject;
TargetActor = targetType == TargetType.Actor ? target.SerializableActor : null;
TargetLocation = targetType == TargetType.Terrain ? target.SerializableCell.HasValue ?
target.SerializableCell.Value : subject.World.Map.CellContaining(target.CenterPosition) : CPos.Zero;
TargetString = null;
Queued = queued;
ExtraLocation = extraLocation;
ExtraData = targetType == TargetType.FrozenActor ? target.FrozenActor.ID : extraData;
}
public static Order Deserialize(World world, BinaryReader r)
{
var magic = r.ReadByte();
@@ -174,6 +190,9 @@ namespace OpenRA
public Order(string orderString, Actor subject, bool queued)
: this(orderString, subject, null, CPos.Zero, null, queued, CPos.Zero, 0) { }
public Order(string orderString, Actor subject, Target target, bool queued)
: this(orderString, subject, target, queued, CPos.Zero, 0) { }
public Order(string orderstring, Order order)
: this(orderstring, order.Subject, order.TargetActor, order.TargetLocation,
order.TargetString, order.Queued, order.ExtraLocation, order.ExtraData) { }