File size: 4,581 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
enum eAnimFinishType
{
SUCCESS,
FAILURE,
}
class SmptAnimMetaBase
{
bool m_IsPlaying;
SymptomManager m_Manager;
PlayerBase m_Player;
int m_AnimID;
int m_SymptomType;
int m_StateType;
bool m_DestroyRequested;
bool m_Canceled;
void SmptAnimMetaBase()
{
}
void Init(ParamsReadContext ctx, SymptomManager manager, PlayerBase player)
{
m_Manager = manager;
m_Player = player;
}
bool IsPlaying()
{
return m_IsPlaying;
}
bool IsDestroyReqested()
{
return m_DestroyRequested;
}
void AnimFinished(eAnimFinishType type)
{
m_DestroyRequested = true;
SymptomBase Symptom = m_Manager.GetCurrentPrimaryActiveSymptom();
if( type == eAnimFinishType.FAILURE)// <--------------- FAILED
{
if( m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
{
if( Symptom )
{
Symptom.AnimationPlayFailed();
}
}
}
else if( type == eAnimFinishType.SUCCESS)// <--------------- SUCCESS
{
if( m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || !GetGame().IsMultiplayer())
{
if( Symptom )
{
Symptom.AnimationFinish();
}
}
}
}
EAnimPlayState PlayRequest()
{
EAnimPlayState played = Play();
if(played == EAnimPlayState.FAILED)
{
m_Manager.OnAnimationFinished(eAnimFinishType.FAILURE);
}
return played;
}
protected EAnimPlayState Play();
void Update(HumanMovementState movement_state);
};
class SmptAnimMetaFB extends SmptAnimMetaBase
{
int m_StanceMask;
float m_Duration;
void ~SmptAnimMetaFB()
{
if(m_Player)
m_Player.m_isFBsymptomPlaying = false;
}
override void Init(ParamsReadContext ctx, SymptomManager manager, PlayerBase player)
{
super.Init(ctx, manager, player);
DayZPlayerSyncJunctures.ReadPlayerSymptomFBParams( ctx, m_AnimID, m_StanceMask, m_Duration);
}
override EAnimPlayState Play()
{
m_Canceled = false;
HumanCommandActionCallback callback = m_Player.GetCommand_Action();
if (!callback)
{
callback = m_Player.GetCommandModifier_Action();
}
if( callback )
{
callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
m_Canceled = true;
}
if(!m_Canceled)
{
SymptomCB anim_callback = SymptomCB.Cast(m_Player.StartCommand_Action(m_AnimID, SymptomCB, m_StanceMask));
if(anim_callback)
{
anim_callback.Init(m_Duration, m_Player);
m_IsPlaying = true;
m_Player.m_isFBsymptomPlaying = true;
return EAnimPlayState.OK;
}
else
{
return EAnimPlayState.FAILED;
}
}
return EAnimPlayState.POSTPONED;
}
}
class SmptAnimMetaADD extends SmptAnimMetaBase
{
bool m_CalledAnimStart;
override void Init(ParamsReadContext ctx, SymptomManager manager, PlayerBase player)
{
super.Init(ctx, manager, player);
DayZPlayerSyncJunctures.ReadPlayerSymptomADDParams( ctx, m_AnimID);
}
override EAnimPlayState Play()
{
HumanCommandActionCallback callback = m_Player.GetCommand_Action();
if (!callback)
{
callback = m_Player.GetCommandModifier_Action();
}
if( !callback )
{
HumanCommandWeapons hcw = m_Player.GetCommandModifier_Weapons();
if (hcw && !hcw.IsActionFinished())
return EAnimPlayState.FAILED;
HumanCommandAdditives ad = m_Player.GetCommandModifier_Additives();
if(ad)
{
//Print("------------------ Playing -----------------");
ad.StartModifier(m_AnimID);
m_IsPlaying = true;
return EAnimPlayState.OK;
}
}
return EAnimPlayState.FAILED;
}
override void Update(HumanMovementState movement_state)
{
if( m_IsPlaying )
{
HumanCommandAdditives ad = m_Player.GetCommandModifier_Additives();
if(!ad || !ad.IsModifierActive())
{
//Print("------------------ Not Playing -----------------");
m_Manager.OnAnimationFinished();
}
else
{
if(!m_CalledAnimStart)
{
m_Manager.OnAnimationStarted();
m_CalledAnimStart = true;
}
}
}
}
}
class HeatComfortmMetaADD extends SmptAnimMetaADD
{
override void Update(HumanMovementState movement_state)
{
//if( movement_state.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_WALK || movement_state.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_RUN || movement_state.m_iMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
if( movement_state.m_iMovement != DayZPlayerConstants.MOVEMENTIDX_IDLE || movement_state.IsInProne())
{
HumanCommandAdditives ad = m_Player.GetCommandModifier_Additives();
if(ad && ad.IsModifierActive())
{
ad.CancelModifier();
}
}
super.Update(movement_state);
}
} |