DayZ 1.24
Loading...
Searching...
No Matches
ActionRemoveSeed Class Reference
Inheritance diagram for ActionRemoveSeed:
[legend]
Collaboration diagram for ActionRemoveSeed:
[legend]

Private Member Functions

void ActionRemoveSeed ()
 
override GetInputType ()
 
override void CreateConditionComponents ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override bool InventoryReservation (ActionData action_data)
 
override void OnExecute (ActionData action_data)
 

Private Attributes

SeedBase m_Seed
 

Detailed Description

Definition at line 1 of file ActionRemoveSeed.c.

Constructor & Destructor Documentation

◆ ActionRemoveSeed()

void ActionRemoveSeed::ActionRemoveSeed ( )
inlineprivate

Definition at line 5 of file ActionRemoveSeed.c.

6 {
7 m_Text = "#take";
8 }
string m_Text
Definition ActionBase.c:49

References m_Text.

Member Function Documentation

◆ ActionCondition()

override bool ActionRemoveSeed::ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprivate

Definition at line 21 of file ActionRemoveSeed.c.

22 {
23 if (player.GetCommand_Vehicle())
24 return false;
25
27 if (Class.CastTo(garden_base, target.GetObject()))
28 {
29 Slot slot;
30
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() != 0)
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 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), and m_Seed.

◆ CreateConditionComponents()

override void ActionRemoveSeed::CreateConditionComponents ( )
inlineprivate

Definition at line 15 of file ActionRemoveSeed.c.

16 {
19 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
const float SMALL

References m_ConditionItem, m_ConditionTarget, and UAMaxDistances::SMALL.

◆ GetInputType()

override ActionRemoveSeed::GetInputType ( )
inlineprivate

Definition at line 10 of file ActionRemoveSeed.c.

◆ InventoryReservation()

override bool ActionRemoveSeed::InventoryReservation ( ActionData action_data)
inlineprivate

Definition at line 63 of file ActionRemoveSeed.c.

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 success = false;
74 else
75 action_data.m_Player.GetInventory().AddInventoryReservationEx(m_Seed, il, GameInventory.c_InventoryReservationTimeoutMS);
76 }
77
78 if (success)
79 {
80 if (il)
81 action_data.m_ReservedInventoryLocations.Insert(il);
82 }
83
84 return success;
85 }
FindInventoryLocationType
flags for searching locations in inventory
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
InventoryLocation.

References GameInventory::c_InventoryReservationTimeoutMS, and m_Seed.

◆ OnExecute()

override void ActionRemoveSeed::OnExecute ( ActionData action_data)
inlineprivate

Definition at line 87 of file ActionRemoveSeed.c.

88 {
89 if (GetGame().IsMultiplayer() && GetGame().IsServer())
90 return;
91
92 PlayerBase player = action_data.m_Player;
93 float stackable;
95
96 //We place in inventory
97 if (!player.GetInventory().CanAddEntityIntoHands(m_Seed))
98 {
99 il = action_data.m_ReservedInventoryLocations.Get(0);
101 m_Seed.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
102
103 stackable = m_Seed.GetTargetQuantityMax(il.GetSlot());
104
105 if (stackable == 0 || stackable >= m_Seed.GetQuantity())
106 player.PredictiveTakeToDst(targetInventoryLocation, il);
107 else
108 m_Seed.SplitIntoStackMaxToInventoryLocationClient(il);
109 }
110 else
111 {
112 //We place in hands
114
115 stackable = m_Seed.GetTargetQuantityMax(-1);
116
117 if (stackable == 0 || stackable >= m_Seed.GetQuantity())
118 action_data.m_Player.PredictiveTakeEntityToHands(m_Seed);
119 else
120 {
121 il = new InventoryLocation;
122 il.SetHands(action_data.m_Player, m_Seed);
123 m_Seed.SplitIntoStackMaxToInventoryLocationClient(il);
124 }
125 }
126 }
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
proto native CGame GetGame()

References ClearInventoryReservationEx(), GetGame(), and m_Seed.

Member Data Documentation

◆ m_Seed

SeedBase ActionRemoveSeed::m_Seed
private

Definition at line 3 of file ActionRemoveSeed.c.

Referenced by ActionCondition(), InventoryReservation(), and OnExecute().


The documentation for this class was generated from the following file: