public override void UpdateAfterSimulation() { Instance = this; // This needs to wait until the MyAPIGateway.Session.Player is created, as running on a Dedicated server can cause issues. // It would be nicer to just read a property that indicates this is a dedicated server, and simply return. if (!_isInitialized && MyAPIGateway.Session != null && MyAPIGateway.Session.Player != null) { Debug = MyAPIGateway.Session.Player.IsExperimentalCreator(); if (MyAPIGateway.Session.OnlineMode.Equals(MyOnlineModeEnum.OFFLINE)) // pretend single player instance is also server. InitServer(); if (!MyAPIGateway.Session.OnlineMode.Equals(MyOnlineModeEnum.OFFLINE) && MyAPIGateway.Multiplayer.IsServer && !MyAPIGateway.Utilities.IsDedicated) InitServer(); InitClient(); } // Dedicated Server. if (!_isInitialized && MyAPIGateway.Utilities != null && MyAPIGateway.Multiplayer != null && MyAPIGateway.Session != null && MyAPIGateway.Utilities.IsDedicated && MyAPIGateway.Multiplayer.IsServer) { InitServer(); return; } if (_delayedConnectionRequest) { ClientLogger.Write("Delayed Connection Request"); _delayedConnectionRequest = false; MessageConnectionRequest.SendMessage(EconomyConsts.ModCommunicationVersion); } base.UpdateAfterSimulation(); }
static EconomyScript() { Instance = new EconomyScript(); }