Use HasMovementType to avoid Enum.HasFlag allocations.

This commit is contained in:
RoosterDragon
2020-10-11 11:49:32 +01:00
committed by abcdefg30
parent 094ccf76b0
commit 2adee1e374
4 changed files with 7 additions and 7 deletions

View File

@@ -72,8 +72,8 @@ namespace OpenRA.Mods.Cnc.Traits.Render
void ITick.Tick(Actor self) void ITick.Tick(Actor self)
{ {
if (movement.CurrentMovementTypes.HasFlag(MovementType.Horizontal) if (movement.CurrentMovementTypes.HasMovementType(MovementType.Horizontal)
|| movement.CurrentMovementTypes.HasFlag(MovementType.Turn)) || movement.CurrentMovementTypes.HasMovementType(MovementType.Turn))
tick++; tick++;
if (tick < info.TickRate) if (tick < info.TickRate)

View File

@@ -419,7 +419,7 @@ namespace OpenRA.Mods.Common.Traits
CurrentMovementTypes = newMovementTypes; CurrentMovementTypes = newMovementTypes;
if (!CurrentMovementTypes.HasFlag(MovementType.Horizontal)) if (!CurrentMovementTypes.HasMovementType(MovementType.Horizontal))
{ {
if (Info.Roll != WAngle.Zero && Roll != WAngle.Zero) if (Info.Roll != WAngle.Zero && Roll != WAngle.Zero)
Roll = Util.TickFacing(Roll, WAngle.Zero, Info.RollSpeed); Roll = Util.TickFacing(Roll, WAngle.Zero, Info.RollSpeed);

View File

@@ -402,10 +402,10 @@ namespace OpenRA.Mods.Common.Traits
public bool IsLeaving() public bool IsLeaving()
{ {
if (CurrentMovementTypes.HasFlag(MovementType.Horizontal)) if (CurrentMovementTypes.HasMovementType(MovementType.Horizontal))
return true; return true;
if (CurrentMovementTypes.HasFlag(MovementType.Turn)) if (CurrentMovementTypes.HasMovementType(MovementType.Turn))
return TurnToMove; return TurnToMove;
return false; return false;

View File

@@ -168,12 +168,12 @@ namespace OpenRA.Mods.Common.Traits.Render
wasModifying = rsm.IsModifyingSequence; wasModifying = rsm.IsModifyingSequence;
} }
if ((state != AnimationState.Moving || dirty) && move.CurrentMovementTypes.HasFlag(MovementType.Horizontal)) if ((state != AnimationState.Moving || dirty) && move.CurrentMovementTypes.HasMovementType(MovementType.Horizontal))
{ {
state = AnimationState.Moving; state = AnimationState.Moving;
DefaultAnimation.PlayRepeating(NormalizeInfantrySequence(self, GetDisplayInfo().MoveSequence)); DefaultAnimation.PlayRepeating(NormalizeInfantrySequence(self, GetDisplayInfo().MoveSequence));
} }
else if (((state == AnimationState.Moving || dirty) && !move.CurrentMovementTypes.HasFlag(MovementType.Horizontal)) else if (((state == AnimationState.Moving || dirty) && !move.CurrentMovementTypes.HasMovementType(MovementType.Horizontal))
|| ((state == AnimationState.Idle || state == AnimationState.IdleAnimating) && !self.IsIdle)) || ((state == AnimationState.Idle || state == AnimationState.IdleAnimating) && !self.IsIdle))
PlayStandAnimation(self); PlayStandAnimation(self);