DayZ 1.24
Loading...
Searching...
No Matches
ActionBuildPart.c
Go to the documentation of this file.
1class BuildPartActionReciveData : ActionReciveData
2{
3 string m_PartType;
4}
5
7{
8 string m_PartType;
9};
10
24
26{
28 {
30 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ASSEMBLE;
31 m_FullBody = true;
32 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
33
35 m_Text = "#build";
36 }
37
43
45 {
46 ConstructionActionData construction_action_data = player.GetConstructionActionData();
48
50 m_Text = "#build " + constrution_part.GetName();
51 }
52
53 override bool CanBeUsedLeaning()
54 {
55 return false;
56 }
57
58 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
59 {
60 if (player.IsPlacingLocal() || player.IsPlacingServer())
61 return false;
62
63 //Action not allowed if player has broken legs
64 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
65 return false;
66
67 //gate..
68 if (target.GetObject() && (!target.GetObject().CanUseConstructionBuild() || target.GetObject().CanUseHandConstruction()))
69 return false;
70
71 if ((!GetGame().IsDedicatedServer()))
72 {
73 if (MiscGameplayFunctions.ComplexBuildCollideCheckClient(player, target, item, m_VariantID))
74 return true;
75 return false;
76 }
77 return true;
78 }
79
81 {
83 Construction construction = base_building.GetConstruction();
84 string part_name = BuildPartActionData.Cast(action_data).m_PartType;
86
87 check_data.m_PartName = part_name;
88 check_data.m_AdditionalExcludes.Insert(action_data.m_Player);
89
90 bool canBuild = construction.CanBuildPart(part_name, action_data.m_MainItem, true);
91 if (GetGame().IsServer())
92 {
93 bool collides = construction.IsCollidingEx(check_data);
94
95 return !collides && canBuild;
96 }
97 else
98 return canBuild;
99 }
100
102 {
103 BaseBuildingBase base_building = BaseBuildingBase.Cast(action_data.m_Target.GetObject());
104 Construction construction = base_building.GetConstruction();
105
106 string part_name = BuildPartActionData.Cast(action_data).m_PartType;
108
109 check_data.m_PartName = part_name;
110 check_data.m_AdditionalExcludes.Insert(action_data.m_Player);
111
112 if (!construction.IsCollidingEx(check_data) && construction.CanBuildPart(part_name, action_data.m_MainItem, true)) //redundant at this point?
113 {
114 //build
115 construction.BuildPartServer(action_data.m_Player, part_name, AT_BUILD_PART);
116 //add damage to tool
117 action_data.m_MainItem.DecreaseHealth(UADamageApplied.BUILD, false);
118 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
119 }
120 }
121
123 {
124 return "Base_building";
125 }
126
132
133 //setup
135 {
136 if (super.SetupAction(player, target, item, action_data, extra_data))
137 {
139
140 if (!GetGame().IsDedicatedServer())
141 {
142 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
143 BuildPartActionData.Cast(action_data).m_PartType = construction_action_data.GetBuildPartAtIndex(m_VariantID).GetPartName();
144 }
145 return true;
146 }
147
148 return false;
149 }
150
152 {
153 switch (item.Type())
154 {
155 case Pickaxe:
156 case Shovel:
157 case FarmingHoe:
158 case FieldShovel:
159 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIG;
160 break;
161 case Pliers:
162 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
163 break;
164 case SledgeHammer:
165 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_MINEROCK;
166 break;
167 default:
168 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_ASSEMBLE;
169 break;
170 }
171 }
172
174 {
175 super.WriteToContext(ctx, action_data);
176
177 ctx.Write(BuildPartActionData.Cast(action_data).m_PartType);
178 }
179
181 {
183 super.ReadFromContext(ctx, action_recive_data);
184
185 string part_type;
186 if (ctx.Read(part_type))
187 {
189 return true;
190 }
191 else
192 return false;
193 }
194
201
203 {
204 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
205 string partName = BuildPartActionData.Cast(action_data).m_PartType;
206
207 string message = string.Format("Built %1 on %2 with %3", partName, action_data.m_Target.GetObject().GetDisplayName(), action_data.m_MainItem.GetDisplayName());
208 return message;
209 }
210}
211
213{
214 override typename GetInputType()
217 }
218
219 override bool UseMainItem()
220 {
221 return false;
222 }
223
224 override bool HasProgress()
225 {
226 return true;
227 }
228
230 {
231 return false;
233}
const int AT_BUILD_PART
Definition _constants.c:6
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
int m_VariantID
Definition ActionBase.c:59
GetInputType()
Definition ActionBase.c:181
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
bool UseMainItem()
Definition ActionBase.c:335
int m_StanceMask
Definition ActionBase.c:53
bool HasProgress()
For UI: hiding of progress bar.
Definition ActionBase.c:216
BuildPartActionReciveData m_PartType
override bool HasAlternativeInterrupt()
void CollisionCheckData()
void Construction(BaseBuildingBase parent)
eBrokenLegs
Definition EBrokenLegs.c:2
ActionData m_ActionData
float SetCallbackDuration(ItemBase item)
override void CreateActionComponent()
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
override bool CanBeUsedLeaning()
override void CreateConditionComponents()
override string GetSoundCategory(ActionData action_data)
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
void SetBuildingAnimation(ItemBase item)
override bool ActionConditionContinue(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override ActionData CreateActionData()
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override string GetAdminLogMessage(ActionData action_data)
override void OnFinishProgressServer(ActionData action_data)
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
ref CABase m_ActionComponent
Definition ActionBase.c:30
ItemBase m_MainItem
Definition ActionBase.c:28
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
const float BASEBUILDING_CONSTRUCT_MEDIUM
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()