Add Types to EngineerRepair(able).
This commit is contained in:
committed by
reaperrr
parent
e63f52c43f
commit
c89d90e4b0
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Activities;
|
using OpenRA.Mods.Common.Activities;
|
||||||
using OpenRA.Mods.Common.Orders;
|
using OpenRA.Mods.Common.Orders;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
@@ -20,6 +21,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Can instantly repair other actors, but gets consumed afterwards.")]
|
[Desc("Can instantly repair other actors, but gets consumed afterwards.")]
|
||||||
class EngineerRepairInfo : ITraitInfo
|
class EngineerRepairInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
|
[Desc("Uses the \"EngineerRepairable\" trait to determine repairability.")]
|
||||||
|
public readonly BitSet<EngineerRepairType> Types = default(BitSet<EngineerRepairType>);
|
||||||
|
|
||||||
[VoiceReference] public readonly string Voice = "Action";
|
[VoiceReference] public readonly string Voice = "Action";
|
||||||
|
|
||||||
[Desc("Behaviour when entering the structure.",
|
[Desc("Behaviour when entering the structure.",
|
||||||
@@ -104,7 +108,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
|
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
if (!target.Info.HasTraitInfo<EngineerRepairableInfo>())
|
var engineerRepairable = target.Info.TraitInfoOrDefault<EngineerRepairableInfo>();
|
||||||
|
if (engineerRepairable == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!engineerRepairable.Types.IsEmpty && !engineerRepairable.Types.Overlaps(info.Types))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!info.ValidStances.HasStance(self.Owner.Stances[target.Owner]))
|
if (!info.ValidStances.HasStance(self.Owner.Stances[target.Owner]))
|
||||||
@@ -118,7 +126,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
|
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
if (!target.Info.HasTraitInfo<EngineerRepairableInfo>())
|
var engineerRepairable = target.Info.TraitInfoOrDefault<EngineerRepairableInfo>();
|
||||||
|
if (engineerRepairable == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!engineerRepairable.Types.IsEmpty && !engineerRepairable.Types.Overlaps(info.Types))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!info.ValidStances.HasStance(self.Owner.Stances[target.Owner]))
|
if (!info.ValidStances.HasStance(self.Owner.Stances[target.Owner]))
|
||||||
|
|||||||
@@ -9,12 +9,19 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
|
public class EngineerRepairType { }
|
||||||
|
|
||||||
[Desc("Eligible for instant repair.")]
|
[Desc("Eligible for instant repair.")]
|
||||||
class EngineerRepairableInfo : TraitInfo<EngineerRepairable> { }
|
class EngineerRepairableInfo : TraitInfo<EngineerRepairable>
|
||||||
|
{
|
||||||
|
[Desc("Actors with these Types under EngineerRepair trait can repair me.")]
|
||||||
|
public readonly BitSet<EngineerRepairType> Types = default(BitSet<EngineerRepairType>);
|
||||||
|
}
|
||||||
|
|
||||||
class EngineerRepairable { }
|
class EngineerRepairable { }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user