internal void OpenWheel()
        {
            WheelActive = true;
            if (HudNotify == null)
            {
                HudNotify = MyAPIGateway.Utilities.CreateNotification("[Grids]", 160, "UrlHighlight");
            }
            if (string.IsNullOrEmpty(_currentMenu))
            {
                _currentMenu = "CompGroups";
                var menu = GetCurrentMenu();
                var item = GetCurrentMenuItem();
                UpdateState(menu, item, Update.None);
            }
            Ai.SupressMouseShoot = true;
            var controlStringLeft = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Left).GetGameControlEnum().String;

            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringLeft, Ai.Session.PlayerId, false);
            var controlStringRight = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Right).GetGameControlEnum().String;

            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringRight, Ai.Session.PlayerId, false);
            var controlStringMiddle = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Middle).GetGameControlEnum().String;

            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringMiddle, Ai.Session.PlayerId, false);
        }
Beispiel #2
0
        private void BlackList2(bool activate)
        {
            try
            {
                var numPad0 = MyAPIGateway.Input.GetControl(MyKeys.NumPad0);
                var numPad1 = MyAPIGateway.Input.GetControl(MyKeys.NumPad1);
                var numPad2 = MyAPIGateway.Input.GetControl(MyKeys.NumPad2);
                var numPad3 = MyAPIGateway.Input.GetControl(MyKeys.NumPad3);
                var numPad4 = MyAPIGateway.Input.GetControl(MyKeys.NumPad4);
                var numPad5 = MyAPIGateway.Input.GetControl(MyKeys.NumPad5);
                var numPad6 = MyAPIGateway.Input.GetControl(MyKeys.NumPad6);
                var numPad7 = MyAPIGateway.Input.GetControl(MyKeys.NumPad7);
                var numPad8 = MyAPIGateway.Input.GetControl(MyKeys.NumPad8);
                var numPad9 = MyAPIGateway.Input.GetControl(MyKeys.NumPad9);

                if (numPad0 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad0.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad1 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad1.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad2 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad2.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad3 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad3.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad4 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad4.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad5 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad5.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad6 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad6.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad7 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad7.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad8 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad8.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (numPad9 != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(numPad9.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                BlackListActive2 = activate;
            }
            catch (Exception ex) { Log.Line($"Exception in BlackList2: {ex}"); }
        }
Beispiel #3
0
        private void BlackList1(bool activate)
        {
            try
            {
                var upKey      = MyAPIGateway.Input.GetControl(MyKeys.Up);
                var downKey    = MyAPIGateway.Input.GetControl(MyKeys.Down);
                var leftKey    = MyAPIGateway.Input.GetControl(MyKeys.Left);
                var rightkey   = MyAPIGateway.Input.GetControl(MyKeys.Right);
                var addKey     = MyAPIGateway.Input.GetControl(MyKeys.Add);
                var subKey     = MyAPIGateway.Input.GetControl(MyKeys.Subtract);
                var actionKey  = MyAPIGateway.Input.GetControl(MyKeys.NumPad0);
                var controlKey = MyAPIGateway.Input.GetControl(MyKeys.R);
                var detailKey  = MyAPIGateway.Input.GetControl(MyKeys.Decimal);

                if (upKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(upKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (downKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(downKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (leftKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(leftKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (rightkey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(rightkey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (addKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(addKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                if (subKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(subKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }

                if (actionKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(actionKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }

                if (controlKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }

                if (detailKey != null)
                {
                    MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(detailKey.GetGameControlEnum().String, _session.PlayerId, !activate);
                }
                BlackListActive1 = activate;
            }
            catch (Exception ex) { Log.Line($"Exception in BlackList1: {ex}"); }
        }
Beispiel #4
0
 private static void SetBlacklist(IReadOnlyList <string> IDs, bool value)
 {
     if (MyAPIGateway.Session?.Player != null)
     {
         foreach (string control in IDs)
         {
             MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(control, MyAPIGateway.Session.Player.IdentityId, !value);
         }
     }
 }
        internal void CloseWheel()
        {
            WheelActive          = false;
            Ai.SupressMouseShoot = false;
            var controlStringLeft = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Left).GetGameControlEnum().String;

            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringLeft, Ai.Session.PlayerId, true);
            var controlStringRight = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Right).GetGameControlEnum().String;

            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringRight, Ai.Session.PlayerId, true);
            var controlStringMiddle = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Middle).GetGameControlEnum().String;

            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringMiddle, Ai.Session.PlayerId, true);
            Session.RemoveGps();
        }
Beispiel #6
0
        internal void EntityControlUpdate()
        {
            var lastControlledEnt = ControlledEntity;

            ControlledEntity = (MyEntity)MyAPIGateway.Session.ControlledObject;

            var entityChanged = lastControlledEnt != null && lastControlledEnt != ControlledEntity;

            if (entityChanged)
            {
                if (lastControlledEnt is MyCockpit || lastControlledEnt is MyRemoteControl)
                {
                    PlayerControlAcquired(lastControlledEnt);
                }

                if (ControlledEntity is MyCockpit || ControlledEntity is MyRemoteControl)
                {
                    PlayerControlNotify(ControlledEntity);
                }

                if (ControlledEntity is IMyGunBaseUser && !(lastControlledEnt is IMyGunBaseUser))
                {
                    var    cube = (MyCubeBlock)ControlledEntity;
                    GridAi gridAi;
                    if (GridTargetingAIs.TryGetValue(cube.CubeGrid, out gridAi))
                    {
                        CoreComponent comp;
                        if (gridAi.WeaponBase.TryGetValue(cube, out comp))
                        {
                            GunnerBlackList = true;
                            if (IsServer)
                            {
                                comp.Data.Repo.Base.State.PlayerId = PlayerId;
                                comp.Data.Repo.Base.State.Control  = ControlMode.Camera;
                            }
                            ActiveControlBlock = (MyCubeBlock)ControlledEntity;
                            var controlStringLeft = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Left).GetGameControlEnum().String;
                            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringLeft, PlayerId, false);
                            var controlStringRight = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Right).GetGameControlEnum().String;
                            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringRight, PlayerId, false);
                            var controlStringMenu = MyAPIGateway.Input.GetControl(UiInput.MouseButtonMenu).GetGameControlEnum().String;
                            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringMenu, PlayerId, false);

                            if (HandlesInput && MpActive)
                            {
                                SendPlayerControlRequest(comp, PlayerId, ControlMode.Camera);
                            }
                        }
                    }
                }
                else if (!(ControlledEntity is IMyGunBaseUser) && lastControlledEnt is IMyGunBaseUser)
                {
                    if (GunnerBlackList)
                    {
                        GunnerBlackList = false;
                        var controlStringLeft = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Left).GetGameControlEnum().String;
                        MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringLeft, PlayerId, true);
                        var controlStringRight = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Right).GetGameControlEnum().String;
                        MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringRight, PlayerId, true);
                        var controlStringMenu = MyAPIGateway.Input.GetControl(UiInput.MouseButtonMenu).GetGameControlEnum().String;
                        MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringMenu, PlayerId, true);
                        var    oldCube = lastControlledEnt as MyCubeBlock;
                        GridAi gridAi;
                        if (oldCube != null && GridTargetingAIs.TryGetValue(oldCube.CubeGrid, out gridAi))
                        {
                            CoreComponent comp;
                            if (gridAi.WeaponBase.TryGetValue(oldCube, out comp))
                            {
                                if (IsServer)
                                {
                                    comp.Data.Repo.Base.State.PlayerId = -1;
                                    comp.Data.Repo.Base.State.Control  = ControlMode.None;
                                }

                                if (HandlesInput && MpActive)
                                {
                                    SendPlayerControlRequest(comp, -1, ControlMode.None);
                                }

                                ActiveControlBlock = null;
                            }
                        }
                    }
                }
            }
        }
        internal void EntityControlUpdate()
        {
            var lastControlledEnt = ControlledEntity;

            ControlledEntity = (MyEntity)MyAPIGateway.Session.ControlledObject;

            var entityChanged = lastControlledEnt != null && lastControlledEnt != ControlledEntity;

            if (entityChanged)
            {
                if (lastControlledEnt is MyCockpit || lastControlledEnt is MyRemoteControl)
                {
                    PlayerControlAcquired(lastControlledEnt);
                }

                if (ControlledEntity is IMyGunBaseUser && !(lastControlledEnt is IMyGunBaseUser))
                {
                    var    cube = (MyCubeBlock)ControlledEntity;
                    GridAi gridAi;
                    if (GridTargetingAIs.TryGetValue(cube.CubeGrid, out gridAi))
                    {
                        WeaponComponent comp;
                        if (gridAi.WeaponBase.TryGetValue(cube, out comp))
                        {
                            GunnerBlackList = true;
                            comp.State.Value.CurrentPlayerControl.PlayerId    = PlayerId;
                            comp.State.Value.CurrentPlayerControl.ControlType = ControlType.Camera;
                            ActiveControlBlock = (MyCubeBlock)ControlledEntity;
                            var controlStringLeft = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Left).GetGameControlEnum().String;
                            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringLeft, PlayerId, false);
                            var controlStringRight = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Right).GetGameControlEnum().String;
                            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringRight, PlayerId, false);
                            var controlStringMiddle = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Middle).GetGameControlEnum().String;
                            MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringMiddle, PlayerId, false);

                            if (HandlesInput && MpActive)
                            {
                                SendControlingPlayer(comp);
                            }
                        }
                    }
                }
                else if (!(ControlledEntity is IMyGunBaseUser) && lastControlledEnt is IMyGunBaseUser)
                {
                    if (GunnerBlackList)
                    {
                        GunnerBlackList = false;
                        var controlStringLeft = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Left).GetGameControlEnum().String;
                        MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringLeft, PlayerId, true);
                        var controlStringRight = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Right).GetGameControlEnum().String;
                        MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringRight, PlayerId, true);
                        var controlStringMiddle = MyAPIGateway.Input.GetControl(MyMouseButtonsEnum.Middle).GetGameControlEnum().String;
                        MyVisualScriptLogicProvider.SetPlayerInputBlacklistState(controlStringMiddle, PlayerId, true);
                        var    oldCube = lastControlledEnt as MyCubeBlock;
                        GridAi gridAi;
                        if (oldCube != null && GridTargetingAIs.TryGetValue(oldCube.CubeGrid, out gridAi))
                        {
                            WeaponComponent comp;
                            if (gridAi.WeaponBase.TryGetValue(oldCube, out comp))
                            {
                                comp.State.Value.CurrentPlayerControl.PlayerId    = -1;
                                comp.State.Value.CurrentPlayerControl.ControlType = ControlType.None;
                                ActiveControlBlock = null;
                            }
                        }
                    }
                }
            }
        }