Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionwritepaper.c
Go to the documentation of this file.
2 {
3  override void CreateActionComponent()
4  {
6  m_ActionData.m_ActionComponent = new CAContinuousTime(-1.0);
7  }
8 
9  override void EndActionComponent()
10  {
11  }
12 
13  override void OnStateChange(int pOldState, int pCurrentState)
14  {
15  if (pCurrentState == STATE_NONE && (!GetGame().IsDedicatedServer()))
16  {
17  if (GetGame().GetUIManager() && GetGame().GetUIManager().IsMenuOpen(MENU_NOTE))
18  GetGame().GetUIManager().FindMenu(MENU_NOTE).Close();
19  }
20  else if (pCurrentState == STATE_LOOP_LOOP && pOldState != STATE_LOOP_LOOP && (!GetGame().IsMultiplayer() || GetGame().IsServer()))
21  {
22  ItemBase paper_item;
23  if (m_ActionData.m_MainItem.ConfigIsExisting("writingColor"))
24  {
25  paper_item = ItemBase.Cast(m_ActionData.m_Target.GetObject());
26  }
27  else
28  {
29  paper_item = ItemBase.Cast(m_ActionData.m_MainItem);
30  }
31  Param1<string> text = new Param1<string>(paper_item.GetWrittenNoteData().GetNoteText());
32  paper_item.RPCSingleParam(ERPCs.RPC_WRITE_NOTE, text, true,m_ActionData.m_Player.GetIdentity());
33  }
34  }
35 };
36 
38 {
39  const float TARGET_DISTANCE = 2;
40 
41  void ActionWritePaper()
42  {
43  m_CallbackClass = ActionWritePaperCB;
44  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_VIEWNOTE;
45  m_FullBody = true;
46  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_PRONE;
47  m_Text = "#write_note";
48  }
49 
50  override void CreateConditionComponents()
51  {
53  m_ConditionTarget = new CCTNone;//CCTNonRuined(TARGET_DISTANCE);
54  }
55 
56  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
57  {
58  if ((item && item.ConfigIsExisting("writingColor") && target.GetObject() && Paper.Cast(target.GetObject())) || (target.GetObject() && target.GetObject().ConfigIsExisting("writingColor") && item && Paper.Cast(item)))
59  {
60  return true;
61  }
62  return false;
63  }
64 
65  override void OnStartClient( ActionData action_data )
66  {
67  if (action_data.m_Target.GetObject().ConfigIsExisting("writingColor"))
68  {
69  action_data.m_MainItem.GetWrittenNoteData().InitNoteInfo(ItemBase.Cast(action_data.m_Target.GetObject()),action_data.m_MainItem);
70  }
71  else
72  {
73  ItemBase.Cast(action_data.m_Target.GetObject()).GetWrittenNoteData().InitNoteInfo(action_data.m_MainItem,ItemBase.Cast(action_data.m_Target.GetObject()));
74  }
75  }
76 
77  override void OnStartServer( ActionData action_data )
78  {
79  if (action_data.m_Target.GetObject().ConfigIsExisting("writingColor"))
80  {
81  action_data.m_MainItem.GetWrittenNoteData().InitNoteInfo(ItemBase.Cast(action_data.m_Target.GetObject()),action_data.m_MainItem);
82  }
83  else
84  {
85  ItemBase.Cast(action_data.m_Target.GetObject()).GetWrittenNoteData().InitNoteInfo(action_data.m_MainItem,ItemBase.Cast(action_data.m_Target.GetObject()));
86  }
87  }
88 
89  override void OnUpdate(ActionData action_data)
90  {
91  super.OnUpdate(action_data);
92 
93  if(!GetGame().IsDedicatedServer())
94  {
95  if (action_data.m_State == UA_FINISHED && GetGame().GetUIManager() && !GetGame().GetUIManager().IsMenuOpen(MENU_NOTE))
96  {
97  ActionManagerClient.Cast(action_data.m_Player.GetActionManager()).RequestEndAction();
98  }
99  }
100  }
101 
102  override void OnEndRequest(ActionData action_data)
103  {
104  if (action_data.m_Callback)
105  {
106  action_data.m_Callback.InternalCommand(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
107  }
108  }
109 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ActionWritePaperCB
Definition: actionwritepaper.c:1
CAContinuousTime
Definition: cacontinuoustime.c:1
EnableStateChangeCallback
proto native void EnableStateChangeCallback()
enables state change callback OnStateChange
CCTNone
Definition: cctnone.c:1
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
PlayerBase
Definition: playerbaseclient.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
ActionContinuousBaseCB
Definition: actioncontinuousbase.c:1
ActionManagerClient
Definition: actionmanagerclient.c:4
ActionWritePaper
Definition: actionwritepaper.c:37
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ERPCs
ERPCs
Definition: erpcs.c:1
ActionContinuousBase
Definition: actioncontinuousbase.c:132
CCINonRuined
Definition: ccinonruined.c:1
MENU_NOTE
const int MENU_NOTE
Definition: constants.c:180
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53