/// <summary> /// Executed if Session is ready. /// </summary> private void OnSessionReady() { MyAPIGateway.Session.OnSessionReady -= OnSessionReady; _suitComputer = SuitComputer.Create(); SetUpdateOrder(_suitComputer != null ? MyUpdateOrder.BeforeSimulation : MyUpdateOrder.AfterSimulation); }
/// <summary> /// Executed if Session is ready. /// </summary> private void OnSessionReady() { MyAPIGateway.Session.OnSessionReady -= OnSessionReady; RemoveAutomaticJetpackActivation = MyAPIGateway.Session.Mods.Any(x => x.PublishedFileId == REMOVE_AUTOMATIC_JETPACK_ACTIVATION_ID); _suitComputer = SuitComputer.Create(); if (_suitComputer != null) { SetUpdateOrder(MyUpdateOrder.BeforeSimulation); } }
/// <summary> /// Used to register <see cref="SuitComputer" /> when in some rare cases the player or player identity was not set in /// <see cref="OnSessionReady" />. /// </summary> public override void UpdateAfterSimulation() { if (_suitComputer != null) { return; } _suitComputer = SuitComputer.Create(); if (_suitComputer != null) { SetUpdateOrder(MyUpdateOrder.BeforeSimulation); } }
/// <inheritdoc /> protected override void UnloadData() { Log?.EnterMethod(nameof(UnloadData)); MyAPIGateway.Session.OnSessionReady -= OnSessionReady; MyAPIGateway.Gui.GuiControlRemoved -= OnGuiControlRemoved; if (WaterModAvailable) { WaterModAPI?.Unregister(); } if (_chatHandler != null) { _chatHandler.Close(); _chatHandler = null; } if (_suitComputer != null) { _suitComputer.Close(); _suitComputer = null; } if (Network != null) { _networkHandler.Close(); _networkHandler = null; Log?.Info("Cap network connections"); Network.Close(); Network = null; } if (Log != null) { Log.Info("Logging stopped"); Log.Flush(); Log.Close(); Log = null; } }