DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionPartInfo.c
См. документацию.
2{
6
7 override void InitInfoData()
8 {
9 m_InfoData = new ActionInfoDataConstructionImpossible();
10 }
11
13 {
16 }
17
18 override bool CanBeStarted()
19 {
20 return false;
21 }
22
23 override bool IsLocal()
24 {
25 return true;
26 }
27
28 override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
29 {
30 ConstructionActionData cad = player.GetConstructionActionData();
32 if (part)
33 {
34 string overrideText = part.GetBuildTextOverride();
35 if (overrideText == string.Empty)
36 m_Text = "#build" + " " + part.GetName();
37 else
38 m_Text = overrideText;
39
40 #ifdef DIAG_DEVELOPER
41 if (DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_FULLDEBUG))
42 {
43 m_Text = "dbg " + "#build" + " " + part.GetName() + " | " + part.GetPartName();
44 }
45 #endif
46 }
47
48 }
49
50 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
51 {
52 EntityAI ent;
53 if (!Class.CastTo(ent,target.GetObject()))
54 return false;
55
56 if (player.IsPlacingLocal() || player.IsPlacingServer())
57 return false;
58
59 //Action not allowed if player has broken legs
60 if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
61 return false;
62
63 if (!ent.CanUseConstruction() || !ent.CanUseConstructionBuild())
64 return false;
65
66 if ((!GetGame().IsDedicatedServer()))
67 {
68 if (SimplifiedCollisionInfoCheck(player,target,item))
69 {
70 return GatherInfoData(player,target,item);
71 }
72 }
73
74 return false;
75 }
76
77 override bool ActionConditionContinue(ActionData action_data)
78 {
79 return false;
80 }
81
82 override protected bool GatherInfoData(PlayerBase player, ActionTarget target, ItemBase item)
83 {
85
86 EntityAI ent;
87 if (Class.CastTo(ent,target.GetObject()))
88 {
89 ActionInfoDataConstructionImpossible info = ActionInfoDataConstructionImpossible.Cast(m_InfoData);
90 ConstructionBase construction = ConstructionBase.Cast(ent.GetConstructionBasic());
91 ConstructionActionData cad = player.GetConstructionActionData();
93 construction.CanBuildPartEx(part.GetPartName(), item, info.m_InfoContextMask);
94 info.SetConstructionPart(part);
95 info.SetTool(item);
96
97 #ifdef DIAG_DEVELOPER
98 if (DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_FULLDEBUG) && info.m_InfoContextMask)
99 DbgPrint(construction, info, target.GetComponentIndex()); //print here for 'real' mask data..
100 #endif
101
102 info.m_InfoContextMask |= EConstructionInfoCategories.MATERIALS_PRESENCE; //material info should always be visible
103 info.m_InfoContextMask |= EConstructionInfoCategories.TOOL_PRESENCE; //tools info should always be visible
104
105 return info.CanDisplayInfo();
106 }
107
108 return false;
109 }
110
111 #ifdef DIAG_DEVELOPER
112 void DbgPrint(notnull ConstructionBase construction, ActionInfoDataConstructionBase info, int componentIdx)
113 {
114 int failureMask = info.m_InfoContextMask;
115 ConstructionPart part = info.GetConstructionPart();
116 string partName = part.GetPartName();
117
118 if (failureMask == 0)
119 {
120 ConstructionDebug.RemoveBuildPartInfoData(partName);
121 }
122 else
123 {
124 string conflictingPart;
125 if (failureMask & EConstructionInfoCategories.PART_CONFLICTED)
126 construction.HasConflictPart(partName, conflictingPart);
127
128 string missingSlot;
129 float missingQty;
130 if (failureMask & EConstructionInfoCategories.MATERIALS_PRESENCE)
131 construction.HasMaterialsEx(partName, false, missingSlot, missingQty);
132
133 ItemBase tool = info.GetTool();
134 string badToolType = "hands";
135 if ((failureMask & EConstructionInfoCategories.TOOL_PRESENCE) && tool)
136 badToolType = tool.GetType();
137
138 ActionInfoDebugData data = new ActionInfoDebugData();
139 data.partName = partName;
140 data.componentIdx = componentIdx;
141 data.failureMask = failureMask;
142 data.conflictingPart = conflictingPart;
143 data.missingSlot = missingSlot;
144 data.missingQty = missingQty;
145 data.badToolType = badToolType;
146
147 ConstructionDebug.AddBuildPartInfoData(data);
148 }
149 }
150 #endif
151
154 {
155 EntityAI ent = EntityAI.Cast(target.GetObject());
156 ConstructionActionData constructionActionData = player.GetConstructionActionData();
157 constructionActionData.SetTarget(ent);
158 ConstructionPart part = constructionActionData.GetBuildPartInfoAtIndex(m_VariantID);
159 ConstructionBase construction = ConstructionBase.Cast(ent.GetConstructionBasic());
160
161 if (!part)
162 {
163 ErrorEx("no part available!");
164 constructionActionData.GetBuildPartInfoAtIndex(m_VariantID);
165 }
166 else
167 {
168 BaseBuildingBase baseBuilding = BaseBuildingBase.Cast(ent);
169 if (baseBuilding && baseBuilding.MustBeBuiltFromOutside() && baseBuilding.IsPlayerInsideEx(player, part.GetMainPartName()))
170 return false;
171
172 if (!construction.ConstructionDirectionCheck(player, part, EConstructionDirCheckType.INDOORS))
173 return false;
174 if (!construction.ConstructionInsiderBoxCheck(player, part))
175 return false;
176 if (player.GetInputController().CameraIsFreeLook())
177 return false;
178
179 if (baseBuilding)
180 {
181 bool boo;
182 if (baseBuilding.PerformRoofCheckForBase(part.GetPartName(),player,boo) && boo)
183 return false;
184 }
185
186 if (player.IsPlacingLocal() || player.IsPlacingServer())
187 return false;
188
189 CollisionCheckData checkData = new CollisionCheckData();
190 checkData.m_PartName = part.GetPartName();
191
192 return !construction.IsCollidingEx(checkData);
193 }
194
195 return false;
196 }
197}
198
199// just a duplicate to allow displaying in interact category of target widget
200class ActionConstructionPartInfoInteract: ActionConstructionPartInfoContinuous
201{
202 override typename GetInputType()
205 }
206}
207///////////////////////////
208
210{
214 {
216 }
217
219 {
220 return true;
221 }
222}
225class ActionInfoDataConstructionBase: ActionInfoDataBase
226{
227 protected ItemBase m_Tool;
229
231 {
232 m_Part = part;
233 }
234
236 {
237 return m_Part;
238 }
239
240 void SetTool(ItemBase tool)
241 {
242 m_Tool = tool;
243 }
244
246 {
247 return m_Tool;
248 }
249}
252class ActionInfoDataConstructionPossible: ActionInfoDataConstructionBase
253{
254}
255
257class ActionInfoDataConstructionImpossible: ActionInfoDataConstructionBase
258{
259 override bool CanDisplayInfo()
260 {
261 bool forceHide = false;
262 forceHide |= m_InfoContextMask & EConstructionInfoCategories.PART_CONSTRUCTED;
263 forceHide |= m_InfoContextMask & EConstructionInfoCategories.PART_CONFLICTED;
264 forceHide |= m_InfoContextMask & EConstructionInfoCategories.PART_MISSING_REQUIREMENT;
265 forceHide |= m_InfoContextMask & EConstructionInfoCategories.PART_MISSING_SUPPORT;
266 bool show = true;
267 //show |= m_InfoContextMask & EConstructionInfoCategories.TOOL_PRESENCE;
268 //show |= m_InfoContextMask & EConstructionInfoCategories.MATERIALS_PRESENCE;
269
270 return super.CanDisplayInfo() && !forceHide && show;
271 }
272}
string m_Text
Определения ActionBase.c:57
ref ActionInfoDataBase m_InfoData
Определения ActionBase.c:70
int m_VariantID
Определения ActionBase.c:67
ref CCIBase m_ConditionItem
Определения ActionBase.c:63
ref CCTBase m_ConditionTarget
Определения ActionBase.c:64
void SetConstructionPart(ConstructionPart part)
Определения ActionPartInfo.c:230
ActionInfoDataConstructionPossible ActionInfoDataConstructionBase CanDisplayInfo()
visible only under specific conditions
Определения ActionPartInfo.c:259
ItemBase GetTool()
Определения ActionPartInfo.c:245
class ActionInfoDataBase m_Tool
not intended for direct use
void SetTool(ItemBase tool)
Определения ActionPartInfo.c:240
ConstructionPart GetConstructionPart()
Определения ActionPartInfo.c:235
ConstructionPart m_Part
Определения ActionPartInfo.c:228
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
void ConstructionBase(EntityAI parent)
Определения ConstructionBase.c:58
void CollisionCheckData()
Определения ConstructionBase.c:1923
EConstructionInfoCategories
Определения ConstructionConstants.c:2
eBrokenLegs
Определения EBrokenLegs.c:2
DiagMenuIDs
Определения EDiagMenuIDs.c:2
class GP5GasMask extends MaskBase ItemBase
Empty
Определения Hand_States.c:14
void ActionBuildPart()
Определения ActionBuildPart.c:35
void ClearInfoData()
Определения ActionBuildPart.c:312
void ActionConstructionPartInfoContinuous()
Определения ActionPartInfo.c:3
override void OnActionInfoUpdate(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionPartInfo.c:28
override void InitInfoData()
Определения ActionPartInfo.c:7
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionPartInfo.c:50
override bool ActionConditionContinue(ActionData action_data)
Определения ActionPartInfo.c:77
bool GatherInfoData(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionPartInfo.c:82
bool SimplifiedCollisionInfoCheck(PlayerBase player, ActionTarget target, ItemBase item)
'ComplexBuildCollideCheckClient' not suitable for this, due to missing context (looks into wrong vari...
Определения ActionPartInfo.c:153
override void CreateConditionComponents()
Определения ActionPartInfo.c:12
override bool IsLocal()
Определения ActionPartInfo.c:23
override bool CanBeStarted()
Определения ActionPartInfo.c:18
override GetInputType()
Определения ActionContinuousBase.c:179
Определения ActionBase.c:22
bool CanDisplayInfo()
Определения ActionPartInfo.c:218
void ActionInfoDataBase()
Определения ActionPartInfo.c:213
int m_InfoContextMask
Определения ActionPartInfo.c:211
always visible
Определения ActionPartInfo.c:253
override bool PerformRoofCheckForBase(string partName, PlayerBase player, out bool result)
Определения Watchtower.c:138
override bool MustBeBuiltFromOutside()
Определения ShelterSite.c:80
Определения Fence.c:2
Определения CCINone.c:2
Определения CCTCursor.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
ConstructionPart GetBuildPartInfoAtIndex(int idx)
Определения ConstructionActionData.c:373
void SetTarget(Object target)
Определения ConstructionActionData.c:111
string GetPartName()
Определения ConstructionPart.c:198
string GetBuildTextOverride()
Определения ConstructionPart.c:315
string GetName()
Определения ConstructionPart.c:193
string GetMainPartName()
Определения ConstructionPart.c:203
Instanced construction part data classes for dynamic data, statics now stored on EntityType level in ...
Определения ConstructionPart.c:4
Определения EnDebug.c:241
Определения PlayerBaseClient.c:2
DayZGame GetGame()
Определения gameplay.c:636
enum ShapeType ErrorEx
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.