Пример #1
0
        //private void SettingsRequest(ulong steamid)
        //{
        //	NetSettings.SetValue(Settings.Static);

        //	Tools.Debug(MyAPIGateway.Utilities.SerializeToXML(Settings.Static));

        //}

        private void Changed(VRage.Game.ModAPI.Interfaces.IMyControllableEntity o, VRage.Game.ModAPI.Interfaces.IMyControllableEntity n)
        {
            foreach (WeaponBase w in GridWeapons)
            {
                w.State.Value &= ~WeaponState.ManualShoot;
            }

            GridWeapons.Clear();
            ControlledGridId = 0;

            ActiveTurret = n?.Entity as IMyLargeTurretBase;

            if (ActiveTurret == null)
            {
                ActiveShipController = n?.Entity as IMyShipController;
                SelectedDefinitionId = Tools.GetSelectedHotbarDefinition(ActiveShipController);
            }

            MyCubeGrid grid = (n?.Entity as MyCubeBlock)?.CubeGrid;

            if (grid != null)
            {
                ControlledGridId = grid.EntityId;
                foreach (MyCubeBlock block in grid.GetFatBlocks())
                {
                    WeaponControlLayer layer = block.GameLogic.GetAs <WeaponControlLayer>();

                    if (layer != null)
                    {
                        GridWeapons.Add(layer.Weapon);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Called when game logic is added to container
        /// </summary>
        public virtual void Init(WeaponControlLayer layer)
        {
            ControlLayer = layer;
            CubeBlock    = (MyCubeBlock)layer.Entity;
            //Targeting = ;
            Block      = CubeBlock as IMyFunctionalBlock;
            gun        = CubeBlock as IMyGunObject <MyGunBase>;
            IsFixedGun = CubeBlock is IMySmallGatlingGun;

            PrimaryEmitter   = new MyEntity3DSoundEmitter(CubeBlock, useStaticList: true);
            SecondaryEmitter = new MyEntity3DSoundEmitter(CubeBlock, useStaticList: true);
            InitializeSound();

            Initialized = true;
        }
Пример #3
0
        public void HandleInputs()
        {
            if (MyAPIGateway.Gui.IsCursorVisible)
            {
                return;
            }

            if (ActiveShipController != null)
            {
                List <MyKeys> keys = new List <MyKeys>();
                MyAPIGateway.Input.GetPressedKeys(keys);

                foreach (var key in keys)
                {
                    if (key == MyKeys.D1 ||
                        key == MyKeys.D2 ||
                        key == MyKeys.D3 ||
                        key == MyKeys.D4 ||
                        key == MyKeys.D5 ||
                        key == MyKeys.D6 ||
                        key == MyKeys.D7 ||
                        key == MyKeys.D8 ||
                        key == MyKeys.D9)
                    {
                        SelectedDefinitionId = Tools.GetSelectedHotbarDefinition(ActiveShipController);
                    }
                }
            }

            if (MyAPIGateway.Input.IsNewPrimaryButtonPressed())
            {
                Tools.Debug("primary key pressed");
                if (ActiveTurret != null)
                {
                    WeaponControlLayer layer = ActiveTurret.GameLogic.GetAs <WeaponControlLayer>();
                    layer.Weapon.State.Value |= WeaponState.ManualShoot;
                }
                else
                {
                    Tools.Debug($"looping over {GridWeapons.Count} weapons");
                    foreach (WeaponBase w in GridWeapons)
                    {
                        if (SelectedDefinitionId == w.WeaponDefinition)
                        {
                            w.State.Value |= WeaponState.ManualShoot;
                        }
                    }
                }
            }

            if (MyAPIGateway.Input.IsNewPrimaryButtonReleased())
            {
                Tools.Debug("primary key released");
                if (ActiveTurret != null)
                {
                    WeaponControlLayer layer = ActiveTurret.GameLogic.GetAs <WeaponControlLayer>();
                    layer.Weapon.State.Value &= ~WeaponState.ManualShoot;
                }
                else
                {
                    foreach (WeaponBase w in GridWeapons)
                    {
                        if (SelectedDefinitionId == w.WeaponDefinition)
                        {
                            w.State.Value &= ~WeaponState.ManualShoot;
                        }
                    }
                }
            }
        }