Rename fields on Repairable traits

To bring them in line with RearmActors,
Repairable.RepairBuildings and
RepairableNear.Buildings have been renamed
to RepairActors.
Additionally, their RA-specific internal
defaults were removed and the FieldLoader
now requires them to be set explicitly.
This commit is contained in:
reaperrr
2018-08-19 21:34:00 +02:00
committed by Oliver Brakmann
parent 6dd84b2882
commit 5ec47b47af
12 changed files with 83 additions and 19 deletions

View File

@@ -20,19 +20,20 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("This actor can be sent to a structure for repairs.")]
class RepairableInfo : ITraitInfo, Requires<IHealthInfo>, Requires<IMoveInfo>
public class RepairableInfo : ITraitInfo, Requires<IHealthInfo>, Requires<IMoveInfo>
{
public readonly HashSet<string> RepairBuildings = new HashSet<string> { "fix" };
[FieldLoader.Require]
[ActorReference] public readonly HashSet<string> RepairActors = new HashSet<string> { };
[VoiceReference] public readonly string Voice = "Action";
[Desc("The amount the unit will be repaired at each step. Use -1 for fallback behavior where HpPerStep from RepairUnit trait will be used.")]
[Desc("The amount the unit will be repaired at each step. Use -1 for fallback behavior where HpPerStep from RepairsUnits trait will be used.")]
public readonly int HpPerStep = -1;
public virtual object Create(ActorInitializer init) { return new Repairable(init.Self, this); }
}
class Repairable : IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated
public class Repairable : IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated
{
public readonly RepairableInfo Info;
readonly IHealth health;
@@ -69,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
bool CanRepairAt(Actor target)
{
return Info.RepairBuildings.Contains(target.Info.Name);
return Info.RepairActors.Contains(target.Info.Name);
}
bool CanRearmAt(Actor target)
@@ -155,7 +156,7 @@ namespace OpenRA.Mods.Common.Traits
var repairBuilding = self.World.ActorsWithTrait<RepairsUnits>()
.Where(a => !a.Actor.IsDead && a.Actor.IsInWorld
&& a.Actor.Owner.IsAlliedWith(self.Owner) &&
Info.RepairBuildings.Contains(a.Actor.Info.Name))
Info.RepairActors.Contains(a.Actor.Info.Name))
.OrderBy(p => (self.Location - p.Actor.Location).LengthSquared);
// Worst case FirstOrDefault() will return a TraitPair<null, null>, which is OK.