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);
|
||||
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);
|
||||
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 */
|
||||
/* 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>())
|
||||
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;
|
||||
|
||||
|
||||
@@ -39,32 +39,36 @@ namespace OpenRa.Game.Traits
|
||||
class Building : INotifyDamage, IResolveOrder, ITick
|
||||
{
|
||||
readonly Actor self;
|
||||
public readonly LegacyBuildingInfo unitInfo;
|
||||
[Obsolete] public readonly LegacyBuildingInfo unitInfo;
|
||||
public readonly BuildingInfo Info;
|
||||
[Sync]
|
||||
bool isRepairing = false;
|
||||
[Sync]
|
||||
bool manuallyDisabled = false;
|
||||
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;
|
||||
|
||||
public Building(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
Info = self.Info.Traits.Get<BuildingInfo>();
|
||||
unitInfo = (LegacyBuildingInfo)self.LegacyInfo;
|
||||
self.CenterLocation = Game.CellSize
|
||||
* ((float2)self.Location + .5f * (float2)unitInfo.Dimensions);
|
||||
* ((float2)self.Location + .5f * (float2)Info.Dimensions);
|
||||
}
|
||||
|
||||
public int GetPowerUsage()
|
||||
{
|
||||
if (manuallyDisabled)
|
||||
return 0;
|
||||
|
||||
if (unitInfo.Power > 0) /* todo: is this how real-ra scales it? */
|
||||
return (self.Health * unitInfo.Power) / unitInfo.Strength;
|
||||
|
||||
var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
|
||||
|
||||
if (Info.Power > 0) /* todo: is this how real-ra scales it? */
|
||||
return (self.Health * Info.Power) / maxHP;
|
||||
else
|
||||
return unitInfo.Power;
|
||||
return Info.Power;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
@@ -106,8 +110,9 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
if (remainingTicks == 0)
|
||||
{
|
||||
var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength;
|
||||
var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health);
|
||||
var maxHP = self.Info.Traits.Get<BuildingInfo>().HP;
|
||||
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);
|
||||
if (!self.Owner.TakeCash(cost))
|
||||
{
|
||||
@@ -117,7 +122,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self)));
|
||||
self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]);
|
||||
if (self.Health == self.LegacyInfo.Strength)
|
||||
if (self.Health == maxHP)
|
||||
{
|
||||
isRepairing = false;
|
||||
return;
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class CargoInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Passengers = 0;
|
||||
public readonly UnitMovementType[] PassengerTypes = { };
|
||||
public readonly int UnloadFacing = 0;
|
||||
|
||||
@@ -64,7 +65,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
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)
|
||||
yield return PipType.Transparent;
|
||||
else
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
self.CancelActivity();
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class RallyPointInfo : ITraitInfo
|
||||
{
|
||||
public readonly int[] RallyPoint = { 1, 3 };
|
||||
|
||||
public object Create(Actor self) { return new RallyPoint(self); }
|
||||
}
|
||||
|
||||
@@ -17,8 +19,8 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public RallyPoint(Actor self)
|
||||
{
|
||||
var bi = self.traits.Get<Building>().unitInfo;
|
||||
rallyPoint = self.Location + new int2(bi.RallyPoint[0], bi.RallyPoint[1]);
|
||||
var info = self.Info.Traits.Get<RallyPointInfo>();
|
||||
rallyPoint = self.Location + new int2(info.RallyPoint[0], info.RallyPoint[1]);
|
||||
anim = new Animation("flagfly");
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user