started porting traits to use new trait args.
This commit is contained in:
@@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
static Actor ChooseHelipad(Actor self)
|
||||
{
|
||||
return Game.world.Actors.FirstOrDefault(
|
||||
a => a.LegacyInfo == Rules.UnitInfo["HPAD"] &&
|
||||
a => a.Info == Rules.NewUnitInfo["HPAD"] &&
|
||||
a.Owner == self.Owner &&
|
||||
!Reservable.IsReserved(a));
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@ namespace OpenRa.Game.Traits.Activities
|
||||
|
||||
void DoSell(Actor self)
|
||||
{
|
||||
var refund = Rules.General.RefundPercent
|
||||
* self.Health * self.LegacyInfo.Cost / self.LegacyInfo.Strength;
|
||||
var cost = self.Info.Traits.Get<BuildableInfo>().Cost;
|
||||
var hp = self.Info.Traits.WithInterface<OwnedActorInfo>().First().HP;
|
||||
var refund = Rules.General.RefundPercent * self.Health * cost / hp;
|
||||
|
||||
self.Owner.GiveCash((int)refund);
|
||||
self.Health = 0;
|
||||
|
||||
@@ -8,6 +8,15 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AttackBaseInfo : ITraitInfo
|
||||
{
|
||||
public readonly string PrimaryWeapon = null;
|
||||
public readonly string SecondaryWeapon = null;
|
||||
public readonly int Recoil = 0;
|
||||
public readonly int[] PrimaryLocalOffset = { };
|
||||
public readonly int[] SecondaryLocalOffset = { };
|
||||
public readonly int[] PrimaryOffset = { 0, 0 };
|
||||
public readonly int[] SecondaryOffset = null;
|
||||
public readonly bool MuzzleFlash = false;
|
||||
|
||||
public virtual object Create(Actor self) { return new AttackBase(self); }
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,28 @@ using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class BuildingInfo : ITraitInfo
|
||||
class OwnedActorInfo
|
||||
{
|
||||
public readonly int HP = 0;
|
||||
public readonly ArmorType Armor = ArmorType.none;
|
||||
public readonly bool Crewed = false; // replace with trait?
|
||||
public readonly int InitialFacing = 128;
|
||||
}
|
||||
|
||||
class BuildingInfo : OwnedActorInfo, ITraitInfo
|
||||
{
|
||||
public readonly int Power = 0;
|
||||
public readonly bool RequiresPower = false;
|
||||
public readonly bool BaseNormal = true;
|
||||
public readonly int Adjacent = 1;
|
||||
public readonly bool Bib = false;
|
||||
public readonly bool Capturable = false;
|
||||
public readonly bool Repairable = true;
|
||||
public readonly string Footprint = "x";
|
||||
public readonly string[] Produces = { }; // does this go somewhere else?
|
||||
public readonly int2 Dimensions = new int2(1, 1);
|
||||
public readonly bool WaterBound = false;
|
||||
|
||||
public object Create(Actor self) { return new Building(self); }
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace OpenRa.Game.Traits
|
||||
class CargoInfo : ITraitInfo
|
||||
{
|
||||
public readonly UnitMovementType[] PassengerTypes = { };
|
||||
public readonly int UnloadFacing = 0;
|
||||
|
||||
public object Create(Actor self) { return new Cargo(self); }
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits
|
||||
public void OnSteal(Actor self, Actor thief)
|
||||
{
|
||||
// Steal half the ore the building holds
|
||||
var toSteal = (self.LegacyInfo as LegacyBuildingInfo).Storage/2;
|
||||
var toSteal = self.Info.Traits.Get<StoresOreInfo>().Capacity / 2;
|
||||
self.Owner.TakeCash(toSteal);
|
||||
thief.Owner.GiveCash(toSteal);
|
||||
|
||||
@@ -28,15 +28,12 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public IEnumerable<PipType> GetPips(Actor self)
|
||||
{
|
||||
for (int i = 0; i < self.LegacyInfo.OrePips; i++)
|
||||
{
|
||||
if (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / self.LegacyInfo.OrePips)
|
||||
{
|
||||
yield return PipType.Yellow;
|
||||
continue;
|
||||
}
|
||||
yield return PipType.Transparent;
|
||||
}
|
||||
var numPips = self.Info.Traits.Get<StoresOreInfo>().Pips;
|
||||
|
||||
return Graphics.Util.MakeArray( numPips,
|
||||
i => (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / numPips)
|
||||
? PipType.Yellow : PipType.Transparent );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,8 @@
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class UnitInfo : ITraitInfo
|
||||
class UnitInfo : OwnedActorInfo, ITraitInfo
|
||||
{
|
||||
public readonly int HP = 0;
|
||||
public readonly ArmorType Armor = ArmorType.none;
|
||||
public readonly bool Crewed = false; // replace with trait?
|
||||
|
||||
public object Create(Actor self) { return new Unit(self); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user