DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionTakeHybridAttachment.c
См. документацию.
1
3{
4 string m_ItemName = "";
5
7 {
8 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_INVENTORY;
9 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_PICKUP_INVENTORY;
10 m_Text = "#take";
11 }
12
14 {
17 }
18
19 override bool HasProneException()
20 {
21 return true;
22 }
23
24 override bool ActionConditionContinue( ActionData action_data )
25 {
26 return true;
27 }
28
29 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
30 {
31 EntityAI tgt_entity = EntityAI.Cast( target.GetObject() );
32
33 if ( tgt_entity && BaseBuildingBase.Cast(tgt_entity) &&!tgt_entity.IsBeingPlaced() )
34 {
35 string component_name = tgt_entity.GetActionComponentName( target.GetComponentIndex() );
36
37 /*if (!tgt_entity.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString(component_name)))
38 return false;*/
39
40 ItemBase attachment = ItemBase.Cast(tgt_entity.FindAttachmentBySlotName(component_name));
41
42 if ( attachment && player.GetInventory().CanAddEntityIntoInventory(attachment) && attachment.IsTakeable() )
43 {
44 return true;
45 }
46 }
47 return false;
48 }
49
50 override bool CanBeUsedOnBack()
51 {
52 return true;
53 }
54
55 override bool InventoryReservation(ActionData action_data)
56 {
57 bool success = true;
58
60
61 EntityAI tgt_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
62 string component_name = tgt_entity.GetActionComponentName( action_data.m_Target.GetComponentIndex() );
63 ItemBase attachment;
64
65 if ( tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)) )
66 {
67 action_data.m_Player.GetInventory().FindFreeLocationFor( attachment , FindInventoryLocationType.ANY, il );
68 if ( action_data.m_Player.GetInventory().HasInventoryReservation( attachment, il) )
69 {
70 success = false;
71 }
72 else
73 {
74 action_data.m_Player.GetInventory().AddInventoryReservationEx( attachment, il, GameInventory.c_InventoryReservationTimeoutMS);
75 }
76 }
77
78 if ( success )
79 {
80 if( il )
81 action_data.m_ReservedInventoryLocations.Insert(il);
82 }
83
84 return success;
85 }
86
87 override void OnExecute( ActionData action_data )
88 {
89 if (GetGame().IsDedicatedServer())
90 {
91 ClearActionJuncture(action_data);
92 return;
93 }
94
95 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
96 EntityAI tgt_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
97 string component_name = tgt_entity.GetActionComponentName( action_data.m_Target.GetComponentIndex() );
98 ItemBase attachment;
99
100 if ( tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)) )
101 {
102 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
103 InventoryLocation targetInventoryLocation = new InventoryLocation;
104 attachment.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
105 ClearInventoryReservationEx(action_data);
106 //SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
107
108 float stackable = attachment.GetTargetQuantityMax(il.GetSlot());
109
110 if( stackable == 0 || stackable >= attachment.GetQuantity() )
111 {
112 action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
113 }
114 else
115 {
116 attachment.SplitIntoStackMaxToInventoryLocationClient( il );
117 }
118 }
119 //action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
120 }
121};
ActionBase ActionData
Определения ActionBase.c:30
class ActionTargets ActionTarget
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
void ClearActionJuncture(ActionData action_data)
Определения ActionBase.c:1083
string m_Text
Определения ActionBase.c:58
ref CCIBase m_ConditionItem
Определения ActionBase.c:64
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1025
ref CCTBase m_ConditionTarget
Определения ActionBase.c:65
void ActionInteractBase()
Определения ActionInteractBase.c:43
override bool CanBeUsedOnBack()
Определения ActionTakeHybridAttachment.c:50
override void CreateConditionComponents()
Определения ActionTakeHybridAttachment.c:13
override bool ActionConditionContinue(ActionData action_data)
Определения ActionTakeHybridAttachment.c:24
override bool HasProneException()
Определения ActionTakeHybridAttachment.c:19
override bool InventoryReservation(ActionData action_data)
Определения ActionTakeHybridAttachment.c:55
void ActionTakeHybridAttachment()
Определения ActionTakeHybridAttachment.c:6
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionTakeHybridAttachment.c:29
override void OnExecute(ActionData action_data)
Определения ActionTakeHybridAttachment.c:87
int m_CommandUID
Определения AnimatedActionBase.c:143
int m_CommandUIDProne
Определения AnimatedActionBase.c:144
Определения Fence.c:2
Определения CCINone.c:2
Определения CCTCursor.c:2
Определения Building.c:6
const int c_InventoryReservationTimeoutMS
reservations
Определения Inventory.c:712
script counterpart to engine's class Inventory
Определения Inventory.c:79
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation.
Определения InventoryLocation.c:29
override bool IsTakeable()
Определения BaseBuildingBase.c:988
Определения InventoryItem.c:731
Определения PlayerBaseClient.c:2
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
proto native CGame GetGame()