public void Init(MyObjectBuilder_GlobalEvents objectBuilder) { foreach (var eventBuilder in objectBuilder.Events) { m_globalEvents.Add(MyGlobalEventFactory.CreateEvent(eventBuilder)); } }
public override void BeforeStart() { base.BeforeStart(); if (!Sync.IsServer) { return; } bool shouldHaveCargoShips = MyFakes.ENABLE_CARGO_SHIPS && MySession.Static.CargoShipsEnabled; var cargoShipEvent = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "SpawnCargoShip")); if (cargoShipEvent == null && shouldHaveCargoShips) { var globalEvent = MyGlobalEventFactory.CreateEvent(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "SpawnCargoShip")); MyGlobalEvents.AddGlobalEvent(globalEvent); } else if (cargoShipEvent != null) { if (shouldHaveCargoShips) { cargoShipEvent.Enabled = true; } else { cargoShipEvent.Enabled = false; } } }
public static void LoadEvents(MyObjectBuilder_GlobalEvents eventsBuilder) { if (eventsBuilder == null) { return; } foreach (var globalEventBuilder in eventsBuilder.Events) { MyGlobalEventBase globalEvent = MyGlobalEventFactory.CreateEvent(globalEventBuilder); Debug.Assert(globalEvent == null || globalEvent.IsHandlerValid, "Event handler could not be found on load. Call a programmer please! You can ignore this, if you don't mind the given event not happening."); if (globalEvent != null && globalEvent.IsHandlerValid) { m_globalEvents.Add(globalEvent); } } }