Exemplo n.º 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);
     }
 }
Exemplo n.º 2
0
        void ComplainUnbuilt()
        {
            if (!UnbuiltBlocks.Any())
            {
                //SessionCore.DebugWrite(Tool.CustomName, $"ComplainUnbuilt() early exit - 0 unbuilt", WriteOnlyIfDebug: true);
                return;
            }

            //SessionCore.DebugWrite(Tool.CustomName, $"ComplainUnbuilt()");
            Dictionary <string, int> TotalMissingList = new Dictionary <string, int>();
            Dictionary <IMySlimBlock, Dictionary <string, int> > MissingPerBlock = new Dictionary <IMySlimBlock, Dictionary <string, int> >();

            UnbuiltBlocks.ReadMissingComponents(TotalMissingList, MissingPerBlock);
            //SessionCore.DebugWrite($"{Tool.CustomName}", $"Total missing: {TotalMissingList.Values.Sum()} components", WriteOnlyIfDebug: true);
            //SessionCore.DebugWrite($"{Tool.CustomName}", $"Pull failed");
            HUDModule.ComplainMissing(MissingPerBlock);
            UnbuiltBlocks.Clear();
        }
Exemplo n.º 3
0
    void InitModules()
    {
        Anim  = new AnimationModule(this);      //动作控制模块
        Move  = new MoveModule(this);           //移动模块
        Skill = new SkillModule(this);          //技能模块

        Hud         = new HUDModule(this);      //角色头顶信息模块
        Property    = new PropertyModule(this); //属性模块
        Buff        = new BuffModule(this);     //Buff 模块
        Render      = new RenderModule(this);   //渲染模块
        AI          = new AIModule(this);
        _moduleList = new List <ModuleBase>()
        {
            Anim,
            Move,
            Skill,
            Hud,
            Property,
            Buff,
            Render,
            AI
        };
    }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        protected override void Initialize()
        {
            InputModules = new List<IGameplayModule>();
            GraphicalModules = new List<IGameplayModule>();

            base.Initialize(); // (calls LoadContent)

            Camera = new Camera(GraphicsDevice.Viewport.AspectRatio, 70.0f, 0.1f, 1000.0f);
            UpdateCamera();

            White1x1 = new Texture2D(GraphicsDevice, 1, 1);
            White1x1.SetData<Color>(new[] { Color.White });

            Audio = new AudioManager();
            Audio.LoadDefaultPacks(Content);

            SkyModule = new SkyModule(this);
            ChunkModule = new ChunkModule(this);
            DebugInfoModule = new DebugInfoModule(this, Pixel);
            ChatModule = new ChatModule(this, Pixel);
            var hud = new HUDModule(this, Pixel);
            var windowModule = new WindowModule(this, Pixel);

            GraphicalModules.Add(SkyModule);
            GraphicalModules.Add(ChunkModule);
            GraphicalModules.Add(new HighlightModule(this));
            GraphicalModules.Add(hud);
            GraphicalModules.Add(ChatModule);
            GraphicalModules.Add(windowModule);
            GraphicalModules.Add(DebugInfoModule);

            InputModules.Add(windowModule);
            InputModules.Add(DebugInfoModule);
            InputModules.Add(ChatModule);
            InputModules.Add(new HUDModule(this, Pixel));
            InputModules.Add(ControlModule = new PlayerControlModule(this));

            Client.PropertyChanged += HandleClientPropertyChanged;
            Client.Connect(EndPoint);

            BlockProvider.BlockRepository = BlockRepository;
            var itemRepository = new ItemRepository();
            itemRepository.DiscoverItemProviders();
            ItemRepository = itemRepository;
            BlockProvider.ItemRepository = ItemRepository;

            IconRenderer.CreateBlocks(this, BlockRepository);

            var centerX = GraphicsDevice.Viewport.Width / 2;
            var centerY = GraphicsDevice.Viewport.Height / 2;
            Mouse.SetPosition(centerX, centerY);

            MouseComponent.Scroll += OnMouseComponentScroll;
            MouseComponent.Move += OnMouseComponentMove;
            MouseComponent.ButtonDown += OnMouseComponentButtonDown;
            MouseComponent.ButtonUp += OnMouseComponentButtonUp;
            KeyboardComponent.KeyDown += OnKeyboardKeyDown;
            KeyboardComponent.KeyUp += OnKeyboardKeyUp;
            GamePadComponent.ButtonDown += OnGamePadButtonDown;
            GamePadComponent.ButtonUp += OnGamePadButtonUp;

            CreateRenderTarget();
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            ThreadID = Thread.CurrentThread.ManagedThreadId;
        }