File size: 7,804 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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
class TSelectableActionInfoArray extends array<ref TSelectableActionInfo>
{
bool IsSameAs(TSelectableActionInfoArray other)
{
if (this.Count() != other.Count())
{
return false;
}
for (int i = 0; i < Count(); ++i)
{
TSelectableActionInfo ai1 = this.Get(i);
TSelectableActionInfo ai2 = other.Get(i);
if (ai1.param2 != ai2.param2)
{
return false;
}
if (ai1.param3 != ai2.param3)
{
return false;
}
}
return true;
}
}
class ActionManagerBase
{
PlayerBase m_Player;
protected ActionTarget m_TestedActionTarget;
protected ItemBase m_TestedActionItem;
protected ActionBase m_PrimaryAction;
protected ActionTarget m_PrimaryActionTarget;
protected ItemBase m_PrimaryActionItem;
protected ActionBase m_SecondaryAction;
protected ActionTarget m_SecondaryActionTarget;
protected ItemBase m_SecondaryActionItem;
bool m_PrimaryActionEnabled;
bool m_SecondaryActionEnabled;
bool m_TertiaryActionEnabled;
ref TSelectableActionInfoArray m_SelectableActions;
int m_SelectedActionIndex;
bool m_SelectableActionsHasChanged;
bool m_Interrupted;
static ref array<ref ActionBase> m_ActionsArray;
static ref map<typename, ActionBase> m_ActionNameActionMap;
protected bool m_ActionWantEndRequest;
protected bool m_ActionInputWantEnd;
protected bool m_ActionsEnabled;
protected bool m_ActionsAvaibale;
//Pending actions waiting for acknowledgment
protected int m_PendingActionAcknowledgmentID;
protected ref ActionData m_CurrentActionData;
void ActionManagerBase(PlayerBase player)
{
m_Player = player;
if (m_Player)
{
m_SelectableActions = new TSelectableActionInfoArray();
m_SelectedActionIndex = 0;
m_SelectableActionsHasChanged = false;
m_PendingActionAcknowledgmentID = -1;
m_CurrentActionData = NULL;
m_Interrupted = false;
ActionConstructor ac = new ActionConstructor();
if (!m_ActionsArray)
{
ac.ConstructActions(m_ActionsArray, m_ActionNameActionMap);
}
m_ActionWantEndRequest = false;
m_ActionInputWantEnd = false;
}
m_ActionsEnabled = true;
m_ActionsAvaibale = true;
}
ActionBase GetRunningAction()
{
if (m_CurrentActionData)
return m_CurrentActionData.m_Action;
return null;
}
ItemBase GetRunningActionMainitem()
{
if (m_CurrentActionData)
return m_CurrentActionData.m_MainItem;
return null;
}
void EnableActions(bool enable)
{
m_ActionsEnabled = enable;
}
void Update(int pCurrentCommandID)
{
if (m_CurrentActionData)
{
if (m_Interrupted)
{
LocalInterrupt();
}
else if (m_CurrentActionData.m_State != UA_AM_PENDING && m_CurrentActionData.m_State != UA_AM_REJECTED && m_CurrentActionData.m_State != UA_AM_ACCEPTED)
{
m_CurrentActionData.m_Action.OnUpdate(m_CurrentActionData);
}
}
else if (m_Interrupted)
{
m_Interrupted = false;
}
}
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
{
int AcknowledgmentID;
switch (pJunctureID)
{
case DayZPlayerSyncJunctures.SJ_ACTION_ACK_ACCEPT:
pCtx.Read(AcknowledgmentID);
if (m_CurrentActionData && AcknowledgmentID == m_PendingActionAcknowledgmentID)
m_CurrentActionData.m_State = UA_AM_ACCEPTED;
break;
case DayZPlayerSyncJunctures.SJ_ACTION_ACK_REJECT:
pCtx.Read(AcknowledgmentID);
if (m_CurrentActionData && AcknowledgmentID == m_PendingActionAcknowledgmentID)
m_CurrentActionData.m_State = UA_AM_REJECTED;
break;
case DayZPlayerSyncJunctures.SJ_ACTION_INTERRUPT:
m_Interrupted = true;
break;
}
}
ActionTarget FindActionTarget();
void StartDeliveredAction();
static ActionBase GetActionVariant(typename actionName)
{
if (m_ActionNameActionMap)
{
ActionBase base_action = m_ActionNameActionMap.Get(actionName);
ActionBase new_action = ActionBase.Cast(actionName.Spawn());
new_action.CreateConditionComponents();
new_action.SetID(base_action.GetID());
new_action.SetInput(base_action.GetInput());
return new_action;
}
return null;
}
static ActionBase GetAction(typename actionName)
{
if (m_ActionNameActionMap)
return m_ActionNameActionMap.Get(actionName);
return null;
}
static ActionBase GetAction(int actionID)
{
return m_ActionsArray.Get(actionID);
}
ActionBase GetContinuousAction()
{
return m_PrimaryAction;
}
ActionBase GetSingleUseAction()
{
return m_SecondaryAction;
}
TSelectableActionInfoArray GetSelectableActions()
{
return m_SelectableActions;
}
int GetSelectedActionIndex()
{
return m_SelectedActionIndex;
}
typename GetSelectedActionCategory();
void SelectFirstActionCategory();
void SelectNextActionCategory();
void SelectPrevActionCategory();
void SelectNextAction();
void SelectPrevAction();
void RequestEndAction();
void EndActionInput();
bool IsSelectableActionsChanged()
{
return m_SelectableActionsHasChanged;
}
//------------------------------------------------------
bool ActionPossibilityCheck(int pCurrentCommandID)
{
if (!m_ActionsEnabled || m_Player.IsSprinting() || m_Player.IsUnconscious() || m_Player.GetCommandModifier_Action() || m_Player.GetCommand_Action() || m_Player.IsEmotePlaying() || m_Player.GetThrowing().IsThrowingAnimationPlaying() || m_Player.GetDayZPlayerInventory().IsProcessing() || m_Player.IsItemsToDelete())
return false;
if (m_Player.GetWeaponManager().IsRunning())
return false;
return (pCurrentCommandID == DayZPlayerConstants.COMMANDID_ACTION || pCurrentCommandID == DayZPlayerConstants.COMMANDID_MOVE || pCurrentCommandID == DayZPlayerConstants.COMMANDID_SWIM || pCurrentCommandID == DayZPlayerConstants.COMMANDID_LADDER || pCurrentCommandID == DayZPlayerConstants.COMMANDID_VEHICLE);
}
//------------------------------------------------------
protected void SetActionContext(ActionTarget target, ItemBase item)
{
m_TestedActionTarget = target;
m_TestedActionItem = item;
}
//------------------------------------------------------
int GetActionState(ActionBase action)
{
if (m_CurrentActionData)
{
return m_CurrentActionData.m_State;
}
return UA_NONE;
}
//---------------------------------
// EVENTS
//---------------------------------
void OnContinuousStart();
void OnContinuousCancel();
void OnSingleUse();
void Interrupt();
protected void LocalInterrupt()
{
if (m_CurrentActionData && m_CurrentActionData.m_Action)
m_CurrentActionData.m_Action.Interrupt(m_CurrentActionData);
else
m_Interrupted = false;
}
void OnInteractAction(); //Interact
void OnInstantAction(typename user_action_type, Param data = null);
void OnActionEnd()
{
if (LogManager.IsActionLogEnable())
{
if (m_CurrentActionData)
Debug.ActionLog("n/a", m_CurrentActionData.m_Action.ToString() , "n/a", "OnActionEnd", m_CurrentActionData.m_Player.ToString());
Debug.ActionLog("Action data cleared ", this.ToString() , "n/a", "ActionEnd", m_CurrentActionData.m_Player.ToString());
}
if (m_CurrentActionData)
m_CurrentActionData.m_Action.ActionCleanup(m_CurrentActionData);
m_CurrentActionData = NULL;
m_Player.ResetActionEndInput();
}
void OnJumpStart();
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
{
return false;
}
float GetActionComponentProgress()
{
if (m_CurrentActionData)
return m_CurrentActionData.m_Action.GetProgress(m_CurrentActionData);
return 0.0;
}
int GetActionState()
{
if (m_CurrentActionData)
return m_CurrentActionData.m_Action.GetState(m_CurrentActionData);
return UA_NONE;
}
ActionReciveData GetReciveData()
{
return null;
}
}
|