private static void TryInitialize() { // return unless session ready if (MyAPIGateway.CubeBuilder == null || MyAPIGateway.Entities == null || MyAPIGateway.Multiplayer == null || MyAPIGateway.Parallel == null || MyAPIGateway.Players == null || MyAPIGateway.Session == null || MyAPIGateway.TerminalActionsHelper == null || MyAPIGateway.Utilities == null || (!MyAPIGateway.Multiplayer.IsServer && MyAPIGateway.Session.Player == null)) { return; } var runningOn = !MyAPIGateway.Multiplayer.MultiplayerActive ? RunLocation.Both : (MyAPIGateway.Multiplayer.IsServer ? RunLocation.Server : RunLocation.Client); Logger.DebugLog($"Initializing. RunningOn: {runningOn}, SessionName: {MyAPIGateway.Session.Name}, SessionPath: {MyAPIGateway.Session.CurrentPath}"); ComponentStore = new ComponentCollectionStore(runningOn); ExternalRegistrations = new LockedDeque <Action>(); MyAPIGateway.Entities.OnEntityAdd += EntityAdded; var entities = new HashSet <IMyEntity>(); MyAPIGateway.Entities.GetEntities(entities); foreach (IMyEntity entity in entities) { EntityAdded(entity); } foreach (var collection in ComponentRegistrar.GetInitComponents()) { ComponentStore.TryAddCollection(collection); } Status = RunStatus.Initialized; }
public static void RegisterComponentGroup(int group) { var collection = ComponentRegistrar.GetComponents(Assembly.GetCallingAssembly(), group); ExternalRegistrations?.AddTail(() => { ComponentStore.TryAddCollection(collection); }); }