Beispiel #1
0
 public override void Close()
 {
     try
     {
         if (SessionCore.Settings.Debug)
         {
             DebugNote.Hide();
             DebugNote.AliveTime = 0;
             DebugNote           = null;
         }
     }
     catch (Exception Scrap)
     {
         SessionCore.LogError($"{Tool.CustomName}.Close().DebugClose", Scrap);
     }
     try
     {
         HUDModule.Close();
         PersistenceModule.Close();
         TermModule.Close();
         GridInventoryModule.RemoveWatcher(Tool);
     }
     catch (Exception Scrap)
     {
         SessionCore.LogError($"{Tool.CustomName}.Close()", Scrap);
     }
 }
Beispiel #2
0
        public override void UpdateOnceBeforeFrame()
        {
            try
            {
                if (!Networker.Inited)
                {
                    Networker.Init(SessionCore.ModID);
                }
                try
                {
                    if (Tool.CubeGrid.Physics?.Enabled != true)
                    {
                        NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
                        return;
                    }
                }
                catch (Exception Scrap)
                {
                    SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().PhysicsCheck", Scrap);
                }


                try
                {
                    ToolCargo = Tool.GetInventory();
                }
                catch (Exception Scrap)
                {
                    SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().GetInventory", Scrap);
                }

                try
                {
                    TermModule.Init();
                }
                catch (Exception Scrap)
                {
                    SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().TermModuleInit", Scrap);
                }

                try
                {
                    PersistenceModule.Init();
                }
                catch (Exception Scrap)
                {
                    SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().PersistenceModuleInit", Scrap);
                }

                try
                {
                    PersistenceModule.Load();
                }
                catch (Exception Scrap)
                {
                    SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().PersistenceModuleLoad", Scrap);
                }

                try
                {
                    GridInventoryModule = ToolGrid.GetComponent <GridInventories>();
                    if (IsWelder)
                    {
                        GridInventoryModule.AddWatcher(Tool);
                    }
                }
                catch (Exception Scrap)
                {
                    SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().InventoryModule", Scrap);
                }

                try
                {
                    HUDModule.Init();
                }
                catch (Exception Scrap)
                {
                    SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame().HudModule", Scrap);
                }

                if (IsWelder && MyAPIGateway.Session.LocalHumanPlayer?.IdentityId == Tool.OwnerId)
                {
                    MissingHUD = MyAPIGateway.Utilities.CreateNotification("", int.MaxValue, "Red");
                }

                CheckInitControls();
                NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
                Tool.AppendingCustomInfo += Tool_AppendingCustomInfo;
                DebugNote = MyAPIGateway.Utilities.CreateNotification($"{Tool.CustomName}", int.MaxValue, (IsWelder ? "Blue" : "Red"));
                Owner     = MyAPIGateway.Players.GetPlayer(Tool.OwnerId);
                if (SessionCore.Settings.Debug)
                {
                    DebugNote.Show();
                }
            }
            catch (Exception Scrap)
            {
                SessionCore.LogError($"{Tool.CustomName}.OnceBeforeFrame()", Scrap);
            }
        }