DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionRemoveSeed.c
См. документацию.
2{
4
6 {
7 m_Text = "#take";
8 }
9
10 override typename GetInputType()
11 {
13 }
14
20
21 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
22 {
23 if ( player.GetCommand_Vehicle() )
24 return false;
25
26 GardenBase garden_base;
27 if ( Class.CastTo( garden_base, target.GetObject() ) )
28 {
29 Slot slot;
30
31 array<string> selections = new array<string>;
32 garden_base.GetActionComponentNameList( target.GetComponentIndex(), selections );
33 string selection;
34
35 for (int s = 0; s < selections.Count(); s++)
36 {
37 selection = selections[s];
38 slot = garden_base.GetSlotBySelection( selection );
39 if ( slot )
40 break;
41 }
42
43 //Can only remove seed if slot is not watered to prevent VME
44 if ( slot && slot.GetSeed() )
45 {
46 if ( slot.GetWateredState() != eWateredState.DRY)
47 return false;
48
49 m_Seed = SeedBase.Cast( slot.GetSeed() );
50
51 if ( m_Seed )
52 {
53 if ( player.GetInventory().CanAddEntityIntoInventory( m_Seed ) && m_Seed.GetHierarchyRootPlayer() != player )
54 return true;
55 else
56 return player.GetInventory().CanAddEntityIntoHands( m_Seed );
57 }
58 }
59 }
60 return false;
61 }
62
63 override bool InventoryReservation(ActionData action_data)
64 {
65 bool success = true;
66
68
69 if ( m_Seed )
70 {
71 action_data.m_Player.GetInventory().FindFreeLocationFor( m_Seed , FindInventoryLocationType.ANY, il );
72 if ( action_data.m_Player.GetInventory().HasInventoryReservation( m_Seed, il ) )
73 {
74 success = false;
75 }
76 else
77 {
78 action_data.m_Player.GetInventory().AddInventoryReservationEx( m_Seed, il, GameInventory.c_InventoryReservationTimeoutMS );
79 }
80 }
81
82 if ( success )
83 {
84 if ( il )
85 action_data.m_ReservedInventoryLocations.Insert( il );
86 }
87
88 return success;
89 }
90
91 override void OnExecuteClient(ActionData action_data)
92 {
93 super.OnExecuteClient(action_data);
94
95 PlayerBase player = action_data.m_Player;
96 float stackable;
98
99 //We place in inventory
100 if ( !player.GetInventory().CanAddEntityIntoHands( m_Seed ) )
101 {
102 il = action_data.m_ReservedInventoryLocations.Get( 0 );
103 InventoryLocation targetInventoryLocation = new InventoryLocation;
104 m_Seed.GetInventory().GetCurrentInventoryLocation( targetInventoryLocation );
105
106 stackable = m_Seed.GetTargetQuantityMax( il.GetSlot() );
107
108 ClearInventoryReservationEx(action_data);
109 if ( stackable == 0 || stackable >= m_Seed.GetQuantity() )
110 {
111 player.PredictiveTakeToDst( targetInventoryLocation, il );
112 }
113 else
114 {
115 m_Seed.SplitIntoStackMaxToInventoryLocationClient( il );
116 }
117 }
118 else
119 {
120 //We place in hands
121 ClearInventoryReservationEx(action_data);
122 stackable = m_Seed.GetTargetQuantityMax( -1 );
123
124 if ( stackable == 0 || stackable >= m_Seed.GetQuantity() )
125 {
126 action_data.m_Player.PredictiveTakeEntityToHands( m_Seed );
127 }
128 else
129 {
130 il = new InventoryLocation;
131 il.SetHands( action_data.m_Player, m_Seed );
132 m_Seed.SplitIntoStackMaxToInventoryLocationClient( il );
133 }
134 }
135 }
136};
ActionBase ActionData
Определения ActionBase.c:30
class ActionTargets ActionTarget
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
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 GetInputType()
Определения ActionRemoveSeed.c:10
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionRemoveSeed.c:21
SeedBase m_Seed
Определения ActionRemoveSeed.c:3
override bool InventoryReservation(ActionData action_data)
Определения ActionRemoveSeed.c:63
void ActionRemoveSeed()
Определения ActionRemoveSeed.c:5
override void OnExecuteClient(ActionData action_data)
Определения ActionRemoveSeed.c:91
override void CreateConditionComponents()
Определения ActionRemoveSeed.c:15
Определения CCINone.c:2
Определения CCTCursor.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
const int c_InventoryReservationTimeoutMS
reservations
Определения Inventory.c:712
script counterpart to engine's class Inventory
Определения Inventory.c:79
Определения GardenPlot.c:2
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
Определения PlayerBaseClient.c:2
Определения cultivation.c:53
const float SMALL
Определения ActionConstants.c:111
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.