removed LegacyInfo from Actor
This commit is contained in:
@@ -12,11 +12,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
public readonly TypeDictionary traits = new TypeDictionary();
|
public readonly TypeDictionary traits = new TypeDictionary();
|
||||||
|
|
||||||
[Obsolete]
|
|
||||||
public readonly LegacyUnitInfo LegacyInfo;
|
|
||||||
public readonly NewUnitInfo Info;
|
public readonly NewUnitInfo Info;
|
||||||
|
|
||||||
public readonly uint ActorID;
|
public readonly uint ActorID;
|
||||||
[Sync]
|
[Sync]
|
||||||
public int2 Location;
|
public int2 Location;
|
||||||
@@ -29,20 +25,19 @@ namespace OpenRa.Game
|
|||||||
public Actor( string name, int2 location, Player owner )
|
public Actor( string name, int2 location, Player owner )
|
||||||
{
|
{
|
||||||
ActorID = Game.world.NextAID();
|
ActorID = Game.world.NextAID();
|
||||||
LegacyInfo = name != null ? Rules.UnitInfo[name.ToLowerInvariant()] : null; // temporary
|
|
||||||
Location = location;
|
Location = location;
|
||||||
CenterLocation = Traits.Util.CenterOfCell(Location);
|
CenterLocation = Traits.Util.CenterOfCell(Location);
|
||||||
Owner = owner;
|
Owner = owner;
|
||||||
|
|
||||||
if (LegacyInfo == null) return;
|
if (name != null)
|
||||||
|
{
|
||||||
Health = LegacyInfo.Strength; /* todo: fix walls, etc so this is always true! */
|
|
||||||
|
|
||||||
Info = Rules.NewUnitInfo[name.ToLowerInvariant()];
|
Info = Rules.NewUnitInfo[name.ToLowerInvariant()];
|
||||||
|
Health = this.GetMaxHP();
|
||||||
|
|
||||||
foreach (var trait in Info.Traits.WithInterface<ITraitInfo>())
|
foreach (var trait in Info.Traits.WithInterface<ITraitInfo>())
|
||||||
traits.Add(trait.Create(this));
|
traits.Add(trait.Create(this));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
@@ -128,7 +123,7 @@ namespace OpenRa.Game
|
|||||||
public DamageState GetDamageState()
|
public DamageState GetDamageState()
|
||||||
{
|
{
|
||||||
if (Health <= 0) return DamageState.Dead;
|
if (Health <= 0) return DamageState.Dead;
|
||||||
var halfStrength = LegacyInfo.Strength * Rules.General.ConditionYellow;
|
var halfStrength = this.GetMaxHP() * Rules.General.ConditionYellow;
|
||||||
return Health < halfStrength ? DamageState.Half : DamageState.Normal;
|
return Health < halfStrength ? DamageState.Half : DamageState.Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,8 +146,10 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
Game.world.AddFrameEndTask(w => w.Remove(this));
|
Game.world.AddFrameEndTask(w => w.Remove(this));
|
||||||
}
|
}
|
||||||
if (Health > LegacyInfo.Strength)
|
|
||||||
Health = LegacyInfo.Strength;
|
var maxHP = this.GetMaxHP();
|
||||||
|
|
||||||
|
if (Health > maxHP) Health = maxHP;
|
||||||
|
|
||||||
var newState = GetDamageState();
|
var newState = GetDamageState();
|
||||||
|
|
||||||
|
|||||||
@@ -51,5 +51,13 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
return Rules.WeaponInfo[weapon];
|
return Rules.WeaponInfo[weapon];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetMaxHP(this Actor self)
|
||||||
|
{
|
||||||
|
if (self.Info == null) return 0;
|
||||||
|
var oai = self.Info.Traits.GetOrDefault<OwnedActorInfo>();
|
||||||
|
if (oai == null) return 0;
|
||||||
|
return oai.HP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user