1[
EntityEditorProps(
category:
"GameScripted/GameMode", description:
"Area that provides basic events and api to serve as a captureable area.")]
81 FactionManager factionManager =
GetGame().GetFactionManager();
84 Debug.Error(
"No faction manager present in the world! Capture area will malfunction!");
92 Debug.Error(
"SCR_CaptureArea requires RplComponent to function!");
99 array<Faction> availableFactions = {};
100 factionManager.GetFactionsList(availableFactions);
103 foreach (
Faction faction : availableFactions)
104 m_mOccupants.Insert(faction,
new array<SCR_ChimeraCharacter>());
112 int factionIndex = -1;
113 reader.ReadInt(factionIndex);
116 if (factionIndex != -1)
117 ownerFaction =
GetGame().GetFactionManager().GetFactionByIndex(factionIndex);
127 protected override bool RplSave(ScriptBitWriter writer)
129 int factionIndex = -1;
133 writer.WriteInt(factionIndex);
142 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(ent);
147 return !character.GetCharacterController().IsDead();
157 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(ent);
161 Faction faction = character.GetFaction();
183 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(ent);
184 Faction faction = character.GetFaction();
209 array<SCR_ChimeraCharacter> characters =
m_mOccupants[faction];
210 if (!characters || characters.IsEmpty())
213 outCharacters.Copy(characters);
214 return characters.Count();
238 array<Faction> availableFactions = {};
239 GetGame().GetFactionManager().GetFactionsList(availableFactions);
244 foreach (
Faction faction : availableFactions)
247 if (occupantsCount == 0)
250 if (occupantsCount > maxCount)
252 maxCount = occupantsCount;
253 maxFaction = faction;
271 super.OnFrame(owner, timeSlice);
277 for (
int i = characters.Count() - 1; i >= 0; --i)
279 SCR_ChimeraCharacter occupant = characters[i];
280 if (!occupant || occupant.GetCharacterController().IsDead())
282 characters.Remove(i);
309 FactionManager factionManager =
GetGame().GetFactionManager();
310 int previousIndex = factionManager.GetFactionIndex(previousOwner);
311 int newIndex = factionManager.GetFactionIndex(newOwner);
331 FactionManager factionManager =
GetGame().GetFactionManager();
334 if (previousFactionIndex != -1)
335 previousFaction = factionManager.GetFactionByIndex(previousFactionIndex);
338 if (newFactionIndex != -1)
339 newFaction = factionManager.GetFactionByIndex(newFactionIndex);
ArmaReforgerScripted GetGame()
func CaptureAreaOwnerFactionEventDelegate
ScriptInvokerBase< CaptureAreaOwnerFactionEventDelegate > CaptureAreaOwnershipEvent
ScriptInvokerBase< CaptureAreaCharacterEventDelegate > CaptureAreaEvent
func CaptureAreaCharacterEventDelegate
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
override bool RplLoad(ScriptBitReader reader)
void SetOwningFactionInternal(Faction previousFaction, Faction newFaction)
Sets internal owner faction and raises corresponding callback.
RplComponent m_pRplComponent
Replication component of this entity.
event void OnCharacterExit(Faction faction, SCR_ChimeraCharacter character)
Occurs when a [character] of provided [faction] leaves the area.
override void OnInit(IEntity owner)
Initializes this area by initializing and preallocating required resources.
void SetOwningFactionInternalAuthority(Faction previousOwner, Faction newOwner)
Sets internal owner faction and raises corresponding callback for clients.
ref CaptureAreaEvent m_pOnCharacterEnter
Callback raised when a character enters this area.
override bool RplSave(ScriptBitWriter writer)
CaptureAreaEvent GetCharacterEnterInvoker()
Returns invoker that is invoked when a character enters this area.
override void OnDeactivate(IEntity ent)
callback - deactivation - occurs when and entity which was activated (OnActivate) leaves the Trigger
override bool ScriptedEntityFilterForQuery(IEntity ent)
By default queries only for characters of SCR_ChimeraCharacter type.
ref map< Faction, ref array< SCR_ChimeraCharacter > > m_mOccupants
ref CaptureAreaOwnershipEvent m_pOnOwnershipChanged
Callback raised when a new faction claims ownership of this area.
Faction EvaluateOwnerFaction()
event void OnCharacterEntered(Faction faction, SCR_ChimeraCharacter character)
Occurs when a [character] of provided [faction] enters the area.
Faction GetOwningFaction()
Returns the faction that currently owns the area or null if none.
ref CaptureAreaEvent m_pOnCharacterExit
Callback raised when a character leaves this area.
override void OnActivate(IEntity ent)
callback - activation - occurs when and entity which fulfills the filter definitions enters the Trigg...
int GetOccupantsCount(Faction faction)
event void OnOwningFactionChanged(Faction previousFaction, Faction newFaction)
CaptureAreaOwnershipEvent GetOwnershipChangedEvent()
Returns invoker that is invoked when a faction claims ownership of this area.
override event void OnFrame(IEntity owner, float timeSlice)
CaptureAreaEvent GetCharacterExitInvoker()
Returns invoker that is invoked when a character exits this area.
int GetOccupants(Faction faction, notnull array< SCR_ChimeraCharacter > outCharacters)
void Rpc_SetOwningFaction_BC(int previousFactionIndex, int newFactionIndex)
Faction m_pOwnerFaction
The faction that currently owns this area.
EntityEvent
Various entity events.
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
proto bool Contains(T value)