3 [
ComponentEditorProps(
category:
"GameScripted/Editor", description:
"Attribute for managing access keys. Works only with SCR_EditorBaseEntity!", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
21 private bool m_bIsAdmin =
true;
43 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
49 m_AccessKey = m_AccessKey | accessKey;
54 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
60 m_AccessKey = m_AccessKey &~ accessKey;
65 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
68 m_AccessKey = accessKey;
86 return m_AccessKey & accessKey;
108 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
113 entity.AddAccessKey(accessKey);
117 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
122 entity.RemoveAccessKey(accessKey);
137 int enumCount = enumType.GetVariableCount();
138 for (
int i = 0; i < enumCount; i++)
141 if (enumType.GetVariableType(i) ==
int && enumType.GetVariableValue(
null, i, val))
145 if (!output.IsEmpty())
148 output += enumType.GetVariableName(i);
153 return string.Format(
"Editor access keys: %1", output);
164 Print(
"--------------------------------------------------", LogLevel.DEBUG);
165 set<SCR_EditableEntityComponent> entities =
new set<SCR_EditableEntityComponent>();
166 core.GetAllEntities(entities,
true);
169 if (entity.IsLayer())
170 entity.Log(
"", m_AccessKey);
172 Print(
"--------------------------------------------------", LogLevel.DEBUG);
184 override bool IsAdmin()
186 return m_bIsAdmin && super.IsAdmin();
197 override void EOnFrame(IEntity owner,
float timeSlice)
199 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_AVAILABLE))
202 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_AVAILABLE,
false);
205 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_ACCESS_KEYS))
208 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_ACCESS_KEYS,
false);
211 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_TOGGLE))
215 keysType.GetVariableValue(
null, DiagMenu.GetRangeValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY), keyValue);
225 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_TOGGLE,
false);
229 if (DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_ADMIN) != m_bIsAdmin)
231 m_bIsAdmin = DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_ADMIN);
233 m_AccessKey =
int.MAX;
246 writer.Write(m_AccessKey, 32);
254 reader.Read(m_AccessKey, 32);
261 SetEventMask(
GetOwner(), EntityEvent.FRAME);
271 int keysCount = keysType.GetVariableCount();
275 m_AccessKey =
int.MAX;
277 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_AVAILABLE,
"",
"Log Available",
"Editable Entities");
278 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_ACCESS_KEYS,
"",
"Log Access Keys",
"Editable Entities");
279 DiagMenu.RegisterRange(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY,
"",
"Access Key",
"Editable Entities",
string.Format(
"0, %1, 0, 1", keysCount - 1));
280 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_TOGGLE,
"",
"Access Key: Toggle",
"Editable Entities");
281 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_ACCESS_KEYS,
false);
282 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_TOGGLE,
false);
285 m_bIsAdmin = IsAdmin();
288 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_ADMIN,
"",
"Admin Access",
"Editable Entities");
289 DiagMenu.SetValue(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_ADMIN, m_bIsAdmin);
297 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_AVAILABLE);
298 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_LOG_ACCESS_KEYS);
299 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY);
300 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_TOGGLE);
301 DiagMenu.Unregister(
SCR_DebugMenuID.DEBUGUI_EDITOR_ENTITIES_ACCESS_KEY_ADMIN);