Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayersPresentTriggerEntity.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Triggers", description: "")]
5
6/*
7 The trigger invokes the onActivate event in case the number of the connected players of the given faction
8 is present in the trigger
9*/
10
11//O B S O L E T E !!! DON'T USE IT
12//WILL BE DELETED
13
14class SCR_PlayersPresentTriggerEntity: SCR_BaseTriggerEntity
15{
16 [Attribute(desc: "Faction which is used for area control calculation. Leave empty for any faction.", category: "Trigger")]
18
19 [Attribute("0", UIWidgets.ComboBox, "By whom the trigger is activated", "", ParamEnumArray.FromEnum(SCR_EScenarioFrameworkTriggerActivation), category: "Trigger")]
20 protected SCR_EScenarioFrameworkTriggerActivation m_eActivationPresence;
21
22 /*
23 [Attribute(desc: "Trigger activation - all connected players of the given faction or just one?", category: "Trigger")]
24 protected bool m_bAllPlayersPresent;
25 */
26
28 protected int m_iEntitiesInside = 0;
29
30 //------------------------------------------------------------------------------------------------
32 {
33 m_OwnerFaction = faction;
34 }
35
36 //------------------------------------------------------------------------------------------------
37 bool IsMaster()// IsServer
38 {
39 RplComponent comp = RplComponent.Cast(FindComponent(RplComponent));
40 return comp && comp.IsMaster();
41 }
42
43 //------------------------------------------------------------------------------------------------
45 {
46 int iCnt = 0;
47 array<int> aPlayerIDs = {};
48 SCR_PlayerController playerController;
49 GetGame().GetPlayerManager().GetPlayers(aPlayerIDs);
50 foreach (int iPlayerID: aPlayerIDs)
51 {
52 playerController = SCR_PlayerController.Cast(GetGame().GetPlayerManager().GetPlayerController(iPlayerID));
53 if (!playerController)
54 continue;
55
56 if (playerController.GetLocalControlledEntityFaction() == m_OwnerFaction)
57 iCnt++;
58 }
59 return iCnt;
60 }
61
62 //------------------------------------------------------------------------------------------------
63 protected void GetPlayersByFaction(notnull out array<IEntity> aOut)
64 {
65 array<int> aPlayerIDs = {};
66 SCR_PlayerController playerController;
67 GetGame().GetPlayerManager().GetPlayers(aPlayerIDs);
68 foreach (int iPlayerID: aPlayerIDs)
69 {
70 playerController = SCR_PlayerController.Cast(GetGame().GetPlayerManager().GetPlayerController(iPlayerID));
71 if (!playerController)
72 continue;
73
74 if (playerController.GetLocalControlledEntityFaction() == m_OwnerFaction)
75 aOut.Insert(playerController.GetLocalMainEntity());
76 }
77 }
78
79
82 {
83 if (!ChimeraCharacter.Cast(ent))
84 return false;
85
86 // take only players
87 if (m_eActivationPresence == SCR_EScenarioFrameworkTriggerActivation.PLAYER)
88 {
89 if (!EntityUtils.IsPlayer(ent))
90 return false;
91 }
92 if (m_sOwnerFactionKey.IsEmpty())
93 return true; //if faction is not specified, any faction can (de)activate the trigger
94
95 FactionAffiliationComponent pFaciliation = FactionAffiliationComponent.Cast(ent.FindComponent(FactionAffiliationComponent));
96 if (!pFaciliation)
97 return false;
98
99 return pFaciliation.GetAffiliatedFaction() == m_OwnerFaction;
100 }
101
102 //------------------------------------------------------------------------------------------------
103 override protected event void OnActivate(IEntity ent)
104 {
105 if (!IsMaster())
106 return;
107
109 if (m_eActivationPresence == SCR_EScenarioFrameworkTriggerActivation.PLAYER || m_eActivationPresence == SCR_EScenarioFrameworkTriggerActivation.ANY_CHARACTER)
110 {
111 m_OnActivate.Invoke(ent);
112 }
113 }
114
115 //------------------------------------------------------------------------------------------------
116 override protected event void OnDeactivate(IEntity ent)
117 {
119 m_OnDeactivate.Invoke();
120 }
121
122 //------------------------------------------------------------------------------------------------
123 override protected void EOnInit(IEntity owner)
124 {
125 FactionManager factionManager = GetGame().GetFactionManager();
126 if (factionManager)
127 m_OwnerFaction = factionManager.GetFactionByKey(m_sOwnerFactionKey);
128 }
129};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseTriggerEntityClass m_OnActivate
Basic scripted trigger which offers external invoekrs for major events like activation or deactivatio...
ref ScriptInvoker m_OnDeactivate
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
static Faction GetLocalControlledEntityFaction()
static IEntity GetLocalMainEntity()
SCR_EScenarioFrameworkTriggerActivation m_eActivationPresence
void GetPlayersByFaction(notnull out array< IEntity > aOut)
override bool ScriptedEntityFilterForQuery(IEntity ent)
Override this method in inherited class to define a new filter.
SCR_FieldOfViewSettings Attribute
proto external PlayerController GetPlayerController()