Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiontransferliquid.c
Go to the documentation of this file.
1 class TransferLiquidActionReciveData : ActionReciveData
2 {
3  bool m_TendencyRecived;
4 }
5 
6 class TransferLiquidActionData : ActionData
7 {
8  bool m_Tendency;
9 };
10 
12 {
13  private const float TIME_TO_REPEAT = 0.25;
14 
15  override void CreateActionComponent()
16  {
17  if (TransferLiquidActionData.Cast(m_ActionData))
18  m_ActionData.m_ActionComponent = new CAContinuousQuantityLiquidTransfer(UAQuantityConsumed.DRAIN_LIQUID, TIME_TO_REPEAT, TransferLiquidActionData.Cast(m_ActionData).m_Tendency);
19  else
20  m_ActionData.m_ActionComponent = new CAContinuousQuantityLiquidTransfer(UAQuantityConsumed.DRAIN_LIQUID, TIME_TO_REPEAT);
21  }
22 };
23 
25 {
27  {
28  m_CallbackClass = ActionTransferLiquidCB;
29  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_EMPTY_VESSEL;
30  m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_EMPTY_VESSEL;
32  }
33 
34  override void CreateConditionComponents()
35  {
38  }
39 
40  override bool HasProneException()
41  {
42  return true;
43  }
44 
45  override string GetText()
46  {
47  PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
48  if ( player.GetLiquidTendencyDrain() )
49  return "#drain_liquid";
50  else
51  return "#pour_liquid";
52  }
53 
54  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
55  {
56  ItemBase target_item = ItemBase.Cast(target.GetObject());
57 
58  if ( target_item && item )
59  {
60  bool can_drain = Liquid.CanTransfer(target_item,item);
61  bool can_pour = Liquid.CanTransfer(item,target_item);
62 
63  if (can_drain && can_pour)
64  {
65  return true;
66  }
67  else if (!can_pour && can_drain)
68  {
69  if ( (!GetGame().IsDedicatedServer()) && !player.GetLiquidTendencyDrain() )
70  {
71  player.SetLiquidTendencyDrain(true);
72  return false;
73  }
74  else
75  {
76  return true;
77  }
78  }
79  else if (!can_drain && can_pour)
80  {
81  if ( (!GetGame().IsDedicatedServer()) && player.GetLiquidTendencyDrain() )
82  {
83  player.SetLiquidTendencyDrain(false);
84  return false;
85  }
86  else
87  {
88  return true;
89  }
90  }
91  }
92  return false;
93  }
94 
95  override void OnStartClient( ActionData action_data )
96  {
97  TransferLiquidActionData.Cast(action_data).m_Tendency = action_data.m_Player.GetLiquidTendencyDrain();
98  }
99 
100  override void OnStartServer( ActionData action_data )
101  {
102  if (!GetGame().IsMultiplayer())
103  TransferLiquidActionData.Cast(action_data).m_Tendency = action_data.m_Player.GetLiquidTendencyDrain();
104  }
105 
106  override void OnFinishProgressServer( ActionData action_data )
107  {
108  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_SpecialtyWeight );
109  }
110 
111  override ActionData CreateActionData()
112  {
113  TransferLiquidActionData action_data = new TransferLiquidActionData;
114  return action_data;
115  }
116 
117  override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
118  {
119  super.WriteToContext(ctx, action_data);
120 
121  ctx.Write(action_data.m_Player.GetLiquidTendencyDrain());
122  }
123 
124  override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data )
125  {
126  if(!action_recive_data)
127  {
128  action_recive_data = new TransferLiquidActionReciveData;
129  }
130  TransferLiquidActionReciveData recive_data_transfer = TransferLiquidActionReciveData.Cast(action_recive_data);
131 
132  super.ReadFromContext(ctx, action_recive_data);
133 
134  bool tendency_drain;
135  if ( !ctx.Read(tendency_drain) )
136  return false;
137  recive_data_transfer.m_TendencyRecived = tendency_drain;
138  return true;
139  }
140 
141  override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
142  {
143  super.HandleReciveData(action_recive_data, action_data);
144 
145  TransferLiquidActionReciveData recive_data_transfer = TransferLiquidActionReciveData.Cast(action_recive_data);
146  TransferLiquidActionData.Cast(action_data).m_Tendency = recive_data_transfer.m_TendencyRecived;
147  }
148 
149  override void OnStartAnimationLoop( ActionData action_data )
150  {
151  if ( !GetGame().IsMultiplayer() || GetGame().IsServer() )
152  {
153  Bottle_Base vessel_in_hands = Bottle_Base.Cast( action_data.m_Target.GetObject() );
154  Param1<bool> play = new Param1<bool>( true );
155  if (TransferLiquidActionData.Cast(action_data))
156  {
157  if (TransferLiquidActionData.Cast(action_data).m_Tendency == true)
158  GetGame().RPCSingleParam( vessel_in_hands, SoundTypeBottle.EMPTYING, play, true );
159  else if (!TransferLiquidActionData.Cast(action_data).m_Tendency == false)
160  GetGame().RPCSingleParam( vessel_in_hands, SoundTypeBottle.POURING, play, true );
161  }
162  }
163  }
164 
165  override void OnEndAnimationLoop( ActionData action_data )
166  {
167  if ( !GetGame().IsMultiplayer() || GetGame().IsServer() )
168  {
169  Bottle_Base target_vessel = Bottle_Base.Cast( action_data.m_Target.GetObject());
170  Param1<bool> play = new Param1<bool>( false );
171  if (TransferLiquidActionData.Cast(action_data).m_Tendency)
172  GetGame().RPCSingleParam( target_vessel, SoundTypeBottle.EMPTYING, play, true );
173  else
174  GetGame().RPCSingleParam( target_vessel, SoundTypeBottle.POURING, play, true );
175  }
176  }
177 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
UASoftSkillsWeight
Definition: actionconstants.c:118
ActionTransferLiquidCB
Definition: actiontransferliquid.c:11
UAQuantityConsumed
Definition: actionconstants.c:3
TransferLiquidActionReciveData
Definition: actiontransferliquid.c:1
ActionTransferLiquid
Definition: actiontransferliquid.c:24
CAContinuousQuantityLiquidTransfer
Definition: cacontinuousquantityliquidtransfer.c:1
Bottle_Base
Definition: canistergasoline.c:1
UAMaxDistances
Definition: actionconstants.c:104
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
m_Tendency
TransferLiquidActionReciveData m_Tendency
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
TIME_TO_REPEAT
const private float TIME_TO_REPEAT
Definition: actionextinguishfireplacebyextinguisher.c:2
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CCTNonRuined
Definition: cctnonruined.c:1
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
SoundTypeBottle
SoundTypeBottle
Definition: bottle_base.c:1
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
Liquid
Definition: liquid.c:1
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68