Пример #1
0
 public VersionControl(ShieldSettings core)
 {
     Core = core;
 }
Пример #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}"); }
        }