fixing some more bits
This commit is contained in:
@@ -39,7 +39,8 @@ namespace OpenRa.Game.Traits.Activities
|
|||||||
}
|
}
|
||||||
|
|
||||||
var desiredFacing = Util.GetFacing(dist, unit.Facing);
|
var desiredFacing = Util.GetFacing(dist, unit.Facing);
|
||||||
Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT);
|
Util.TickFacing(ref unit.Facing, desiredFacing,
|
||||||
|
self.Info.Traits.Get<HelicopterInfo>().ROT);
|
||||||
|
|
||||||
var rawSpeed = .2f * Util.GetEffectiveSpeed(self);
|
var rawSpeed = .2f * Util.GetEffectiveSpeed(self);
|
||||||
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||||
/* todo: choose the appropriate weapon, when only one works against this target */
|
/* todo: choose the appropriate weapon, when only one works against this target */
|
||||||
var weapon = order.Subject.LegacyInfo.Primary ?? order.Subject.LegacyInfo.Secondary;
|
var weapon = order.Subject.GetPrimaryWeapon() ?? order.Subject.GetSecondaryWeapon();
|
||||||
|
|
||||||
if (self.traits.Contains<Mobile>())
|
if (self.traits.Contains<Mobile>())
|
||||||
self.QueueActivity( new Traits.Activities.Follow( order.TargetActor,
|
self.QueueActivity( new Traits.Activities.Follow( order.TargetActor,
|
||||||
Math.Max( 0, (int)Rules.WeaponInfo[ weapon ].Range - RangeTolerance ) ) );
|
Math.Max( 0, (int)weapon.Range - RangeTolerance ) ) );
|
||||||
|
|
||||||
target = order.TargetActor;
|
target = order.TargetActor;
|
||||||
|
|
||||||
|
|||||||
@@ -39,32 +39,36 @@ namespace OpenRa.Game.Traits
|
|||||||
class Building : INotifyDamage, IResolveOrder, ITick
|
class Building : INotifyDamage, IResolveOrder, ITick
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
public readonly LegacyBuildingInfo unitInfo;
|
[Obsolete] public readonly LegacyBuildingInfo unitInfo;
|
||||||
|
public readonly BuildingInfo Info;
|
||||||
[Sync]
|
[Sync]
|
||||||
bool isRepairing = false;
|
bool isRepairing = false;
|
||||||
[Sync]
|
[Sync]
|
||||||
bool manuallyDisabled = false;
|
bool manuallyDisabled = false;
|
||||||
public bool ManuallyDisabled { get { return manuallyDisabled; } }
|
public bool ManuallyDisabled { get { return manuallyDisabled; } }
|
||||||
public bool Disabled { get { return (manuallyDisabled || (unitInfo.Powered && self.Owner.GetPowerState() != PowerState.Normal)); } }
|
public bool Disabled { get { return (manuallyDisabled || (Info.RequiresPower && self.Owner.GetPowerState() != PowerState.Normal)); } }
|
||||||
bool wasDisabled = false;
|
bool wasDisabled = false;
|
||||||
|
|
||||||
public Building(Actor self)
|
public Building(Actor self)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
|
Info = self.Info.Traits.Get<BuildingInfo>();
|
||||||
unitInfo = (LegacyBuildingInfo)self.LegacyInfo;
|
unitInfo = (LegacyBuildingInfo)self.LegacyInfo;
|
||||||
self.CenterLocation = Game.CellSize
|
self.CenterLocation = Game.CellSize
|
||||||
* ((float2)self.Location + .5f * (float2)unitInfo.Dimensions);
|
* ((float2)self.Location + .5f * (float2)Info.Dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetPowerUsage()
|
public int GetPowerUsage()
|
||||||
{
|
{
|
||||||
if (manuallyDisabled)
|
if (manuallyDisabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (unitInfo.Power > 0) /* todo: is this how real-ra scales it? */
|
var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
|
||||||
return (self.Health * unitInfo.Power) / unitInfo.Strength;
|
|
||||||
|
if (Info.Power > 0) /* todo: is this how real-ra scales it? */
|
||||||
|
return (self.Health * Info.Power) / maxHP;
|
||||||
else
|
else
|
||||||
return unitInfo.Power;
|
return Info.Power;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
@@ -106,8 +110,9 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
if (remainingTicks == 0)
|
if (remainingTicks == 0)
|
||||||
{
|
{
|
||||||
var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength;
|
var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
|
||||||
var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health);
|
var costPerHp = (Rules.General.URepairPercent * self.Info.Traits.Get<BuildableInfo>().Cost) / maxHP;
|
||||||
|
var hpToRepair = Math.Min(Rules.General.URepairStep, maxHP - self.Health);
|
||||||
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
var cost = (int)Math.Ceiling(costPerHp * hpToRepair);
|
||||||
if (!self.Owner.TakeCash(cost))
|
if (!self.Owner.TakeCash(cost))
|
||||||
{
|
{
|
||||||
@@ -117,7 +122,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self)));
|
Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self)));
|
||||||
self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]);
|
self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]);
|
||||||
if (self.Health == self.LegacyInfo.Strength)
|
if (self.Health == maxHP)
|
||||||
{
|
{
|
||||||
isRepairing = false;
|
isRepairing = false;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
class CargoInfo : ITraitInfo
|
class CargoInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
|
public readonly int Passengers = 0;
|
||||||
public readonly UnitMovementType[] PassengerTypes = { };
|
public readonly UnitMovementType[] PassengerTypes = { };
|
||||||
public readonly int UnloadFacing = 0;
|
public readonly int UnloadFacing = 0;
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public IEnumerable<PipType> GetPips( Actor self )
|
public IEnumerable<PipType> GetPips( Actor self )
|
||||||
{
|
{
|
||||||
for (var i = 0; i < self.LegacyInfo.Passengers; i++)
|
for (var i = 0; i < self.Info.Traits.Get<CargoInfo>().Passengers; i++)
|
||||||
if (i >= cargo.Count)
|
if (i >= cargo.Count)
|
||||||
yield return PipType.Transparent;
|
yield return PipType.Transparent;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
|
self.QueueActivity(new ReturnToBase(self, order.TargetActor));
|
||||||
self.QueueActivity(order.TargetActor.LegacyInfo == Rules.UnitInfo["AFLD"]
|
self.QueueActivity(order.TargetActor.Info.Name == "afld"
|
||||||
? (IActivity)new Rearm() : new Repair());
|
? (IActivity)new Rearm() : new Repair());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
class RallyPointInfo : ITraitInfo
|
class RallyPointInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
|
public readonly int[] RallyPoint = { 1, 3 };
|
||||||
|
|
||||||
public object Create(Actor self) { return new RallyPoint(self); }
|
public object Create(Actor self) { return new RallyPoint(self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,8 +19,8 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
public RallyPoint(Actor self)
|
public RallyPoint(Actor self)
|
||||||
{
|
{
|
||||||
var bi = self.traits.Get<Building>().unitInfo;
|
var info = self.Info.Traits.Get<RallyPointInfo>();
|
||||||
rallyPoint = self.Location + new int2(bi.RallyPoint[0], bi.RallyPoint[1]);
|
rallyPoint = self.Location + new int2(info.RallyPoint[0], info.RallyPoint[1]);
|
||||||
anim = new Animation("flagfly");
|
anim = new Animation("flagfly");
|
||||||
anim.PlayRepeating("idle");
|
anim.PlayRepeating("idle");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user