Split out RenderInfantryProne
This commit is contained in:
@@ -16,7 +16,7 @@ using OpenRA.Mods.RA.Move;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA.Render
|
namespace OpenRA.Mods.RA.Render
|
||||||
{
|
{
|
||||||
public class RenderInfantryInfo : RenderSimpleInfo
|
public class RenderInfantryInfo : RenderSimpleInfo, ITraitPrerequisite<MobileInfo>
|
||||||
{
|
{
|
||||||
public readonly int MinIdleWaitTicks = 30;
|
public readonly int MinIdleWaitTicks = 30;
|
||||||
public readonly int MaxIdleWaitTicks = 110;
|
public readonly int MaxIdleWaitTicks = 110;
|
||||||
@@ -37,8 +37,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
};
|
};
|
||||||
|
|
||||||
public bool Panicked = false;
|
public bool Panicked = false;
|
||||||
public bool Prone = false;
|
protected bool dirty = false;
|
||||||
bool wasProne = false;
|
|
||||||
|
|
||||||
RenderInfantryInfo Info;
|
RenderInfantryInfo Info;
|
||||||
string idleSequence;
|
string idleSequence;
|
||||||
@@ -46,8 +45,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
protected virtual string NormalizeInfantrySequence(Actor self, string baseSequence)
|
protected virtual string NormalizeInfantrySequence(Actor self, string baseSequence)
|
||||||
{
|
{
|
||||||
var prefix = Prone ? "prone-" :
|
var prefix = Panicked ? "panic-" : "";
|
||||||
Panicked ? "panic-" : "";
|
|
||||||
|
|
||||||
if (anim.HasSequence(prefix + baseSequence))
|
if (anim.HasSequence(prefix + baseSequence))
|
||||||
return prefix + baseSequence;
|
return prefix + baseSequence;
|
||||||
@@ -57,7 +55,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
protected virtual bool AllowIdleAnimation(Actor self)
|
protected virtual bool AllowIdleAnimation(Actor self)
|
||||||
{
|
{
|
||||||
return Info.IdleAnimations.Length > 0 && !Prone && !Panicked;
|
return Info.IdleAnimations.Length > 0 && !Panicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimationState State { get; private set; }
|
public AnimationState State { get; private set; }
|
||||||
@@ -84,17 +82,17 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
{
|
{
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
|
|
||||||
if ((State == AnimationState.Moving || wasProne != Prone) && !mobile.IsMoving)
|
if ((State == AnimationState.Moving || dirty) && !mobile.IsMoving)
|
||||||
{
|
{
|
||||||
State = AnimationState.Waiting;
|
State = AnimationState.Waiting;
|
||||||
anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0);
|
anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0);
|
||||||
}
|
}
|
||||||
else if ((State != AnimationState.Moving || wasProne != Prone) && mobile.IsMoving)
|
else if ((State != AnimationState.Moving || dirty) && mobile.IsMoving)
|
||||||
{
|
{
|
||||||
State = AnimationState.Moving;
|
State = AnimationState.Moving;
|
||||||
anim.PlayRepeating(NormalizeInfantrySequence(self, "run"));
|
anim.PlayRepeating(NormalizeInfantrySequence(self, "run"));
|
||||||
}
|
}
|
||||||
wasProne = Prone;
|
dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TickIdle(Actor self)
|
public void TickIdle(Actor self)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using OpenRA.Mods.RA.Render;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class TakeCoverInfo : ITraitInfo, ITraitPrerequisite<RenderInfantryInfo>
|
public class TakeCoverInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly int ProneTime = 100; /* ticks, =4s */
|
public readonly int ProneTime = 100; /* ticks, =4s */
|
||||||
public readonly float ProneDamage = .5f;
|
public readonly float ProneDamage = .5f;
|
||||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Infantry prone behavior
|
// Infantry prone behavior
|
||||||
class TakeCover : ITick, INotifyDamage, IDamageModifier, ISpeedModifier, ISync
|
public class TakeCover : ITick, INotifyDamage, IDamageModifier, ISpeedModifier, ISync
|
||||||
{
|
{
|
||||||
TakeCoverInfo Info;
|
TakeCoverInfo Info;
|
||||||
[Sync]
|
[Sync]
|
||||||
@@ -38,25 +38,14 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Damaged(Actor self, AttackInfo e)
|
public void Damaged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
if (e.Damage > 0) /* Don't go prone when healed */
|
if (e.Damage > 0 && e.Warhead == null || !e.Warhead.PreventProne) /* Don't go prone when healed */
|
||||||
{
|
remainingProneTime = Info.ProneTime;
|
||||||
if (e.Warhead == null || !e.Warhead.PreventProne)
|
|
||||||
{
|
|
||||||
remainingProneTime = Info.ProneTime;
|
|
||||||
self.Trait<RenderInfantry>().Prone = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (!IsProne)
|
if (IsProne)
|
||||||
return;
|
remainingProneTime--;
|
||||||
|
|
||||||
//var ri = self.Trait<RenderInfantry>();
|
|
||||||
|
|
||||||
if (--remainingProneTime <= 0)
|
|
||||||
self.Trait<RenderInfantry>().Prone = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetDamageModifier(Actor attacker, WarheadInfo warhead )
|
public float GetDamageModifier(Actor attacker, WarheadInfo warhead )
|
||||||
@@ -69,4 +58,45 @@ namespace OpenRA.Mods.RA
|
|||||||
return IsProne ? Info.ProneSpeed : 1m;
|
return IsProne ? Info.ProneSpeed : 1m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RenderInfantryProneInfo : RenderInfantryInfo, ITraitPrerequisite<TakeCoverInfo>
|
||||||
|
{
|
||||||
|
public override object Create(ActorInitializer init) { return new RenderInfantryProne(init.self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class RenderInfantryProne : RenderInfantry
|
||||||
|
{
|
||||||
|
readonly TakeCover tc;
|
||||||
|
bool wasProne;
|
||||||
|
|
||||||
|
public RenderInfantryProne(Actor self, RenderInfantryProneInfo info)
|
||||||
|
: base(self, info)
|
||||||
|
{
|
||||||
|
tc = self.Trait<TakeCover>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string NormalizeInfantrySequence(Actor self, string baseSequence)
|
||||||
|
{
|
||||||
|
var prefix = tc != null && tc.IsProne ? "prone-" : "";
|
||||||
|
|
||||||
|
if (anim.HasSequence(prefix + baseSequence))
|
||||||
|
return prefix + baseSequence;
|
||||||
|
else
|
||||||
|
return baseSequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool AllowIdleAnimation(Actor self)
|
||||||
|
{
|
||||||
|
return base.AllowIdleAnimation(self) && !tc.IsProne;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick (Actor self)
|
||||||
|
{
|
||||||
|
if (wasProne != tc.IsProne)
|
||||||
|
dirty = true;
|
||||||
|
|
||||||
|
wasProne = tc.IsProne;
|
||||||
|
base.Tick(self);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,8 @@
|
|||||||
TargetTypes: Ground
|
TargetTypes: Ground
|
||||||
Buildable:
|
Buildable:
|
||||||
Queue: Infantry
|
Queue: Infantry
|
||||||
RenderInfantry:
|
TakeCover:
|
||||||
|
RenderInfantryProne:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
AttackMove:
|
AttackMove:
|
||||||
Passenger:
|
Passenger:
|
||||||
@@ -132,6 +133,9 @@
|
|||||||
Inherits: ^Infantry
|
Inherits: ^Infantry
|
||||||
-Buildable:
|
-Buildable:
|
||||||
-AutoTarget:
|
-AutoTarget:
|
||||||
|
-TakeCover:
|
||||||
|
-RenderInfantryProne:
|
||||||
|
RenderInfantry:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
Selectable:
|
Selectable:
|
||||||
Voice: CivilianMaleVoice
|
Voice: CivilianMaleVoice
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ E1:
|
|||||||
HP: 50
|
HP: 50
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
PrimaryWeapon: M16
|
PrimaryWeapon: M16
|
||||||
TakeCover:
|
RenderInfantryProne:
|
||||||
RenderInfantry:
|
|
||||||
IdleAnimations: idle1,idle2,idle3,idle4
|
IdleAnimations: idle1,idle2,idle3,idle4
|
||||||
E2:
|
E2:
|
||||||
Inherits: ^Infantry
|
Inherits: ^Infantry
|
||||||
@@ -42,8 +41,7 @@ E2:
|
|||||||
PrimaryWeapon: Grenade
|
PrimaryWeapon: Grenade
|
||||||
PrimaryOffset: 0,0,0,-10
|
PrimaryOffset: 0,0,0,-10
|
||||||
FireDelay: 15
|
FireDelay: 15
|
||||||
TakeCover:
|
RenderInfantryProne:
|
||||||
RenderInfantry:
|
|
||||||
IdleAnimations: idle1,idle2
|
IdleAnimations: idle1,idle2
|
||||||
|
|
||||||
E3:
|
E3:
|
||||||
@@ -67,8 +65,7 @@ E3:
|
|||||||
PrimaryWeapon: Rockets
|
PrimaryWeapon: Rockets
|
||||||
PrimaryOffset: 0,0,0,-10
|
PrimaryOffset: 0,0,0,-10
|
||||||
FireDelay: 5
|
FireDelay: 5
|
||||||
TakeCover:
|
RenderInfantryProne:
|
||||||
RenderInfantry:
|
|
||||||
IdleAnimations: idle1,idle2
|
IdleAnimations: idle1,idle2
|
||||||
|
|
||||||
E4:
|
E4:
|
||||||
@@ -93,9 +90,8 @@ E4:
|
|||||||
PrimaryWeapon: Flamethrower
|
PrimaryWeapon: Flamethrower
|
||||||
PrimaryOffset: 0,0,0,-5
|
PrimaryOffset: 0,0,0,-5
|
||||||
FireDelay: 3
|
FireDelay: 3
|
||||||
TakeCover:
|
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
RenderInfantry:
|
RenderInfantryProne:
|
||||||
IdleAnimations: idle1,idle2
|
IdleAnimations: idle1,idle2
|
||||||
|
|
||||||
E5:
|
E5:
|
||||||
@@ -120,10 +116,9 @@ E5:
|
|||||||
PrimaryWeapon: Chemspray
|
PrimaryWeapon: Chemspray
|
||||||
PrimaryOffset: 0,0,0,-5
|
PrimaryOffset: 0,0,0,-5
|
||||||
FireDelay: 3
|
FireDelay: 3
|
||||||
TakeCover:
|
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
-PoisonedByTiberium:
|
-PoisonedByTiberium:
|
||||||
RenderInfantry:
|
RenderInfantryProne:
|
||||||
IdleAnimations: idle1,idle2
|
IdleAnimations: idle1,idle2
|
||||||
|
|
||||||
E6:
|
E6:
|
||||||
@@ -143,7 +138,6 @@ E6:
|
|||||||
Speed: 4
|
Speed: 4
|
||||||
Health:
|
Health:
|
||||||
HP: 25
|
HP: 25
|
||||||
TakeCover:
|
|
||||||
Passenger:
|
Passenger:
|
||||||
PipType: Yellow
|
PipType: Yellow
|
||||||
EngineerRepair:
|
EngineerRepair:
|
||||||
@@ -151,7 +145,7 @@ E6:
|
|||||||
-AutoTarget:
|
-AutoTarget:
|
||||||
AttackMove:
|
AttackMove:
|
||||||
JustMove: true
|
JustMove: true
|
||||||
RenderInfantry:
|
RenderInfantryProne:
|
||||||
IdleAnimations: idle1,idle2
|
IdleAnimations: idle1,idle2
|
||||||
|
|
||||||
RMBO:
|
RMBO:
|
||||||
@@ -175,12 +169,11 @@ RMBO:
|
|||||||
HP: 200
|
HP: 200
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 5
|
Range: 5
|
||||||
TakeCover:
|
|
||||||
C4Demolition:
|
C4Demolition:
|
||||||
C4Delay: .03
|
C4Delay: .03
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
PrimaryWeapon: Sniper
|
PrimaryWeapon: Sniper
|
||||||
RenderInfantry:
|
RenderInfantryProne:
|
||||||
IdleAnimations: idle1,idle2,idle3
|
IdleAnimations: idle1,idle2,idle3
|
||||||
|
|
||||||
VICE:
|
VICE:
|
||||||
@@ -204,3 +197,4 @@ VICE:
|
|||||||
Armor:
|
Armor:
|
||||||
Type: Wood
|
Type: Wood
|
||||||
-PoisonedByTiberium:
|
-PoisonedByTiberium:
|
||||||
|
-TakeCover:
|
||||||
Reference in New Issue
Block a user