Пример #1
0
        public override void BeforeStart()
        {
            try
            {
                MpActive        = MyAPIGateway.Multiplayer.MultiplayerActive;
                IsServer        = MyAPIGateway.Multiplayer.IsServer;
                DedicatedServer = MyAPIGateway.Utilities.IsDedicated;

                var env = MyDefinitionManager.Static.EnvironmentDefinition;
                if (env.LargeShipMaxSpeed > MaxEntitySpeed)
                {
                    MaxEntitySpeed = env.LargeShipMaxSpeed;
                }
                else if (env.SmallShipMaxSpeed > MaxEntitySpeed)
                {
                    MaxEntitySpeed = env.SmallShipMaxSpeed;
                }

                Log.Init("debugdevelop.log");
                Log.Line($"Logging Started: Server:{IsServer} - Dedicated:{DedicatedServer} - MpActive:{MpActive}");

                MyAPIGateway.Session.DamageSystem.RegisterBeforeDamageHandler(0, CheckDamage);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PACKET_ID, ReceivedPacket);

                if (!DedicatedServer && IsServer)
                {
                    Players.TryAdd(MyAPIGateway.Session.Player.IdentityId, MyAPIGateway.Session.Player);
                }
                MyEntities.OnEntityRemove                        += OnEntityRemove;
                MyAPIGateway.Session.OnSessionReady              += OnSessionReady;
                MyVisualScriptLogicProvider.PlayerDisconnected   += PlayerDisconnected;
                MyVisualScriptLogicProvider.PlayerRespawnRequest += PlayerConnected;
                if (!DedicatedServer)
                {
                    MyAPIGateway.TerminalControls.CustomControlGetter += CustomControls;
                }

                if (IsServer)
                {
                    Log.Line("LoadConf - Session: This is a server");
                    UtilsStatic.PrepConfigFile();
                    UtilsStatic.ReadConfigFile();
                }

                if (MpActive)
                {
                    SyncDist            = MyAPIGateway.Session.SessionSettings.SyncDistance;
                    SyncDistSqr         = SyncDist * SyncDist;
                    SyncBufferedDistSqr = SyncDistSqr + 250000;
                    if (Enforced.Debug >= 2)
                    {
                        Log.Line($"SyncDistSqr:{SyncDistSqr} - SyncBufferedDistSqr:{SyncBufferedDistSqr} - DistNorm:{SyncDist}");
                    }
                }
                else
                {
                    SyncDist            = MyAPIGateway.Session.SessionSettings.ViewDistance;
                    SyncDistSqr         = SyncDist * SyncDist;
                    SyncBufferedDistSqr = SyncDistSqr + 250000;
                    if (Enforced.Debug >= 2)
                    {
                        Log.Line($"SyncDistSqr:{SyncDistSqr} - SyncBufferedDistSqr:{SyncBufferedDistSqr} - DistNorm:{SyncDist}");
                    }
                }
                MyAPIGateway.Parallel.StartBackground(WebMonitor);

                if (!IsServer)
                {
                    RequestEnforcement(MyAPIGateway.Multiplayer.MyId);
                }

                foreach (var mod in MyAPIGateway.Session.Mods)
                {
                    if (mod.PublishedFileId == 540003236)
                    {
                        ThyaImages = true;
                    }
                }

                ApiServer.Load();
            }
            catch (Exception ex) { Log.Line($"Exception in BeforeStart: {ex}"); }
        }
Пример #2
0
        public override void BeforeStart()
        {
            try
            {
                MpActive        = MyAPIGateway.Multiplayer.MultiplayerActive;
                IsServer        = MyAPIGateway.Multiplayer.IsServer;
                DedicatedServer = MyAPIGateway.Utilities.IsDedicated;
                HandlesInput    = !IsServer || IsServer && !DedicatedServer;

                var env = MyDefinitionManager.Static.EnvironmentDefinition;
                if (env.LargeShipMaxSpeed > MaxEntitySpeed)
                {
                    MaxEntitySpeed = env.LargeShipMaxSpeed;
                }
                else if (env.SmallShipMaxSpeed > MaxEntitySpeed)
                {
                    MaxEntitySpeed = env.SmallShipMaxSpeed;
                }

                Log.Init("debugdevelop.log");
                Log.Line($"Logging Started: Server:{IsServer} - Dedicated:{DedicatedServer} - MpActive:{MpActive}");

                MyAPIGateway.Session.DamageSystem.RegisterBeforeDamageHandler(0, CheckDamage);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PACKET_ID, ReceivedPacket);

                if (!DedicatedServer && IsServer)
                {
                    Players.TryAdd(MyAPIGateway.Session.Player.IdentityId, MyAPIGateway.Session.Player);
                }
                MyEntities.OnEntityRemove                        += OnEntityRemove;
                MyAPIGateway.Session.OnSessionReady              += OnSessionReady;
                MyVisualScriptLogicProvider.PlayerDisconnected   += PlayerDisconnected;
                MyVisualScriptLogicProvider.PlayerRespawnRequest += PlayerConnected;
                if (!DedicatedServer)
                {
                    Password          = MyStringId.GetOrCompute(Localization.GetText("TerminalPasswordTitle"));
                    PasswordTooltip   = MyStringId.GetOrCompute(Localization.GetText("TerminalPasswordTooltip"));
                    ShieldFreq        = MyStringId.GetOrCompute(Localization.GetText("TerminalShieldFreqTitle"));
                    ShieldFreqTooltip = MyStringId.GetOrCompute(Localization.GetText("TerminalShieldFreqTooltip"));
                    MyAPIGateway.TerminalControls.CustomControlGetter += CustomControls;
                }

                if (IsServer)
                {
                    Log.Line("LoadConf - Session: This is a server");
                    UtilsStatic.PrepConfigFile();
                    UtilsStatic.ReadConfigFile();
                }

                if (MpActive)
                {
                    SyncDist            = MyAPIGateway.Session.SessionSettings.SyncDistance;
                    SyncDistSqr         = SyncDist * SyncDist;
                    SyncBufferedDistSqr = SyncDistSqr + 250000;
                    if (Enforced.Debug >= 2)
                    {
                        Log.Line($"SyncDistSqr:{SyncDistSqr} - SyncBufferedDistSqr:{SyncBufferedDistSqr} - DistNorm:{SyncDist}");
                    }
                }
                else
                {
                    SyncDist            = MyAPIGateway.Session.SessionSettings.ViewDistance;
                    SyncDistSqr         = SyncDist * SyncDist;
                    SyncBufferedDistSqr = SyncDistSqr + 250000;
                    if (Enforced.Debug >= 2)
                    {
                        Log.Line($"SyncDistSqr:{SyncDistSqr} - SyncBufferedDistSqr:{SyncBufferedDistSqr} - DistNorm:{SyncDist}");
                    }
                }
                WebMonitor();

                if (!IsServer)
                {
                    RequestEnforcement(MyAPIGateway.Multiplayer.MyId);
                }

                foreach (var mod in MyAPIGateway.Session.Mods)
                {
                    if (mod.PublishedFileId == 540003236)
                    {
                        ThyaImages = true;
                    }
                }

                HudNotify = MyAPIGateway.Utilities.CreateNotification("", 2000, "UrlHighlight");;
                if (HandlesInput)
                {
                    MyAPIGateway.Utilities.MessageEntered += ChatMessageSet;
                }

                GenerateButtonMap();
                Settings = new ShieldSettings(this);
            }
            catch (Exception ex) { Log.Line($"Exception in BeforeStart: {ex}"); }
        }
Пример #3
0
        public override void BeforeStart()
        {
            try
            {
                MpActive        = MyAPIGateway.Multiplayer.MultiplayerActive;
                IsServer        = MyAPIGateway.Multiplayer.IsServer;
                DedicatedServer = MyAPIGateway.Utilities.IsDedicated;

                var env = MyDefinitionManager.Static.EnvironmentDefinition;
                if (env.LargeShipMaxSpeed > MaxEntitySpeed)
                {
                    MaxEntitySpeed = env.LargeShipMaxSpeed;
                }
                else if (env.SmallShipMaxSpeed > MaxEntitySpeed)
                {
                    MaxEntitySpeed = env.SmallShipMaxSpeed;
                }

                Log.Init("debugdevelop.log");
                Log.Line($"Logging Started: Server:{IsServer} - Dedicated:{DedicatedServer} - MpActive:{MpActive}");

                MyAPIGateway.Session.DamageSystem.RegisterBeforeDamageHandler(0, CheckDamage);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdShieldHit, ShieldHitReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdEnforce, EnforcementReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdO2GeneratorSettings, O2GeneratorSettingsReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdControllerState, ControllerStateReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdControllerSettings, ControllerSettingsReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdModulatorSettings, ModulatorSettingsReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdModulatorState, ModulatorStateReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdEnhancerState, EnhancerStateReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdO2GeneratorState, O2GeneratorStateReceived);
                MyAPIGateway.Multiplayer.RegisterMessageHandler(PacketIdEmitterState, EmitterStateReceived);

                if (!MpActive)
                {
                    Players.TryAdd(MyAPIGateway.Session.Player.IdentityId, MyAPIGateway.Session.Player);
                }
                MyEntities.OnEntityRemove += OnEntityRemove;

                MyVisualScriptLogicProvider.PlayerDisconnected   += PlayerDisconnected;
                MyVisualScriptLogicProvider.PlayerRespawnRequest += PlayerConnected;
                if (!DedicatedServer)
                {
                    MyAPIGateway.TerminalControls.CustomControlGetter += CustomControls;
                }

                if (IsServer)
                {
                    Log.Line("LoadConf - Session: This is a server");
                    UtilsStatic.PrepConfigFile();
                    UtilsStatic.ReadConfigFile();
                }

                if (MpActive)
                {
                    SyncDist            = MyAPIGateway.Session.SessionSettings.SyncDistance;
                    SyncDistSqr         = SyncDist * SyncDist;
                    SyncBufferedDistSqr = SyncDistSqr + 250000;
                    if (Enforced.Debug >= 2)
                    {
                        Log.Line($"SyncDistSqr:{SyncDistSqr} - SyncBufferedDistSqr:{SyncBufferedDistSqr} - DistNorm:{SyncDist}");
                    }
                }
                else
                {
                    SyncDist            = MyAPIGateway.Session.SessionSettings.ViewDistance;
                    SyncDistSqr         = SyncDist * SyncDist;
                    SyncBufferedDistSqr = SyncDistSqr + 250000;
                    if (Enforced.Debug >= 2)
                    {
                        Log.Line($"SyncDistSqr:{SyncDistSqr} - SyncBufferedDistSqr:{SyncBufferedDistSqr} - DistNorm:{SyncDist}");
                    }
                }
                MyAPIGateway.Parallel.StartBackground(WebMonitor);
            }
            catch (Exception ex) { Log.Line($"Exception in BeforeStart: {ex}"); }
        }