Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CampaignBuildingDisassemblyUserAction.c
Go to the documentation of this file.
2{
3 protected SCR_CampaignBuildingLayoutComponent m_LayoutComponent;
4 protected SCR_CampaignBuildingCompositionComponent m_CompositionComponent;
7 protected FactionAffiliationComponent m_FactionComponent;
8 protected SCR_MilitaryBaseComponent m_BaseComponent;
9 protected ref array<SCR_EditableVehicleComponent> m_EditableVehicle = {};
10 protected SCR_CampaignBuildingProviderComponent m_MasterProviderComponent;
11 protected bool m_bCompositionSpawned;
12 protected bool m_bTurretCollected;
14 protected IEntity m_User;
15 protected bool m_bDisassembleOnlyWhenCapturing = false;
16 protected bool m_bSameFactionDisassembleOnly = false;
18 protected bool m_bAccessCanBeBlocked;
20 protected RplComponent m_RplComponent;
22
24
25 protected const string DISMANTLE_ALL_BUILDINGS = "#AR-FactionCommander_DismantleAllBuildings";
26 protected const string IN_USE = "#AR-UserAction_Blocked_InUseByOther";
27 protected const string OCCUPIED = "#AR-UserAction_SeatOccupied";
28 protected const string ENEMY_PRESENCE = "#AR-Campaign_Action_ShowBuildPreviewEnemyPresence";
29 protected const int TEMPORARY_BLOCKED_ACCESS_RESET_TIME = 2;
30 protected const int ALLOWED_PLAYER_DISTANCE_SQ = 10000;
31
32 //------------------------------------------------------------------------------------------------
33 protected override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
34 {
35 m_RootEntity = pOwnerEntity.GetRootParent();
36
37 m_CompositionComponent = SCR_CampaignBuildingCompositionComponent.Cast(m_RootEntity.FindComponent(SCR_CampaignBuildingCompositionComponent));
39 m_LayoutComponent = SCR_CampaignBuildingLayoutComponent.Cast(pOwnerEntity.FindComponent(SCR_CampaignBuildingLayoutComponent));
40 m_RplComponent = RplComponent.Cast(pOwnerEntity.FindComponent(RplComponent));
41
44
45 if (m_CompositionComponent && GetOwner() == GetOwner().GetRootParent())
46 {
47 m_CompositionComponent.GetOnCompositionSpawned().Insert(OnCompositionSpawned);
48
49 BaseGameMode gameMode = GetGame().GetGameMode();
50 if (!gameMode)
51 return;
52
53 SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(gameMode.FindComponent(SCR_CampaignBuildingManagerComponent));
54 if (!buildingManagerComponent)
55 return;
56
57 m_bSameFactionDisassembleOnly = buildingManagerComponent.CanDisassembleSameFactionOnly();
58 m_bDisassembleOnlyWhenCapturing = buildingManagerComponent.CanDisassembleOnlyWhenCapturing();
59
62 }
63 }
64
65 //------------------------------------------------------------------------------------------------
66 override void OnActionStart(IEntity pUserEntity)
67 {
68 ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
69 if (!character)
70 return;
71
72 m_User = pUserEntity;
74 if (!SCR_CharacterHelper.IsPlayerOrAIOwner(character))
75 return;
76
77 CharacterControllerComponent charController = character.GetCharacterController();
78 if (charController)
79 {
80 CharacterAnimationComponent pAnimationComponent = charController.GetAnimationComponent();
81 int itemActionId = pAnimationComponent.BindCommand("CMD_Item_Action");
82
84 params.SetEntity(GetBuildingTool(pUserEntity));
85 params.SetAllowMovementDuringAction(false);
86 params.SetKeepInHandAfterSuccess(true);
87 params.SetCommandID(itemActionId);
88 params.SetCommandIntArg(2);
89
90 charController.TryUseItemOverrideParams(params);
91 }
92
93 super.OnActionStart(pUserEntity);
94 }
95
96 //------------------------------------------------------------------------------------------------
97 override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
98 {
99 m_User = null;
101
102 ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
103 if (!character)
104 return;
105
106 if (!SCR_CharacterHelper.IsPlayerOrAIOwner(character))
107 return;
108
109 CancelPlayerAnimation(character); // when player stops holding use action button
110 }
111
112 //------------------------------------------------------------------------------------------------
116 protected void ToggleCompartmentAccess(notnull IEntity object, IEntity blockingUser = null)
117 {
118 Turret turret = Turret.Cast(object);
119 if (turret)
120 {
121 SCR_BaseCompartmentManagerComponent compartmentMgr = SCR_BaseCompartmentManagerComponent.Cast(turret.FindComponent(SCR_BaseCompartmentManagerComponent));
122 if (!compartmentMgr)
123 return;
124
125 array<BaseCompartmentSlot> outCompartments = {};
126 if (compartmentMgr.GetCompartments(outCompartments) < 1)
127 return;
128
129 foreach (BaseCompartmentSlot compartment : outCompartments)
130 {
131 compartment.SetReserved(blockingUser);
132 }
133
134 return;
135 }
136
137 IEntity child = object.GetChildren();
138 while (child)
139 {
140 ToggleCompartmentAccess(child, blockingUser);
141 child = child.GetSibling();
142 }
143 }
144
145 //------------------------------------------------------------------------------------------------
146 protected void CancelPlayerAnimation(notnull IEntity entity)
147 {
148 ChimeraCharacter character = ChimeraCharacter.Cast(entity);
149 if (!character)
150 return;
151
152 CharacterControllerComponent charController = character.GetCharacterController();
153 if (!charController)
154 return;
155
156 CharacterAnimationComponent pAnimationComponent = charController.GetAnimationComponent();
157 CharacterCommandHandlerComponent cmdHandler = pAnimationComponent.GetCommandHandler();
158 cmdHandler.FinishItemUse(true);
159 }
160
161 //------------------------------------------------------------------------------------------------
162 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
163 {
165 return;
166
167 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(pUserEntity);
168 if (!character)
169 return;
170
171 CancelPlayerAnimation(character); // if player finished the action, then lets not wait for it to do all the RPCing, and end the animation now
172
173 SCR_CampaignBuildingCompositionComponent buildingComponent = SCR_CampaignBuildingCompositionComponent.Cast(pOwnerEntity.FindComponent(SCR_CampaignBuildingCompositionComponent));
174 if (buildingComponent)
175 {
176 if (!System.IsConsoleApp())
177 buildingComponent.SetCanPlaySoundOnDeletion(true);
178 }
179 else if (!pOwnerEntity.FindComponent(SCR_CampaignBuildingLayoutComponent))
180 {
181 // Not buildable composition
182 return;
183 }
184
185 if (m_RplComponent.IsProxy())
186 return;
187
188 if (character.GetCharacterController().GetLifeState() != ECharacterLifeState.ALIVE)
189 return;
190
191 PlayerManager playerMgr = GetGame().GetPlayerManager();
192 int playerId = playerMgr.GetPlayerIdFromControlledEntity(character);
193 if (!playerMgr.IsPlayerConnected(playerId))
194 return;
195
196 if (vector.DistanceSqXZ(m_RootEntity.GetOrigin(), character.GetOrigin()) > ALLOWED_PLAYER_DISTANCE_SQ)
197 return;
198
200 TryToSendNotification(pOwnerEntity, character);
201
202 PrintFormat("Player %1 dismantled composition %2", SCR_PlayerIdentityUtils.GetPlayerLogInfo(playerId), m_RootEntity, level:LogLevel.DEBUG);
203
205 if (IsHQService())
206 {
207 if (CanBaseBeDisassembled(character))
208 base = GetBase();
209 else
210 return;
211 }
212
214
215 // deleting base if it is possible
216 if (base)
217 DeleteBase(base, playerId);
218 }
219
220 //------------------------------------------------------------------------------------------------
221 protected void DeleteComposition(notnull IEntity composition, notnull SCR_ChimeraCharacter character)
222 {
223 SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(composition.GetRootParent().FindComponent(SCR_EditableEntityComponent));
224 if (editableEntity)
225 {
226 editableEntity.Delete(true, true);
227 }
228 else
229 {
230 SCR_AIWorld aiWorld = SCR_AIWorld.Cast(GetGame().GetAIWorld());
231 if (aiWorld)
232 {
233 array<ref Tuple2<vector, vector>> areas = {}; // min, max
234 array<bool> redoAreas = {};
235 aiWorld.GetNavmeshRebuildAreas(composition.GetRootParent(), areas, redoAreas);
236 GetGame().GetCallqueue().CallLater(aiWorld.RequestNavmeshRebuildAreas, 1000, false, areas, redoAreas); //--- Called *before* the entity is deleted with a delay, ensures the regeneration doesn't accidentaly get anything from the entity prior to full destruction
237 }
238
239 RplComponent.DeleteRplEntity(composition, false);
240 }
241 }
242
243 //------------------------------------------------------------------------------------------------
244 protected void DeleteBase(notnull SCR_CampaignMilitaryBaseComponent base, int userPlayerId)
245 {
246 Faction playerFaction = SCR_FactionManager.SGetPlayerFaction(userPlayerId);
247 if (!playerFaction)
248 return;
249
250 // check if is exists dismantle task on this base for player faction
251 SCR_DismantleCampaignMilitaryBaseTaskEntity task = SCR_DismantleCampaignMilitaryBaseTaskEntity.Cast(SCR_CampaignTaskHelper.GetTaskOnBase(base, playerFaction, SCR_DismantleCampaignMilitaryBaseTaskEntity));
252 if (!task)
253 return;
254
255 // check if the player is assigned to task
256 if (!task.IsTaskAssignedTo(SCR_TaskExecutor.FromPlayerID(userPlayerId)))
257 return;
258
259 PrintFormat("Base:%1 was dismantled by playerId:%2", base.GetBaseNameUpperCase(), userPlayerId, level:LogLevel.DEBUG);
260
261 RplComponent.DeleteRplEntity(base.GetOwner(), false);
262 }
263
264 //------------------------------------------------------------------------------------------------
265 protected void TryToSendNotification(notnull IEntity pOwnerEntity, notnull SCR_ChimeraCharacter disassemblingCharacter)
266 {
268 return;
269
270 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(disassemblingCharacter);
271
272 IEntity provider = m_CompositionComponent.GetProviderEntity();
273 if (!provider)
274 return;
275
276 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.FindComponent(SCR_CampaignBuildingProviderComponent));
277 if (!providerComponent)
278 return;
279
280 array<SCR_MilitaryBaseComponent> bases = {};
281 providerComponent.GetBases(bases);
282 if (bases.IsEmpty())
283 return;
284
285 SCR_MilitaryBaseComponent base = bases[0];
286 int callsign = base.GetCallsign();
287 if (callsign == SCR_MilitaryBaseComponent.INVALID_BASE_CALLSIGN)
288 return;
289
290 Faction baseFaction = base.GetFaction();
291 SCR_Faction characterFaction = SCR_Faction.Cast(disassemblingCharacter.GetFaction());
292 if (characterFaction != baseFaction)
293 return;
294
295 RplComponent rplComponent = RplComponent.Cast(m_EditableEntity.GetOwner().FindComponent(RplComponent));
296 if (!rplComponent)
297 return;
298
299 SCR_NotificationsComponent.SendToFaction(characterFaction, true, ENotification.EDITOR_SERVICE_DISASSEMBLED, playerId, rplComponent.Id(), callsign);
300 }
301
302 //------------------------------------------------------------------------------------------------
303 // Check if the editable entity component has a specific label.
305 {
306 if (!m_EditableEntity)
307 return false;
308
309 SCR_EditableEntityUIInfo editableEntityUIInfo = SCR_EditableEntityUIInfo.Cast(m_EditableEntity.GetInfo());
310 return editableEntityUIInfo && editableEntityUIInfo.HasEntityLabel(label);
311 }
312
313 //------------------------------------------------------------------------------------------------
314 // The user action is shown when the preview is visible - means player has a building tool.
315 override bool CanBeShownScript(IEntity user)
316 {
317 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(user);
318 if (!character)
319 return false;
320
322 return false;
323
324 if (!m_GadgetManager)
325 {
327
329 if (playerController)
330 playerController.m_OnControlledEntityChanged.Insert(SetNewGadgetManager);
331
332 return false;
333 }
334
335 if (!SCR_CampaignBuildingGadgetToolComponent.Cast(m_GadgetManager.GetHeldGadgetComponent()))
336 return false;
337
338 if (!CanBeDisassembled())
339 return false;
340
341 // checks only if it is HQ service
342 if (IsHQService() && !CanBaseBeDisassembled(character))
343 return false;
344
345 // The user action is on entity with composition component, show it if the composition is spawned.
346 if (GetOwner() == GetOwner().GetRootParent())
348
349 if (m_BuildAction && !m_BuildAction.IsShown())
350 return false;
351
352 return m_LayoutComponent;
353 }
354
355 //------------------------------------------------------------------------------------------------
356 override bool GetActionNameScript(out string outName)
357 {
358 if (!m_EditableEntity)
359 return false;
360
361 SCR_UIInfo uiInfo = m_EditableEntity.GetInfo();
362 if (!uiInfo)
363 return false;
364
365 UIInfo actionUiInfo = GetUIInfo();
366 if (!actionUiInfo)
367 return false;
368
369 outName = WidgetManager.Translate(actionUiInfo.GetDescription(), uiInfo.GetName());
370 return true;
371 }
372
373 //------------------------------------------------------------------------------------------------
379
380 //------------------------------------------------------------------------------------------------
381 override bool CanBePerformedScript(IEntity user)
382 {
383 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(user);
384 if (!character)
385 return false;
386
387 if (m_User && m_User != character)
388 {
390 return false;
391 }
392
393 SCR_Faction scriptedFaction = SCR_Faction.Cast(character.GetFaction());
394 if (scriptedFaction)
395 {
396 SCR_ECharacterRank playerRank = SCR_CharacterRankComponent.GetCharacterRank(user);
397
398 if (scriptedFaction.GetRanks().IsRankRenegade(playerRank))
399 {
400 SetCannotPerformReason(SCR_CharacterRankComponent.GetRankName(user, playerRank));
401 return false;
402 }
403 }
404
406 {
407 m_bTurretCollected = true;
409 }
410
411 // If the editor manager doesn't exists, try to get one and set as for an example when connecting to a server with build compositions, the editor manager doesn't exist when the user action inicialized.
412 if (!m_EditorManager)
414
415 if (!m_EditorManager || m_EditorManager.IsOpened())
416 return false;
417
419 {
420 BaseCompartmentManagerComponent comaprtmentMgrComp;
421 array<BaseCompartmentSlot> outCompartments = {};
422 foreach (SCR_EditableVehicleComponent editableVehicle : m_EditableVehicle)
423 {
424 if (!editableVehicle)
425 continue;
426
427 comaprtmentMgrComp = BaseCompartmentManagerComponent.Cast(editableVehicle.GetOwner().FindComponent(BaseCompartmentManagerComponent));
428 if (!comaprtmentMgrComp)
429 continue;
430
431 outCompartments.Clear();
432 comaprtmentMgrComp.GetCompartments(outCompartments);
433 foreach (BaseCompartmentSlot compartment : outCompartments)
434 {
435 if (!compartment.IsOccupied())
436 continue;
437
439 return false;
440 }
441 }
442 }
443
444
445 if (IsHQService())
446 {
447 if (CanBaseBeDisassembled(character))
448 {
450 {
452
453 return false;
454 }
455 }
456 else
457 {
458 return false;
459 }
460 }
461
463 {
465
467 {
469 return false;
470 }
471 }
472
474 return true;
475
476 if (!m_BaseComponent)
477 {
479 return false;
480
481 IEntity provider = m_CompositionComponent.GetProviderEntity();
482 if (!provider)
483 return false;
484
485 SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(provider.FindComponent(SCR_CampaignBuildingProviderComponent));
486 if (!providerComponent)
487 return false;
488
489 array<SCR_MilitaryBaseComponent> bases = {};
490 providerComponent.GetBases(bases);
491 if (bases.IsEmpty())
492 return false;
493
494 m_BaseComponent = bases[0];
495 }
496
497 Faction playerFaction = character.GetFaction();
498
499 return playerFaction && playerFaction == m_BaseComponent.GetCapturingFaction();
500 }
501
502 //------------------------------------------------------------------------------------------------
504 protected void GetBuildingAction()
505 {
507 if (!baseActionManager)
508 return;
509
510 array<BaseUserAction> actions = {};
511 baseActionManager.GetActionsList(actions);
512
513 foreach (BaseUserAction action : actions)
514 {
516 if (m_BuildAction)
517 break;
518 }
519 }
520
521 //------------------------------------------------------------------------------------------------
522 protected void SetEditorManager()
523 {
525 if (!core)
526 return;
527
529 }
530
531 //------------------------------------------------------------------------------------------------
533 protected void GetAllTurretsInComposition(IEntity object)
534 {
535 if (!m_EditableEntity)
536 return;
537
538 m_bTurretCollected = true;
539 set<SCR_EditableEntityComponent> editableEntities = new set<SCR_EditableEntityComponent>();
540 m_EditableEntity.GetChildren(editableEntities);
541
542 foreach (SCR_EditableEntityComponent ent : editableEntities)
543 {
544 SCR_EditableVehicleComponent editableVehicle = SCR_EditableVehicleComponent.Cast(ent);
545 if (editableVehicle)
546 m_EditableVehicle.Insert(editableVehicle);
547 }
548 }
549
550 //------------------------------------------------------------------------------------------------
552 protected void OnCompositionSpawned(bool compositionSpawned)
553 {
554 m_bCompositionSpawned = compositionSpawned;
556 m_CompositionComponent.GetOnCompositionSpawned().Remove(OnCompositionSpawned);
557 }
558
559 //------------------------------------------------------------------------------------------------
562 {
563 IEntity provider = m_CompositionComponent.GetProviderEntity();
564 if (!provider)
565 return;
566
567 m_FactionComponent = FactionAffiliationComponent.Cast(provider.FindComponent(FactionAffiliationComponent));
568 }
569
570 //------------------------------------------------------------------------------------------------
572 protected IEntity GetBuildingTool(notnull IEntity ent)
573 {
575 if (!gadgetManager)
576 return null;
577
578 return gadgetManager.GetHeldGadget();
579 }
580
581 //------------------------------------------------------------------------------------------------
583 bool IsPlayerFactionSame(notnull SCR_ChimeraCharacter user)
584 {
586 return true;
587
588 Faction playerFaction = user.GetFaction();
589
590 return playerFaction && m_FactionComponent.GetAffiliatedFaction() == playerFaction;
591 }
592
593 //------------------------------------------------------------------------------------------------
594 protected bool IsHQService()
595 {
597 if (!campaignGameMode || !m_EditableEntity)
598 return false;
599
600 SCR_EditableEntityUIInfo editableEntityUIInfo = SCR_EditableEntityUIInfo.Cast(m_EditableEntity.GetInfo(GetOwner()));
601 if (!editableEntityUIInfo)
602 return false;
603
604 array<EEditableEntityLabel> entityLabels = {};
605 editableEntityUIInfo.GetEntityLabels(entityLabels);
606 if (entityLabels.Contains(EEditableEntityLabel.SERVICE_HQ))
607 return true;
608
609 return false;
610 }
611
612 //------------------------------------------------------------------------------------------------
614 {
615 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
616 if (!campaign)
617 return null;
618
619 SCR_CampaignMilitaryBaseManager baseMgr = campaign.GetBaseManager();
620 if (!baseMgr)
621 return null;
622
623 IEntity owner = GetOwner();
624 if (!owner)
625 return null;
626
627 return baseMgr.FindClosestBase(owner.GetOrigin(), SCR_ECampaignBaseType.BASE);
628 }
629
630 //------------------------------------------------------------------------------------------------
631 protected bool CanBeDisassembled()
632 {
633 // is not headquarter building, can be disassembled
634 if (!IsHQService())
635 return true;
636
638 if (!campaignBase)
639 return true;
640
641 if (campaignBase.IsHQ() || campaignBase.IsControlPoint())
642 return false;
643
644 SCR_ECampaignBaseType baseType = campaignBase.GetType();
645 if (baseType == SCR_ECampaignBaseType.RELAY || baseType == SCR_ECampaignBaseType.SOURCE_BASE)
646 return false;
647
648 return true;
649 }
650
651 //------------------------------------------------------------------------------------------------
652 protected bool CanBaseBeDisassembled(notnull SCR_ChimeraCharacter disassemblingCharacter)
653 {
655 if (!campaignBase)
656 return true;
657
658 Faction playerFaction = disassemblingCharacter.GetFaction();
659 if (!playerFaction)
660 return false;
661
662 // check if is exists dismantle task on this base for player faction
663 SCR_DismantleCampaignMilitaryBaseTaskEntity task = SCR_DismantleCampaignMilitaryBaseTaskEntity.Cast(SCR_CampaignTaskHelper.GetTaskOnBase(campaignBase, playerFaction, SCR_DismantleCampaignMilitaryBaseTaskEntity));
664 if (!task)
665 return false;
666
667 int playerId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(disassemblingCharacter);
668 // check if the player is assigned to task
669 if (!task.IsTaskAssignedTo(SCR_TaskExecutor.FromPlayerID(playerId)))
670 return false;
671
672 return true;
673 }
674
675 //------------------------------------------------------------------------------------------------
676 // Check if the editable entity component has a service trait set.
677 protected bool HasCompositionLabel(notnull SCR_CampaignBuildingCompositionComponent composition, EEditableEntityLabel label = EEditableEntityLabel.TRAIT_SERVICE)
678 {
679 SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(composition.GetOwner().FindComponent(SCR_EditableEntityComponent));
680 if (!editableEntity)
681 return false;
682
683 SCR_EditableEntityUIInfo editableEntityUIInfo = SCR_EditableEntityUIInfo.Cast(editableEntity.GetInfo());
684 return editableEntityUIInfo && editableEntityUIInfo.HasEntityLabel(label);
685 }
686
687 //------------------------------------------------------------------------------------------------
689 {
690 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
691 if (!campaign)
692 return false;
693
695 if (!campaignBase)
696 return false;
697
698 SCR_CampaignBuildingManagerComponent buildingManagerComponent = SCR_CampaignBuildingManagerComponent.Cast(campaign.FindComponent(SCR_CampaignBuildingManagerComponent));
699 if (!buildingManagerComponent)
700 return false;
701
702 array<SCR_CampaignBuildingCompositionComponent> compositions = {};
703 int compositionCount = buildingManagerComponent.GetBuildingCompositions(campaignBase, compositions);
704 foreach (SCR_CampaignBuildingCompositionComponent composition : compositions)
705 {
706 if (composition && HasCompositionLabel(composition))
707 return true;
708 }
709
710 return false;
711 }
712
713 //------------------------------------------------------------------------------------------------
716 {
717 ChimeraWorld world = GetGame().GetWorld();
718 if (!world)
719 return;
720
721 WorldTimestamp currentServerTimestamp = world.GetServerTimestamp();
722 if (!currentServerTimestamp.Greater(m_ResetTemporaryBlockedAccessTimestamp))
723 return;
724
726
727 // cache master provider component
729 {
731 if (!campaignBase)
732 return;
733
734 array<SCR_CampaignBuildingProviderComponent> providers = {};
735 campaignBase.GetBuildingProviders(providers);
736
737 foreach (SCR_CampaignBuildingProviderComponent provider : providers)
738 {
739 if (!provider.IsMasterProvider())
740 continue;
741
742 m_MasterProviderComponent = provider;
743 break;
744 }
745 }
746
748 return;
749
750 PlayerManager playerManager = GetGame().GetPlayerManager();
751 if (!playerManager)
752 return;
753
754 array<int> outPlayers = {};
755 playerManager.GetPlayers(outPlayers);
756
757 float buildingRadiusSq = m_MasterProviderComponent.GetBuildingRadius() * m_MasterProviderComponent.GetBuildingRadius();
758
759 IEntity playerEntity;
760 SCR_CharacterDamageManagerComponent charDamageManager;
761 foreach (int playerID : outPlayers)
762 {
763 playerEntity = playerManager.GetPlayerControlledEntity(playerID);
764 if (!playerEntity)
765 continue;
766
767 SCR_ChimeraCharacter char = SCR_ChimeraCharacter.Cast(playerEntity);
768 if (!char)
769 continue;
770
771 charDamageManager = SCR_CharacterDamageManagerComponent.Cast(char.FindComponent(SCR_CharacterDamageManagerComponent));
772 if (!charDamageManager || charDamageManager.GetState() == EDamageState.DESTROYED)
773 continue;
774
775 if (!m_MasterProviderComponent.IsEnemyFaction(char))
776 continue;
777
778 if (vector.DistanceSqXZ(GetOwner().GetOrigin(), playerEntity.GetOrigin()) <= buildingRadiusSq)
779 {
782 break;
783 }
784 }
785 }
786
787 //------------------------------------------------------------------------------------------------
788 // Destructor
790 {
791 if (!m_User)
792 return;
793
794 ChimeraCharacter character = ChimeraCharacter.Cast(m_User);
795 if (!SCR_CharacterHelper.IsPlayerOrAIOwner(character))
796 return;
797
798 CancelPlayerAnimation(character); // this needs to be here in case f.e. a GM deletes the composition while it is being dismantled
799 }
800}
EEditableEntityLabel
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
vector GetOrigin()
SCR_BaseGameMode GetGameMode()
void SCR_CharacterRankComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
proto external ActionsManagerComponent GetActionsManager()
void SetCannotPerformReason(string reason)
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external UIInfo GetUIInfo()
Returns the UIInfo set for this user action or null if none.
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
proto external IEntity GetChildren()
proto external IEntity GetSibling()
proto external IEntity GetRootParent()
void GetNavmeshRebuildAreas(IEntity entity, out notnull array< ref Tuple2< vector, vector > > outAreas, out notnull array< bool > redoRoads)
void RequestNavmeshRebuildAreas(notnull array< ref Tuple2< vector, vector > > areas, notnull array< bool > redoRoads)
SCR_CampaignBuildingCompositionComponent m_CompositionComponent
bool HasCompositionLabel(notnull SCR_CampaignBuildingCompositionComponent composition, EEditableEntityLabel label=EEditableEntityLabel.TRAIT_SERVICE)
override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
void TryToSendNotification(notnull IEntity pOwnerEntity, notnull SCR_ChimeraCharacter disassemblingCharacter)
bool HasCompositionLabel(EEditableEntityLabel label=EEditableEntityLabel.TRAIT_SERVICE)
void OnCompositionSpawned(bool compositionSpawned)
Get call once the composition is fully spawned.
bool CanBaseBeDisassembled(notnull SCR_ChimeraCharacter disassemblingCharacter)
void SetNewGadgetManager(IEntity from, IEntity to)
Sets a new gadget manager. Controlled by an event when the controlled entity has changed.
void CacheFactionAffiliationComponent()
Get call once the provider is set.
IEntity GetBuildingTool(notnull IEntity ent)
Get building tool entity.
void GetBuildingAction()
Search for first instance of building action, as we can safely assume there is only one per entity.
bool IsPlayerFactionSame(notnull SCR_ChimeraCharacter user)
Is user faction same as the composition one.
ref array< SCR_EditableVehicleComponent > m_EditableVehicle
void DeleteComposition(notnull IEntity composition, notnull SCR_ChimeraCharacter character)
void ToggleCompartmentAccess(notnull IEntity object, IEntity blockingUser=null)
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
100m
void GetAllTurretsInComposition(IEntity object)
Check the hierarchy of the composition for any turret and make a list of them.
void DeleteBase(notnull SCR_CampaignMilitaryBaseComponent base, int userPlayerId)
SCR_ECampaignBaseType GetType()
Returns type of this base.
SCR_CampaignMilitaryBaseComponent FindClosestBase(vector position, SCR_ECampaignBaseType searchedType=-1)
bool Delete(bool changedByUser=false, bool updateNavmesh=false)
SCR_UIInfo GetInfo(IEntity owner=null)
bool HasEntityLabel(EEditableEntityLabel label)
int GetEntityLabels(out notnull array< EEditableEntityLabel > entityLabels)
Core component to manage SCR_EditorManagerEntity.
SCR_EditorManagerEntity GetEditorManager()
SCR_RankContainer GetRanks()
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
ref OnControlledEntityChangedPlayerControllerInvoker m_OnControlledEntityChanged
bool IsRankRenegade(SCR_ECharacterRank rankID)
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
ECharacterLifeState
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
proto external PlayerController GetPlayerController()
EDamageState