14 class ActionReciveData
30 ref
CABase m_ActionComponent;
34 int m_PossibleStanceMask;
36 int m_RefreshReservationTimer;
37 int m_RefreshJunctureTimer;
39 bool m_WasActionStarted;
40 bool m_ReciveEndInput;
79 m_Text =
"default action text";
147 action_data.m_Action =
this;
148 action_data.m_Player = player;
149 action_data.m_Target = target;
150 action_data.m_MainItem = item;
154 action_data.m_WasExecuted =
false;
155 action_data.m_WasActionStarted =
false;
156 action_data.m_ReciveEndInput =
false;
158 ActionReciveData action_recive_data = player.GetActionManager().GetReciveData();
159 if ( action_recive_data )
165 if ( player.GetItemInHands() != action_data.m_MainItem )
185 for (
int i = 0; i < action_data.m_ReservedInventoryLocations.Count(); i++)
187 Debug.ActionLog(
InventoryLocation.DumpToStringNullSafe( action_data.m_ReservedInventoryLocations[i] ), action_data.m_Action.ToString() ,
"n/a",
"LockInventoryList", action_data.m_Player.ToString() );
369 return ActionCondition(action_data.m_Player,action_data.m_Target,action_data.m_MainItem);
386 int componentIndex = -1;
387 int proxyBoneIdx = -1;
392 Object targetObject =
null;
393 Object targetParent =
null;
397 ctx.Write(action_data.m_MainItem);
403 targetObject = action_data.m_Target.GetObject();
404 ctx.Write(targetObject);
405 targetParent = action_data.m_Target.GetParent();
406 ctx.Write(targetParent);
407 componentIndex = action_data.m_Target.GetComponentIndex();
408 ctx.Write(componentIndex);
409 cursorHitPos = action_data.m_Target.GetCursorHitPos();
410 ctx.Write(cursorHitPos);
416 Entity entParent =
Entity.Cast(action_data.m_Target.GetParent());
419 action_data.m_Target.GetObject().GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selectionNames);
420 for (
int s = 0; s < selectionNames.Count(); s++)
422 proxyBoneIdx = entParent.GetBoneIndex(selectionNames[s]);
423 if( proxyBoneIdx > -1 )
430 ctx.Write(proxyBoneIdx);
431 targetParent = action_data.m_Target.GetParent();
432 ctx.Write(targetParent);
433 componentIndex = action_data.m_Target.GetComponentIndex();
434 ctx.Write(componentIndex);
435 cursorHitPos = action_data.m_Target.GetCursorHitPos();
436 ctx.Write(cursorHitPos);
442 if ( !action_recive_data )
444 action_recive_data =
new ActionReciveData;
446 Object actionTargetObject =
null;
447 Object actionTargetParent =
null;
448 int componentIndex = -1;
449 int proxyBoneIdx = -1;
457 if ( !ctx.Read(mainItem) )
463 if ( !ctx.Read(actionTargetObject) )
466 if ( !ctx.Read(actionTargetParent))
469 if ( !ctx.Read(componentIndex) )
472 if ( !ctx.Read(cursorHitPos) )
475 target =
new ActionTarget(actionTargetObject, actionTargetParent, componentIndex, cursorHitPos, 0);
477 action_recive_data.m_Target = target;
481 if ( !ctx.Read(proxyBoneIdx) )
484 if ( !ctx.Read(actionTargetParent))
487 if ( !ctx.Read(componentIndex) )
490 if ( !ctx.Read(cursorHitPos) )
494 if ( proxyBoneIdx > -1 )
500 actionTargetObject = entParent.GetBoneObject(proxyBoneIdx);
508 target =
new ActionTarget(actionTargetObject, actionTargetParent, componentIndex, cursorHitPos, 0);
510 action_recive_data.m_Target = target;
513 action_recive_data.m_MainItem = mainItem;
519 action_data.m_MainItem = action_recive_data.m_MainItem;
523 if (action_recive_data.m_Target)
525 action_data.m_Target = action_recive_data.m_Target;
529 Error(
"Action target not created.");
576 Debug.ActionLog(
"Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(),
this.ToString() ,
"n/a",
"OnStart", action_data.m_Player.ToString() );
587 action_data.m_Player.SetSoundCategoryHash(soundCat.Hash());
599 if ( action_data.m_Player )
612 action_data.m_Player.GetActionManager().OnActionEnd();
626 action_data.m_ReciveEndInput =
true;
645 result = !target_player.IsJumpInProgress();
646 result = result && !(target_player.GetCommand_Ladder() || target_player.GetCommand_Vehicle() || target_player.GetCommand_Swim());
655 if ( player.GetCommand_Vehicle() )
660 if ( player.GetCommand_Ladder() )
665 if ( player.IsRestrained() )
670 if ( player.GetCommand_Swim() )
675 if ( player.IsRaised() )
680 if ( player.GetCommand_Move() && player.GetCommand_Move().IsOnBack() )
685 if ( player.GetThrowing().IsThrowingModeEnabled())
690 if (player.IsLeaning())
695 if (player.GetBrokenLegs() ==
eBrokenLegs.BROKEN_LEGS)
713 if ( entity && !target.GetObject().IsMan() )
715 Man man = entity.GetHierarchyRootPlayer();
716 if ( man && man != player )
734 if (stanceIdx != -1 && !
DayZPlayerUtils.PlayerCanChangeStance(player, stanceIdx ))
743 int condition_mask = ComputeConditionMask(player, target, item);
745 return Can( player, target, item, condition_mask);
818 if (
ItemBase.CastTo(targetItem,action_data.m_Target.GetObject()) )
821 targetItem.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
822 if ( action_data.m_Player.GetInventory().HasInventoryReservation( targetItem, targetInventoryLocation) )
828 action_data.m_Player.GetInventory().AddInventoryReservationEx( targetItem, targetInventoryLocation,
GameInventory.c_InventoryReservationTimeoutMS);
834 handInventoryLocation.SetHands(action_data.m_Player,action_data.m_Player.GetItemInHands());
836 if (action_data.m_Player.GetInventory().HasInventoryReservation( action_data.m_Player.GetItemInHands(), handInventoryLocation))
840 action_data.m_Player.GetInventory().ClearInventoryReservation(targetItem, targetInventoryLocation);
847 action_data.m_Player.GetInventory().AddInventoryReservationEx( action_data.m_Player.GetItemInHands(), handInventoryLocation,
GameInventory.c_InventoryReservationTimeoutMS);
852 if (targetInventoryLocation)
853 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
855 if (handInventoryLocation)
856 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
864 if (action_data.m_ReservedInventoryLocations)
867 for (
int i = 0; i < action_data.m_ReservedInventoryLocations.Count(); i++)
869 il = action_data.m_ReservedInventoryLocations.Get(i);
871 action_data.m_Player.GetInventory().ClearInventoryReservationEx( il.GetItem() , il );
874 action_data.m_ReservedInventoryLocations.Clear();
880 if (action_data.m_ReservedInventoryLocations)
883 for (
int i = 0; i < action_data.m_ReservedInventoryLocations.Count(); i++)
885 il = action_data.m_ReservedInventoryLocations.Get(i);
887 action_data.m_Player.GetInventory().ExtendInventoryReservationEx(il.GetItem() , il, 10000);
915 return target.GetObject() && target.GetObject().IsDamageDestroyed();
920 return target.GetObject() && target.GetObject().IsBuilding();
925 return target.GetObject() && target.GetObject().IsTransport();
930 Object obj = target.GetObject();
934 float distanceRoot, distanceHead;
935 vector modelPos, worldPos, playerHeadPos;
938 maxDistance = maxDistance * maxDistance;
941 MiscGameplayFunctions.GetHeadBonePos(player, playerHeadPos);
944 obj.GetActionComponentNameList(target.GetComponentIndex(), componentNames);
945 foreach (
string componentName : componentNames)
947 if (componentName.Contains(
"doorstwin"))
950 modelPos = obj.GetSelectionPositionMS(componentName);
951 worldPos = obj.ModelToWorld(modelPos);
956 distanceRoot =
vector.DistanceSq(worldPos, player.GetPosition());
957 distanceHead =
vector.DistanceSq(worldPos, playerHeadPos);
959 return distanceRoot <= maxDistance || distanceHead <= maxDistance;
968 if (
GetGame().IsServer() && player )
977 return GetGame().CreateSoundOnObject(player,
m_Sounds.Get(rand_num), 6,
false);
1000 if ( !
GetGame().IsDedicatedServer() )
1002 if (action_data.m_RefreshReservationTimer > 0)
1004 action_data.m_RefreshReservationTimer--;
1019 if (action_data.m_Player != NULL && action_data.m_Player.IsPlacingLocal() && !
IsDeploymentAction())
1020 action_data.m_Player.PlacingCancelLocal();
1058 return action_data.m_State;