Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DynamicSimulationEditorComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Editor", description: "System to force streaming of all editable entities to client who has opened editor. Works only with SCR_EditorBaseEntity!", icon: "WBData/ComponentEditorProps/componentEditor.png")]
5
12{
14
15 protected ref array<EEditableEntityType> m_LocalSkipStreamingRules = {};
16
17 protected bool m_bStreamingRulesInitialized = false;
18
19 protected void EnableStreaming(bool enable)
20 {
22 if (!core)
23 return;
24
25 //--- Get editor owner's RplIdentity
26 if (!m_EditorIdentity.IsValid())
27 {
28 PlayerController playerController = GetGame().GetPlayerManager().GetPlayerController(GetManager().GetPlayerID());
29 if (playerController)
30 m_EditorIdentity = playerController.GetRplIdentity();
31 }
32
33 //--- Ignore when it's local on server, no need to configure streaming in such case
34 if (m_EditorIdentity == RplIdentity.Local())
35 return;
36
37 //--- Get all entities (ToDo: Only limited subsection e.g., players in admin mode)
38 set<SCR_EditableEntityComponent> entities = new set<SCR_EditableEntityComponent>();
39 core.GetAllEntities(entities);
40 for (int i = 0, count = entities.Count(); i < count; i++)
41 {
42 EnableStreamingForEntity(entities[i], enable);
43 }
44 }
45 protected void EnableStreamingForEntity(SCR_EditableEntityComponent entity, bool enable)
46 {
47 //--- Check if the entity was meanwhile deleted (e.g., when placing a waypoint that's instantly completed)
48 if (!entity || !entity.GetOwner())
49 return;
50
52 {
54 if(editorSettingsEntity && m_LocalSkipStreamingRules)
55 {
58 }
59 }
60
61 if(m_LocalSkipStreamingRules.Contains(entity.GetEntityType()))
62 return;
63
64 RplComponent entityRpl = RplComponent.Cast(entity.GetOwner().FindComponent(RplComponent));
65 if (entityRpl)
66 {
67 entityRpl.EnableStreamingConNode(m_EditorIdentity, enable);
68 /*
69 if (enable)
70 entity.Log(string.Format("Enable streaming of %1 for %2",entityRpl, m_EditorIdentity), true, LogLevel.DEBUG);
71 else
72 entity.Log(string.Format("Disable streaming of %1 for %2",entityRpl, m_EditorIdentity), true, LogLevel.WARNING);
73 */
74 }
75 }
76
78 {
79 if (GetManager().IsOpened() && m_EditorIdentity != RplIdentity.Local())
80 GetGame().GetCallqueue().CallLater(EnableStreamingForEntity, 1, false, entity, false); //--- Give replication time to initialize
81 }
83 {
84 if (GetManager().IsOpened() && m_EditorIdentity != RplIdentity.Local())
85 EnableStreamingForEntity(entity, true);
86 }
87
89 {
90 EnableStreaming(false);
91
93 if (core)
94 core.Event_OnEntityRegistered.Insert(OnEntityRegistered);
95 }
97 {
98 EnableStreaming(true);
99
101 if (core)
102 core.Event_OnEntityRegistered.Remove(OnEntityRegistered);
103 }
104};
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
override int GetPlayerID()
Replication connection identity.
Definition RplIdentity.c:14
void SCR_BaseEditorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_EditorManagerEntity GetManager()
void EnableStreamingForEntity(SCR_EditableEntityComponent entity, bool enable)
void OnEntityRegistered(SCR_EditableEntityComponent entity)
void OnEntityUnregistered(SCR_EditableEntityComponent entity)
EEditableEntityType GetEntityType(IEntity owner=null)
void GetAllEntities(out notnull set< SCR_EditableEntityComponent > entities, bool onlyDirect=false, bool skipIgnored=false)
bool GetSkipStreamingRules(out notnull array< EEditableEntityType > skipStreamingRules)
static SCR_EditorSettingsEntity GetInstance()