Remove Actor.HasTrait<T>()
This commit is contained in:
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var building = order.TargetActor;
|
||||
|
||||
if (building.HasTrait<RepairableBuilding>())
|
||||
if (building.Info.Traits.Contains<RepairableBuildingInfo>())
|
||||
if (building.AppearsFriendlyTo(self))
|
||||
building.Trait<RepairableBuilding>().RepairBuilding(building, self.Owner);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
// only track last hit against our base
|
||||
if (!self.HasTrait<Building>())
|
||||
if (!self.Info.Traits.Contains<BuildingInfo>())
|
||||
return;
|
||||
|
||||
if (e.Attacker == null)
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
// only track last hit against our base
|
||||
if (!self.HasTrait<Harvester>())
|
||||
// only track last hit against our harvesters
|
||||
if (!self.Info.Traits.Contains<HarvesterInfo>())
|
||||
return;
|
||||
|
||||
// don't track self-damage
|
||||
|
||||
@@ -107,18 +107,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var attackerStats = e.Attacker.Owner.PlayerActor.Trait<PlayerStatistics>();
|
||||
var defenderStats = self.Owner.PlayerActor.Trait<PlayerStatistics>();
|
||||
if (self.HasTrait<Building>())
|
||||
if (self.Info.Traits.Contains<BuildingInfo>())
|
||||
{
|
||||
attackerStats.BuildingsKilled++;
|
||||
defenderStats.BuildingsDead++;
|
||||
}
|
||||
else if (self.HasTrait<IPositionable>())
|
||||
else if (self.Info.Traits.Contains<IPositionableInfo>())
|
||||
{
|
||||
attackerStats.UnitsKilled++;
|
||||
defenderStats.UnitsDead++;
|
||||
}
|
||||
|
||||
if (self.HasTrait<Valued>())
|
||||
if (self.Info.Traits.Contains<ValuedInfo>())
|
||||
{
|
||||
var cost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
attackerStats.KillsCost += cost;
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class ProvidesPrerequisiteInfo : ITraitInfo
|
||||
public class ProvidesPrerequisiteInfo : ITechTreePrerequisiteInfo
|
||||
{
|
||||
[Desc("The prerequisite type that this provides. If left empty it defaults to the actor's name.")]
|
||||
public readonly string Prerequisite = null;
|
||||
|
||||
@@ -13,7 +13,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class ProvidesTechPrerequisiteInfo : ITraitInfo
|
||||
public class ProvidesTechPrerequisiteInfo : ITechTreePrerequisiteInfo
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string[] Prerequisites = { };
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void ActorChanged(Actor a)
|
||||
{
|
||||
var bi = a.Info.Traits.GetOrDefault<BuildableInfo>();
|
||||
if (a.Owner == player && (a.HasTrait<ITechTreePrerequisite>() || (bi != null && bi.BuildLimit > 0)))
|
||||
if (a.Owner == player && (a.Info.Traits.Contains<ITechTreePrerequisiteInfo>() || (bi != null && bi.BuildLimit > 0)))
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user