DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionAttachOnProxy.c
См. документацию.
2{
4 {
5 m_Text = "#attach";
6 }
7
8 override void CreateConditionComponents()
9 {
12 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_ATTACHITEM;
13 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
14 }
15
16 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
17 {
18 if (!GetGame().IsDedicatedServer() && item)
19 m_Text = "#attach " + item.GetDisplayName();
20
21 EntityAI targetEntity = EntityAI.Cast(target.GetObject());
22 if (targetEntity)
23 {
24 if (CanAttachToProxy(player, targetEntity, item, target.GetComponentIndex()))
25 return true;
26 }
27
28 EntityAI targetParentEntity = EntityAI.Cast(target.GetParent());
29 if (targetParentEntity)
30 {
31 if (CanAttachToProxy(player, targetParentEntity, item, target.GetComponentIndex()))
32 return true;
33 }
34
35 return false;
36 }
37
38 protected bool CanAttachToProxy(PlayerBase player, EntityAI targetEntity, ItemBase item, int componentIndex = -1)
39 {
40 if (targetEntity && item)
41 {
42 GameInventory inventory = targetEntity.GetInventory();
44 if (inventory && inventory.CanAddAttachment(item) && inventory.FindFreeLocationFor(item, FindInventoryLocationType.ANY_CARGO | FindInventoryLocationType.ATTACHMENT, dst))
45 {
46 return true;
47 }
48 }
49
50 return false;
51 }
52
53 override void OnExecuteClient(ActionData action_data)
54 {
55 super.OnExecuteClient(action_data);
56
57 if (action_data.m_Player.IsPlacingLocal())
58 {
59 action_data.m_Player.TogglePlacingLocal();
60 }
61 }
62
63 override protected void AttachItem(AttachActionData action_data)
64 {
65 EntityAI targetEntity = EntityAI.Cast(action_data.m_Target.GetObject());
66 if (targetEntity && CanAttachToProxy(action_data.m_Player, targetEntity, action_data.m_MainItem, action_data.m_Target.GetComponentIndex()))
67 {
68 action_data.m_Player.PredictiveTakeEntityToTargetAttachmentEx(targetEntity, action_data.m_MainItem, action_data.m_AttSlot);
69 return;
70 }
71
72 EntityAI targetParentEntity = EntityAI.Cast(action_data.m_Target.GetParent());
73 if (targetParentEntity && CanAttachToProxy(action_data.m_Player, targetParentEntity, action_data.m_MainItem, action_data.m_Target.GetComponentIndex()))
74 {
75 action_data.m_Player.PredictiveTakeEntityToTargetAttachmentEx(targetParentEntity, action_data.m_MainItem, action_data.m_AttSlot);
76 }
77 }
78}
AttachActionData ActionData ActionAttach()
Определения ActionAttach.c:9
string m_Text
Определения ActionBase.c:57
ref CCIBase m_ConditionItem
Определения ActionBase.c:63
ref CCTBase m_ConditionTarget
Определения ActionBase.c:64
int m_StanceMask
Определения ActionBase.c:61
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionAttachOnProxy.c:16
void ActionAttachOnProxy()
Определения ActionAttachOnProxy.c:3
override void OnExecuteClient(ActionData action_data)
Определения ActionAttachOnProxy.c:53
void AttachItem(AttachActionData action_data)
Определения ActionAttachOnProxy.c:63
bool CanAttachToProxy(PlayerBase player, EntityAI targetEntity, ItemBase item, int componentIndex=-1)
Определения ActionAttachOnProxy.c:38
override void CreateConditionComponents()
Определения ActionAttachOnProxy.c:8
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionTarget m_Target
Определения ActionBase.c:39
ItemBase m_MainItem
Определения ActionBase.c:35
Определения ActionBase.c:22
int m_AttSlot
Определения ActionAttach.c:3
Определения ActionAttach.c:2
Определения CCINonRuined.c:2
Определения CCTCursor.c:2
proto native bool CanAddAttachment(notnull EntityAI e)
Check if attachment can be added to any slot.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
script counterpart to engine's class Inventory
InventoryLocation.
Определения InventoryLocation.c:30
Определения PlayerBaseClient.c:2
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
DayZGame GetGame()
Определения gameplay.c:636