Convert masses of HashSet<string> to BitSet<DamageType>

This commit is contained in:
Chris Forbes
2018-07-27 22:24:51 -07:00
committed by Paul Chote
parent 6d12e84bd9
commit d4ef841678
29 changed files with 86 additions and 62 deletions

View File

@@ -16,6 +16,7 @@ using OpenRA.Activities;
using OpenRA.GameRules;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Traits.Render;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Activities
@@ -30,9 +31,9 @@ namespace OpenRA.Mods.Cnc.Activities
WPos to;
int ticks;
WAngle angle;
HashSet<string> damageTypes;
BitSet<DamageType> damageTypes;
public Leap(Actor self, Actor target, Armament a, WDist speed, WAngle angle, HashSet<string> damageTypes)
public Leap(Actor self, Actor target, Armament a, WDist speed, WAngle angle, BitSet<DamageType> damageTypes)
{
var targetMobile = target.TraitOrDefault<Mobile>();
if (targetMobile == null)

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.Cnc.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
@@ -26,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly WAngle Angle = WAngle.FromDegrees(20);
[Desc("Types of damage that this trait causes. Leave empty for no damage types.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>();
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
public override object Create(ActorInitializer init) { return new AttackLeap(init.Self, this); }
}

View File

@@ -9,7 +9,6 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using OpenRA.Mods.Cnc.Activities;
using OpenRA.Mods.Common.Traits;
@@ -25,7 +24,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly bool ExplodeInstead = false;
[Desc("Types of damage that this trait causes to self when 'ExplodeInstead' is true. Leave empty for no damage types.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>();
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
public readonly string ChronoshiftSound = "chrono2.aud";

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly int Damage = 1000;
[Desc("Apply the damage using these damagetypes.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>();
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
[Desc("Actor to transform into when the timer expires during (un)deploy."), ActorReference]
public readonly string OriginalActor = "mcv";

View File

@@ -54,7 +54,7 @@ namespace OpenRA.Mods.Cnc.Traits
public WeaponInfo DetonationWeaponInfo { get; private set; }
[Desc("Types of damage that this trait causes to self while self-destructing. Leave empty for no damage types.")]
public readonly HashSet<string> DamageTypes = new HashSet<string>();
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
public object Create(ActorInitializer init) { return new MadTank(init.Self, this); }
public void RulesetLoaded(Ruleset rules, ActorInfo ai)

View File

@@ -11,6 +11,7 @@
using System.Collections.Generic;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
@@ -48,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Traits
if (mobile != null && !info.DetonateClasses.Overlaps(mobile.Info.LocomotorInfo.Crushes))
return;
self.Kill(crusher, mobile != null ? mobile.Info.LocomotorInfo.CrushDamageTypes : new HashSet<string>());
self.Kill(crusher, mobile != null ? mobile.Info.LocomotorInfo.CrushDamageTypes : default(BitSet<DamageType>));
}
bool ICrushable.CrushableBy(Actor self, Actor crusher, HashSet<string> crushClasses)