Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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")]
3 {
4 };
5 
12 {
13  protected RplIdentity m_EditorIdentity = RplIdentity.Invalid();
14 
15  protected void EnableStreaming(bool enable)
16  {
18  if (!core)
19  return;
20 
21  //--- Get editor owner's RplIdentity
22  if (!m_EditorIdentity.IsValid())
23  {
24  PlayerController playerController = GetGame().GetPlayerManager().GetPlayerController(GetManager().GetPlayerID());
25  if (playerController)
26  m_EditorIdentity = playerController.GetRplIdentity();
27  }
28 
29  //--- Ignore when it's local on server, no need to configure streaming in such case
30  if (m_EditorIdentity == RplIdentity.Local())
31  return;
32 
33  //--- Get all entities (ToDo: Only limited subsection e.g., players in admin mode)
34  set<SCR_EditableEntityComponent> entities = new set<SCR_EditableEntityComponent>();
35  core.GetAllEntities(entities);
36  for (int i = 0, count = entities.Count(); i < count; i++)
37  {
38  EnableStreamingForEntity(entities[i], enable);
39  }
40  }
41  protected void EnableStreamingForEntity(SCR_EditableEntityComponent entity, bool enable)
42  {
43  //--- Check if the entity was meanwhile deleted (e.g., when placing a waypoint that's instantly completed)
44  if (!entity.GetOwner())
45  return;
46 
47  RplComponent entityRpl = RplComponent.Cast(entity.GetOwner().FindComponent(RplComponent));
48  if (entityRpl)
49  {
50  entityRpl.EnableStreamingConNode(m_EditorIdentity, enable);
51  /*
52  if (enable)
53  entity.Log(string.Format("Enable streaming of %1 for %2",entityRpl, m_EditorIdentity), true, LogLevel.DEBUG);
54  else
55  entity.Log(string.Format("Disable streaming of %1 for %2",entityRpl, m_EditorIdentity), true, LogLevel.WARNING);
56  */
57  }
58  }
59 
60  protected void OnEntityRegistered(SCR_EditableEntityComponent entity)
61  {
62  if (GetManager().IsOpened() && m_EditorIdentity != RplIdentity.Local())
63  GetGame().GetCallqueue().CallLater(EnableStreamingForEntity, 1, false, entity, false); //--- Give replication time to initialize
64  }
65  protected void OnEntityUnregistered(SCR_EditableEntityComponent entity)
66  {
67  if (GetManager().IsOpened() && m_EditorIdentity != RplIdentity.Local())
68  EnableStreamingForEntity(entity, true);
69  }
70 
71  override void EOnEditorActivateServer()
72  {
73  EnableStreaming(false);
74 
76  if (core)
77  core.Event_OnEntityRegistered.Insert(OnEntityRegistered);
78  }
79  override void EOnEditorDeactivateServer()
80  {
81  EnableStreaming(true);
82 
84  if (core)
85  core.Event_OnEntityRegistered.Remove(OnEntityRegistered);
86  }
87 };
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_DynamicSimulationEditorComponentClass
Definition: SCR_DynamicSimulationEditorComponent.c:2
SCR_EditableEntityCore
Definition: SCR_EditableEntityCore.c:10
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GetPlayerID
override int GetPlayerID()
Definition: SCR_EditableCharacterComponent.c:484
SCR_BaseEditorComponent
Definition: SCR_BaseEditorComponent.c:119
SCR_BaseEditorComponentClass
Definition: SCR_BaseEditorComponent.c:2
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_DynamicSimulationEditorComponent
Definition: SCR_DynamicSimulationEditorComponent.c:11
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180