DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionTakeItem.c
См. документацию.
1/*class ActionTakeItemReciveData : ActionReciveData
2{
3 ref InventoryLocation m_InventoryLocation;
4}*/
5
7{
8 string m_ItemName = "";
9
11 {
12 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_INVENTORY;
13 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_PICKUP_INVENTORY;
14 m_Text = "#take";
15 }
16
22
23 override bool HasProneException()
24 {
25 return true;
26 }
27
28 override bool ActionConditionContinue( ActionData action_data )
29 {
30 return true;
31 }
32
33 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
34 {
35 ItemBase tgt_item = ItemBase.Cast( target.GetObject() );
36 if ( tgt_item && !tgt_item.IsTakeable() ) return false;
37 if ( tgt_item && tgt_item.IsBeingPlaced() ) return false;
38
39 EntityAI tgt_parent = EntityAI.Cast( target.GetParent() );
40 EntityAI tgt_entity = EntityAI.Cast( target.GetObject() );
41
42 if ( tgt_entity && (!tgt_parent || BaseBuildingBase.Cast(tgt_parent)) )
43 {
44 if ( tgt_entity && tgt_entity.IsItemBase() && player.GetInventory().CanAddEntityIntoInventory(tgt_entity) && tgt_entity.GetHierarchyRootPlayer() != player )
45 {
46 if ( tgt_parent && (!tgt_item.CanDetachAttachment(tgt_parent) || !tgt_parent.CanReleaseAttachment(tgt_item)) )
47 return false;
48
49 return true;
50 }
51 }
52 return false;
53 }
54
55 override bool CanBeUsedOnBack()
56 {
57 return true;
58 }
59
60 /*override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
61 {
62 super.WriteToContext(ctx, action_data);
63 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
64 il.WriteToContext(ctx);
65 }
66
67 override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data )
68 {
69 if(!action_recive_data)
70 {
71 action_recive_data = new ActionTakeItemReciveData;
72 }
73
74 if(super.ReadFromContext(ctx, action_recive_data))
75 {
76 ActionTakeItemReciveData recive_data_ti = ActionTakeItemReciveData.Cast(action_recive_data);
77 recive_data_ti.m_InventoryLocation = new InventoryLocation;
78 if(recive_data_ti.m_InventoryLocation.ReadFromContext(ctx))
79 {
80 return true;
81 }
82 }
83
84 return false;
85 }
86
87 override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
88 {
89 super.HandleReciveData(action_recive_data, action_data);
90 ActionTakeItemReciveData recive_data_ti = ActionTakeItemReciveData.Cast(action_recive_data);
91 action_data.m_ReservedInventoryLocations.Insert(recive_data_ti.m_InventoryLocation);
92 } */
93
94
95
96 override bool InventoryReservation(ActionData action_data)
97 {
98 bool success = true;
99
101
102 ItemBase targetItem;
103 if ( ItemBase.CastTo(targetItem, action_data.m_Target.GetObject()) )
104 {
105 action_data.m_Player.GetInventory().FindFreeLocationFor( targetItem , FindInventoryLocationType.ANY, il );
106 if ( action_data.m_Player.GetInventory().HasInventoryReservation( targetItem, il) )
107 {
108 success = false;
109 }
110 else
111 {
112 action_data.m_Player.GetInventory().AddInventoryReservationEx( targetItem, il, GameInventory.c_InventoryReservationTimeoutMS);
113 }
114 }
115
116 if ( success )
117 {
118 if( il )
119 action_data.m_ReservedInventoryLocations.Insert(il);
120 }
121
122 return success;
123 }
124
125 override void OnExecute(ActionData action_data)
126 {
127 if (GetGame().IsDedicatedServer())
128 {
129 ClearActionJuncture(action_data);
130 return;
131 }
132
133 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
134 ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
135 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
136 InventoryLocation targetInventoryLocation = new InventoryLocation;
137 ntarget.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
138
139 ClearInventoryReservationEx(action_data);
140
141 //SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
142
143 float stackable = ntarget.GetTargetQuantityMax(il.GetSlot());
144
145 if( stackable == 0 || stackable >= ntarget.GetQuantity() )
146 {
147 action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
148 }
149 else
150 {
151 ClearInventoryReservationEx(action_data);
152 ntarget.SplitIntoStackMaxToInventoryLocationClient( il );
153 }
154
155 //action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
156 }
157};
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 HasProneException()
Определения ActionTakeItem.c:23
void ActionTakeItem()
Определения ActionTakeItem.c:10
override void CreateConditionComponents()
Определения ActionTakeItem.c:17
override bool CanBeUsedOnBack()
Определения ActionTakeItem.c:55
string m_ItemName
Определения ActionTakeItem.c:8
override bool ActionConditionContinue(ActionData action_data)
Определения ActionTakeItem.c:28
override bool InventoryReservation(ActionData action_data)
Определения ActionTakeItem.c:96
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionTakeItem.c:33
override void OnExecute(ActionData action_data)
Определения ActionTakeItem.c:125
int m_CommandUID
Определения AnimatedActionBase.c:143
int m_CommandUIDProne
Определения AnimatedActionBase.c:144
Определения Fence.c:2
Определения CCINone.c:2
Определения CCTObject.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 CanDetachAttachment(EntityAI parent)
Определения GardenLime.c:42
override bool IsTakeable()
Определения BaseBuildingBase.c:988
Определения InventoryItem.c:731
Определения PlayerBaseClient.c:2
const float DEFAULT
Определения ActionConstants.c:112
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
proto native CGame GetGame()