DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ DismantleCondition()

bool ActionDismantlePart::DismantleCondition ( PlayerBase player,
ActionTarget target,
ItemBase item,
bool camera_check )
inlineprotected

См. определение в файле ActionDismantlePart.c строка 147

148 {
149 if (player && !player.IsPlacingLocal() && !player.IsPlacingServer())
150 {
151 EntityAI targetEntity;
152 if (Class.CastTo(targetEntity,target.GetObject()) && targetEntity.CanUseConstruction())
153 {
154 if (targetEntity.FindAttachmentBySlotName("Material_FPole_Flag"))
155 return false;
156
157 BaseBuildingBase baseBuilding = BaseBuildingBase.Cast(targetEntity);
158 ConstructionBase construction = ConstructionBase.Cast(targetEntity.GetConstructionBasic());
159 string partName;
160 ConstructionPart constructionPart;
161
162 array<string> compNames = new array<string>();
163 targetEntity.GetActionComponentNameList(target.GetComponentIndex(), compNames);
164 int count = compNames.Count();
165 for (int i = 0; i < count; ++i)
166 {
167 partName = compNames[i];
168 constructionPart = construction.GetConstructionPartToDismantle(partName, item);
169 if (constructionPart)
170 break;
171 }
172
173 if (constructionPart)
174 {
175 //invalid on gate if the gate is opened
176 if (baseBuilding && constructionPart.IsGate() && baseBuilding.IsOpened())
177 return false;
178
179 if (constructionPart.HasEssentialAttachmentSlots())
180 {
181 array<string> slots = constructionPart.GetEssentialAttachmentSlots();
182 foreach(string slotName: slots)
183 {
184 EntityAI attachment = targetEntity.FindAttachmentBySlotName(slotName);
185 if (attachment)
186 {
187 #ifdef DIAG_DEVELOPER
188 if (DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_FULLDEBUG))
189 {
190 DbgPrintFailure(constructionPart, "essential attachment " + attachment.GetType() + " attached in slot: " + slotName);
191 }
192 #endif
193 return false;
194 }
195 }
196 }
197
198 //camera and position checks
199 bool checked = false;
200
201 if (constructionPart.IsBase())
202 checked = true;
203
204 if (!checked && targetEntity.IsPlayerInsideEx(player, partName))
205 {
206 //Camera check (client-only)
207 if (camera_check)
208 {
209 if (g_Game && (!g_Game.IsDedicatedServer()))
210 {
211 if (targetEntity.IsFacingCamera(partName))
212 {
213 #ifdef DIAG_DEVELOPER
214 if (DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_FULLDEBUG))
215 {
216 DbgPrintFailure(constructionPart, "!IsFacingCamera");
217 }
218 #endif
219 return false;
220 }
221 }
222 }
223
224 checked = true;
225 }
226
227 //directional checks first
228 if (!construction.ConstructionDirectionCheck(player, constructionPart, EConstructionDirCheckType.INDOORS))
229 {
230 #ifdef DIAG_DEVELOPER
231 if (DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_FULLDEBUG))
232 {
233 DbgPrintFailure(constructionPart, "ConstructionDirectionCheck failing, type: EConstructionDirCheckType.INDOORS");
234 }
235 #endif
236 return false;
237 }
238
239 //Also checks for the reversible parts
240 if (constructionPart.IsReversible() && (constructionPart.IsReversedLocal() != construction.ConstructionDirectionCheck(player, constructionPart, EConstructionDirCheckType.REFERENCE_DIRECTION)))
241 {
242 #ifdef DIAG_DEVELOPER
243 if (DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_FULLDEBUG))
244 {
245 DbgPrintFailure(constructionPart, "ConstructionDirectionCheck failing, type: EConstructionDirCheckType.REFERENCE_DIRECTION");
246 }
247 #endif
248 return false;
249 }
250
251 if (!construction.ConstructionInsiderBoxCheck(player, constructionPart))
252 {
253 #ifdef DIAG_DEVELOPER
254 if (DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_FULLDEBUG))
255 {
256 DbgPrintFailure(constructionPart, "ConstructionInsiderBoxCheck failing");
257 //Debug.Draw
258 }
259 #endif
260 return false;
261 }
262
263 if (checked)
264 {
265 ConstructionActionData constructionActionData = player.GetConstructionActionData();
266 constructionActionData.SetTargetPart(constructionPart);
267
268 return true;
269 }
270 }
271 }
272 }
273
274 return false;
275 }
class LogManager EntityAI
void BaseBuildingBase()
Определения BaseBuildingBase.c:1326
PlayerSpawnPreset slotName
void ConstructionBase(EntityAI parent)
Определения ConstructionBase.c:58
void ConstructionPart(string name, string part_name, string main_part_name, int id, bool is_built, bool is_base, bool is_gate, array< string > required_parts)
Определения ConstructionPart.c:531
DayZGame g_Game
Определения DayZGame.c:4074
DiagMenuIDs
Определения EDiagMenuIDs.c:2
override bool IsOpened()
Определения Fence.c:122
void SetTargetPart(ConstructionPart target_part)
Определения ConstructionActionData.c:121
bool IsReversible()
Определения ConstructionPart.c:351
bool IsGate()
Определения ConstructionPart.c:278
bool HasEssentialAttachmentSlots()
Определения ConstructionPart.c:263
array< string > GetEssentialAttachmentSlots()
Определения ConstructionPart.c:305
bool IsBase()
Определения ConstructionPart.c:273
bool IsReversedLocal()
Определения ConstructionPart.c:356

Перекрестные ссылки ActionTarget(), Class::CastTo(), ConstructionBase(), g_Game, DiagMenu::GetBool(), ConstructionPart::GetEssentialAttachmentSlots(), ConstructionPart::HasEssentialAttachmentSlots(), ConstructionPart::IsBase(), ConstructionPart::IsGate(), BaseBuildingBase::IsOpened(), ConstructionPart::IsReversedLocal(), ConstructionPart::IsReversible(), ConstructionActionData::SetTargetPart() и slotName.

Используется в ActionCondition() и ActionConditionContinue().