Ejemplo n.º 1
0
        protected override void InitCommon(IModSystemRegistry modSystemRegistry)
        {
            string sInit = "Initialising Wico Research. Version: " + CurrentModVersion;

            MyAPIGateway.Utilities.ShowNotification(sInit, 5000, MyFontEnum.DarkBlue);
            ModLog.Info(sInit);

            if (MyAPIGateway.Session.IsServer)
            {
                MyVisualScriptLogicProvider.SendChatMessage(sInit, "Wicorel", 0, MyFontEnum.DarkBlue);
            }

            bool bResearch = Session.SessionSettings.EnableResearch;

            // This works to change the setting.
            Session.SessionSettings.EnableResearch = true;

            if (!bResearch)
            {
                ModLog.Info("Research was not turned on");
            }

            TextAPI         = new HudAPIv2();
            researchControl = new ResearchControl(audioSystem);
            researchControl.InitResearchRestrictions();
            researchHacking = new ResearchHacking(researchControl, TextAPI, networkComms);
            networkComms.Init(audioSystem, researchControl, researchHacking);
            modSystemRegistry.AddCloseableModSystem(networkComms);
            modSystemRegistry.AddUpatableModSystem(audioSystem);

            MyAPIGateway.Utilities.MessageEntered += MessageEntered;
        }
Ejemplo n.º 2
0
        public override void LoadData()
        {
            Instance = this;

            isCreativeGame = (MyAPIGateway.Session.SessionSettings.GameMode == MyGameModeEnum.Creative);
            isServer       = (MyAPIGateway.Session.OnlineMode == MyOnlineModeEnum.OFFLINE || MyAPIGateway.Multiplayer.IsServer);
            isDedicated    = (MyAPIGateway.Utilities.IsDedicated && isServer);

            MyLog.Default.WriteLineAndConsole($"isCreativeGame: {isCreativeGame}; isServer: {isServer}; isDedicated: {isDedicated}");

            if (!isDedicated)
            {
                HudApi = new HudAPIv2();
                HUD    = new Hud(HudApi);
            }

            if (isServer)
            {
                updateCounter = 0;
                PlayerList    = new List <IMyPlayer>();

                Config          = StorageFile.Load <Config>("config.xml");
                PlayerStatsDict = StorageFile.Load <PlayerStatsStorage>("stats.xml").ToDict();

                MovementCosts.SetFromConfig(Config);
            }
        }
Ejemplo n.º 3
0
        internal ResearchHacking(ResearchControl researchControl, HudAPIv2 hudTextApi, NetworkComms networkComms)
        {
            this.researchControl = researchControl;

            TextAPI = hudTextApi;

            this.networkComms = networkComms;
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Closes the hud api object.
 /// </summary>
 public void Close()
 {
     if (_hudApi != null)
     {
         IsRegistered = false;
         _hudApi.Close();
         _hudApi = null;
     }
 }
Ejemplo n.º 5
0
        private HudUtilities()
        {
            textHudApi = new HudAPIv2();

            fov      = MyAPIGateway.Session.Camera.FovWithZoom;
            fovScale = 0.1 * Math.Tan(fov / 2d);

            hudElementsDraw  = new List <Action>();
            menuElementsInit = new Queue <Action>();
        }
Ejemplo n.º 6
0
        public Hud(HudAPIv2 api)
        {
            HudApi = api;

            stamina       = 0;
            refreshNeeded = false;

            noColor = new Color(new Vector4(0.0f, 0.0f, 0.0f, 0.0f));

            colorString = "";
        }
Ejemplo n.º 7
0
        private void Init()
        {
            _textAPI = new HudAPIv2();

            if (Utils.isDev())
            {
                MyAPIGateway.Utilities.ShowMessage("CLIENT", "INIT");
            }

            MyAPIGateway.Utilities.MessageEntered += OnMessageEntered;
            MyAPIGateway.Multiplayer.RegisterMessageHandler(1337, FoodUpdateMsgHandler);
        }
Ejemplo n.º 8
0
        public ToolGroups()
        {
            welder = new WelderTool(MyKeys.None, 0, 0);
            ToolEdited(welder, false);
            grinder = new GrinderTool(MyKeys.None, 1, 0);
            ToolEdited(grinder, false);
            drill = new DrillTool(MyKeys.None, 2, 0);
            ToolEdited(drill, false);
            pistol = new PistolTool(MyKeys.None, 3, 0);
            ToolEdited(pistol, false);
            launcher = new LauncherTool(MyKeys.None, 3, 0);
            ToolEdited(launcher, false);
            rifle = new RifleTool(MyKeys.None, 3, 0);
            ToolEdited(rifle, false);


            foreach (MyHandItemDefinition def in MyDefinitionManager.Static.GetHandItemDefinitions())
            {
                if (!def.Context.IsBaseGame)
                {
                    string modName = def.Context.ModName;
                    if (string.IsNullOrWhiteSpace(modName))
                    {
                        if (string.IsNullOrWhiteSpace(def.Context.ModId))
                        {
                            modName = null;
                        }
                        else
                        {
                            modName = def.Context.ModId.Trim();
                        }
                    }
                    else
                    {
                        modName = modName.Trim();
                    }

                    if (modName != null && modName.Length > 30)
                    {
                        modName = modName.Substring(0, 30);
                    }

                    ModTool modTool = new ModTool(MyKeys.None, 0, 0, def.PhysicalItemId, modName);
                    modTools.Add(modTool);
                    ToolEdited(modTool, false);
                }
            }
            serializableTools = modTools.ToArray();

            hud = new HudAPIv2(OnHudReady);
        }
Ejemplo n.º 9
0
        internal ResearchHacking(ResearchControl researchControl, HudAPIv2 hudTextApi, NetworkComms networkComms)
        {
            this.researchControl = researchControl;

            /*
             * // V1
             * hackBar.options |= HUDTextAPI.Options.HideHud;
             *          hackInterrupted.options |= HUDTextAPI.Options.HideHud;
             *          this.hudTextApi = hudTextApi;
             */

            //V2
            TextAPI = hudTextApi;

            this.networkComms = networkComms;
        }
Ejemplo n.º 10
0
        public void Init()
        {
            if (init)
            {
                return;                  //script already initialized, abort.
            }
            instance    = this;
            init        = true;
            running     = true;
            isServer    = MyAPIGateway.Session.OnlineMode == MyOnlineModeEnum.OFFLINE || MyAPIGateway.Multiplayer.IsServer;
            isDedicated = (MyAPIGateway.Utilities.IsDedicated && isServer);
            if (isDedicated)
            {
                return;
            }

            TextAPI = new HudAPIv2();
        }
Ejemplo n.º 11
0
        public override void Init(MyObjectBuilder_SessionComponent sessionComponent)
        {
            if (init)
            {
                return;
            }
            base.Init(sessionComponent);

            Instance = this;
            HudAPI   = new HudAPIv2();

            init     = true;
            running  = true;
            isServer = (MyAPIGateway.Multiplayer.IsServer && MyAPIGateway.Utilities.IsDedicated);
            if (!isServer)
            {
                SetUpdateOrder(MyUpdateOrder.AfterSimulation);
            }
        }
Ejemplo n.º 12
0
        internal ResearchHacking(ResearchControl researchControl, HudAPIv2 hudTextApi, NetworkComms networkComms)
        {
            this.researchControl = researchControl;

            /*
             * // V1
             * hackBar.options |= HUDTextAPI.Options.HideHud;
             *          hackInterrupted.options |= HUDTextAPI.Options.HideHud;
             *          this.hudTextApi = hudTextApi;
             */

            //V2
            TextAPI = hudTextApi;

            this.networkComms = networkComms;

            ConnectionLostID = MyStringId.TryGet("ConnectionLost");

            HackInProgressID = MyStringId.TryGet("HackInProgress");
            //            string sInit = VRage.MyTexts.Get(stringIdInit).ToString() + " " + CurrentModVersion;
        }
Ejemplo n.º 13
0
        public void Start(HudAPIv2 api)
        {
            debugText = new HUDMessage();
            debugText.InitialColor = Color.Yellow;
            debugText.Message      = DebugString;
            debugText.Font         = "monospace";

            var boxdef = HudAPIv2.APIinfo.GetBoxUIDefinition(MyStringId.GetOrCompute("Default"));

            debugUI = new BoxUIText();
            debugUI.SetDefinition(boxdef);
            debugUI.Origin = new Vector2I(-340, 0);
            debugUI.Width  = 340;
            debugUI.SetTextContent(debugText);
            debugUI.Visible         = true;
            debugUI.Height          = 9 * 13 + boxdef.Min.X;
            debugUI.BackgroundColor = Color.White * 0.2f;


            debugText.Scale = 10;             //10pt
            debugText.Blend = BlendTypeEnum.PostPP;
        }
Ejemplo n.º 14
0
        public override void UpdateAfterSimulation()
        {
            debugMonitor.Update();
            if (!init)
            {
                HudAPI = new HudAPIv2(RegisterHudAPI);

                init    = true;
                offline = MyAPIGateway.Session.OnlineMode == VRage.Game.MyOnlineModeEnum.OFFLINE;
                if (!offline)
                {
                    MyAPIGateway.Multiplayer.RegisterMessageHandler(COMID, UpdateChannelRecieve);
                }
                isServer    = offline || MyAPIGateway.Multiplayer.IsServer;
                isDedicated = isServer && MyAPIGateway.Utilities.IsDedicated;
                time.Start();
            }

            foreach (var controller in controllers)
            {
                controller.Value.SendUpdate(time.ElapsedTicks);
            }
        }
Ejemplo n.º 15
0
 public void Init()
 {
     api_handle_ = new HudAPIv2(OnHudInit);
 }
Ejemplo n.º 16
0
 private void Init()
 {
     hudApIv2 = new HudAPIv2();
     MyAPIGateway.Utilities.MessageEntered += ChatCommands;
     _logging.WriteLine("Cross hair mod initialized");
 }
Ejemplo n.º 17
0
        public override void Start()
        {
            base.Start();

            _textApi = new HudAPIv2(OnRegisteredCallback);
        }
Ejemplo n.º 18
0
        protected override void InitCommon(IModSystemRegistry modSystemRegistry)
        {
            var    stringIdInit = MyStringId.TryGet("Init");
            string sInit        = VRage.MyTexts.Get(stringIdInit).ToString() + " " + CurrentModVersion;

            var    TranslationByID = MyStringId.TryGet("TranslationBy");
            string sTranslationBy  = VRage.MyTexts.Get(TranslationByID).ToString();

            if (!string.IsNullOrWhiteSpace(sTranslationBy))
            {
                sInit += "\n  " + sTranslationBy;
            }

            var    AudioByID = MyStringId.TryGet("AudioBy");
            string sAudioBy  = VRage.MyTexts.Get(AudioByID).ToString();

            if (!string.IsNullOrWhiteSpace(sAudioBy))
            {
                sInit += "\n  " + sAudioBy;
            }
            //            string sInit = "Initialising Escape From Mars build " + CurrentModVersion;

            MyAPIGateway.Utilities.ShowNotification(sInit, 5000, MyFontEnum.DarkBlue);
            ModLog.Info(sInit);
            MyLog.Default.Info("EFM Init" + sInit);

//            var gamelanguage = MySpaceTexts.ToolTipOptionsGame_Language;
            var gamelanguage = MyAPIGateway.Session.Config.Language;

            ModLog.Info("Game Language=" + gamelanguage.ToString());

            /*
             * var idString1=MyStringId.TryGet("String1");
             * var String1=VRage.MyTexts.Get(idString1);
             * ModLog.Info("idString1=" + idString1);
             * ModLog.Info("String1=" + String1);
             */

            if (MyAPIGateway.Session.IsServer)
            {
                MyVisualScriptLogicProvider.SendChatMessage(sInit, "Wicorel", 0, MyFontEnum.DarkBlue);
            }

            gameVersion = MyAPIGateway.Session.Version;
            ModLog.Info("SE Version=" + gameVersion.ToString());

            /*
             * ModLog.Info(" Major=" + gameVersion.Major.ToString());
             * ModLog.Info(" MajorRevision=" + gameVersion.MajorRevision.ToString());
             * ModLog.Info(" Minor=" + gameVersion.Minor.ToString());
             * ModLog.Info(" MinorRevision=" + gameVersion.MinorRevision.ToString());
             * ModLog.Info(" Build=" + gameVersion.Build.ToString());
             */
            /*
             * // TESTING: (they seem to be the same)
             * if (MyAPIGateway.Session.IsServer)
             *  ModLog.Info("MyAPIGateway.Session.IsServer.IsServer");
             * else
             *  ModLog.Info("MyAPIGateway.Session.NOT Server");
             * if (MyAPIGateway.Multiplayer.IsServer)
             *  ModLog.Info("MyAPIGateway.Multiplayer.IsServer");
             * else
             *  ModLog.Info("MyAPIGateway.Multiplayer.NOT Server");
             */
            bool bResearch = Session.SessionSettings.EnableResearch;

            // This works to change the setting.
            Session.SessionSettings.EnableResearch = true;

            Session.SessionSettings.EnableBountyContracts = false; // SE V1.192

            if ((gameVersion.Major == 1 && gameVersion.Minor >= 192) || gameVersion.Major > 1)
            {
                ModLog.Info("Economy items enabled");
                CargoType.AllowEconomyItems();
            }
            if ((gameVersion.Major == 1 && gameVersion.Minor >= 198) || gameVersion.Major > 1)
            {
                ModLog.Info("Warefare1 items enabled");
                CargoType.AllowWarefare1Items();
            }
            if ((gameVersion.Major == 1 && gameVersion.Minor >= 200) || gameVersion.Major > 1)
            {
                ModLog.Info("Warefare2 items enabled");
                CargoType.AllowWarefare2Items();
            }

            if (!bResearch)
            {
//                MyAPIGateway.Utilities.ShowNotification("Save, then Exit. Edit world /Advanced settings and Enable progression", 50000, MyFontEnum.Red);
                ModLog.Info("Research was not turned on");
            }
            TextAPI = new HudAPIv2();
//            if (modBuildWhenGameStarted > 4) V37
            {
                DuckUtils.PutPlayerIntoFaction("CRASH");
            }
            researchControl = new ResearchControl(audioSystem);
            researchControl.InitResearchRestrictions();
            researchHacking = new ResearchHacking(researchControl, TextAPI, networkComms);
            networkComms.Init(audioSystem, researchControl, researchHacking);
            modSystemRegistry.AddCloseableModSystem(networkComms);
            modSystemRegistry.AddUpatableModSystem(audioSystem);

            MyAPIGateway.Utilities.MessageEntered += MessageEntered;
        }
Ejemplo n.º 19
0
 protected override void RegisterComponent()
 {
     api = new HudAPIv2(TextAPIDetected);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Clean up references when exiting game.
 /// </summary>
 public void Unload()
 {
     // we didn't initialise this, so don't unload it either
     HudApi = null;
 }
Ejemplo n.º 21
0
 public GuiHandler()
 {
     _hudApi = new HudAPIv2(OnHudApiRegistered);
 }
Ejemplo n.º 22
0
 void InitializableModule.Init()
 {
     HudAPI = new HudAPIv2();
     CheckForHudAPIInModlist();
 }
Ejemplo n.º 23
0
 protected override void UnregisterComponent()
 {
     api?.Close();
     api = null;
 }
Ejemplo n.º 24
0
 public SettingsHud()
 {
     hud    = new HudAPIv2(OnHudReady);
     config = IPSession.Instance.MapSettings;
 }
Ejemplo n.º 25
0
        protected override void InitCommon(IModSystemRegistry modSystemRegistry)
        {
            string sInit = "Initialising Escape From Mars build " + CurrentModVersion;

            MyAPIGateway.Utilities.ShowNotification(sInit, 5000, MyFontEnum.DarkBlue);
            ModLog.Info(sInit);

            if (MyAPIGateway.Session.IsServer)
            {
                MyVisualScriptLogicProvider.SendChatMessage(sInit, "Wicorel", 0, MyFontEnum.DarkBlue);
            }

            gameVersion = MyAPIGateway.Session.Version;
            ModLog.Info("SE Version=" + gameVersion.ToString());

            /*
             * ModLog.Info(" Major=" + gameVersion.Major.ToString());
             * ModLog.Info(" MajorRevision=" + gameVersion.MajorRevision.ToString());
             * ModLog.Info(" Minor=" + gameVersion.Minor.ToString());
             * ModLog.Info(" MinorRevision=" + gameVersion.MinorRevision.ToString());
             * ModLog.Info(" Build=" + gameVersion.Build.ToString());
             */
            /*
             * // TESTING: (they seem to be the same)
             * if (MyAPIGateway.Session.IsServer)
             *  ModLog.Info("MyAPIGateway.Session.IsServer.IsServer");
             * else
             *  ModLog.Info("MyAPIGateway.Session.NOT Server");
             * if (MyAPIGateway.Multiplayer.IsServer)
             *  ModLog.Info("MyAPIGateway.Multiplayer.IsServer");
             * else
             *  ModLog.Info("MyAPIGateway.Multiplayer.NOT Server");
             */
            bool bResearch = Session.SessionSettings.EnableResearch;

            // This works to change the setting.
            Session.SessionSettings.EnableResearch = true;

            Session.SessionSettings.EnableBountyContracts = false; // SE V1.192

            if ((gameVersion.Major == 1 && gameVersion.Minor >= 192) || gameVersion.Major > 1)
            {
                ModLog.Info("Economy items enabled");
                CargoType.AllowEconomyItems();
            }

            if (!bResearch)
            {
//                MyAPIGateway.Utilities.ShowNotification("Save, then Exit. Edit world /Advanced settings and Enable progression", 50000, MyFontEnum.Red);
                ModLog.Info("Research was not turned on");
            }
            TextAPI = new HudAPIv2();
            if (modBuildWhenGameStarted > 4)
            {
                DuckUtils.PutPlayerIntoFaction("CRASH");
            }
            researchControl = new ResearchControl(audioSystem);
            researchControl.InitResearchRestrictions();
            researchHacking = new ResearchHacking(researchControl, TextAPI, networkComms);
            networkComms.Init(audioSystem, researchControl, researchHacking);
            modSystemRegistry.AddCloseableModSystem(networkComms);
            modSystemRegistry.AddUpatableModSystem(audioSystem);

            MyAPIGateway.Utilities.MessageEntered += MessageEntered;
        }