Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DeleteSelectedContextAction.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 {
5  [Attribute(desc: "When enabled, the action will not be available if target entity is a player or a vehicle containing players.")]
6  protected bool m_bCannotDeletePlayer;
7 
8  override bool CanBeShown(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
9  {
10  return CanBePerformed(selectedEntity, cursorWorldPosition, flags);
11  }
12  override bool CanBePerformed(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
13  {
14  //--- Prevent deleting players. Check the entity and compartments directly; don't rely on PLAYER state, as PLAYER filter may not be present in this editor mode.
15  if (m_bCannotDeletePlayer)
16  {
17  SCR_PossessingManagerComponent possessionManager = SCR_PossessingManagerComponent.GetInstance();
18 
19  //--- Scan all children; player may be occupying a turret inside a composition
20  set<SCR_EditableEntityComponent> children = new set<SCR_EditableEntityComponent>();
21  selectedEntity.GetChildren(children);
22  foreach (SCR_EditableEntityComponent child: children)
23  {
24  IEntity owner = child.GetOwner();
25  SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(owner.FindComponent(SCR_BaseCompartmentManagerComponent));
26  if (compartmentManager)
27  {
28  //--- Entity has compartment manager, check if one of the occupants is a player
29  array<IEntity> occupants = {};
30  compartmentManager.GetOccupants(occupants);
31  foreach (IEntity occupant: occupants)
32  {
33  if (possessionManager)
34  {
35  if (possessionManager.GetIdFromMainEntity(occupant) != 0)
36  return false;
37  }
38  else
39  {
40  if ((GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(occupant) != 0))
41  return false;
42  }
43  }
44  }
45  else
46  {
47  //--- Check if the entity itself is a player
48  if (possessionManager)
49  {
50  if (possessionManager.GetIdFromMainEntity(owner) != 0)
51  return false;
52  }
53  else
54  {
55  if ((GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(owner) != 0))
56  return false;
57  }
58  }
59  }
60  }
61 
62  return selectedEntity
63  && !selectedEntity.HasEntityFlag(EEditableEntityFlag.NON_DELETABLE)
64  && !selectedEntity.HasEntityFlag(EEditableEntityFlag.NON_INTERACTIVE);
65  //&& !selectedEntity.HasEntityState(EEditableEntityState.PLAYER);
66  }
67  override void Perform(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition)
68  {
69  if (selectedEntity)
70  selectedEntity.Delete(true);
71  }
72 };
EEditableEntityFlag
EEditableEntityFlag
Unique flags of the entity.
Definition: EEditableEntityFlag.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_SelectedEntitiesContextAction
Definition: SCR_SelectedEntitiesContextAction.c:10
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
SCR_DeleteSelectedContextAction
Definition: SCR_DeleteSelectedContextAction.c:3
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468