MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
        {
            switch (actionEnum)
            {
                case UseActionEnum.Manipulate:
                    return new MyActionDescription()
                    {
                        Text = MySpaceTexts.NotificationHintPressToRechargeInMedicalRoom,
                        FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.USE) },
                        IsTextControlHint = true,
                        JoystickFormatParams = new object[] { MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE) },
                    };

                case UseActionEnum.OpenTerminal:
                    return new MyActionDescription()
                    {
                        Text = MySpaceTexts.NotificationHintPressToOpenTerminal,
                        FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) },
                        IsTextControlHint = true,
                        JoystickText = MySpaceTexts.NotificationHintJoystickPressToOpenTerminal,
                    };

                default:
                    Debug.Fail("Invalid branch reached.");
                    return new MyActionDescription()
                    {
                        Text = MySpaceTexts.NotificationHintPressToOpenTerminal,
                        FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) },
                        IsTextControlHint = true
                    };
            }
        }
        public override void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user = entity as MyCharacter;
            var block = Entity as MyCubeBlock;

            if (block != null)
            {
                var relation = block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
                if (!relation.IsFriendly())
                {
                    if (user.ControllerInfo.IsLocallyHumanControlled())
                    {
                        MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                    }
                    return;
                }
            }

            switch (actionEnum)
            {
                case UseActionEnum.OpenInventory:
                case UseActionEnum.OpenTerminal:
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
                    break;
                default:
                    //MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Block);
                    break;
            }
        }
 public void Use(UseActionEnum actionEnum, Character.MyCharacter user)
 {
     switch(actionEnum)
     {
         case UseActionEnum.Manipulate:
             if (!m_buttonPanel.IsWorking)
                 return;
             if (!m_buttonPanel.AnyoneCanUse && !m_buttonPanel.HasLocalPlayerAccess())
             {
                 MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                 return;
             }
             m_buttonPanel.Toolbar.UpdateItem(m_index);
             m_buttonPanel.Toolbar.ActivateItemAtIndex(m_index);
             m_buttonPanel.PressButton(m_index);
             break;
         case UseActionEnum.OpenTerminal:
             if (!m_buttonPanel.HasLocalPlayerAccess())
                 return;
             MyToolbarComponent.CurrentToolbar = m_buttonPanel.Toolbar;
             MyGuiScreenBase screen = MyGuiScreenCubeBuilder.Static;
             if (screen == null)
                 screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, m_buttonPanel);
             MyToolbarComponent.AutoUpdate = false;
             screen.Closed += (source) => MyToolbarComponent.AutoUpdate = true;
             MyGuiSandbox.AddScreen(screen);
             break;
         default:
             break;
     }
 }
 MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
 {
     return new MyActionDescription()
     {
         Text = MySpaceTexts.NotificationHintPressToUseWardrobe,
         FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.USE) },
         IsTextControlHint = true,
         JoystickFormatParams = new object[] { MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE) },
     };
 }
 MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
 {
     return new MyActionDescription()
     {
         Text = MySpaceTexts.NotificationHintPressToEnterCockpit,
         FormatParams = new object[] { MyGuiSandbox.GetKeyName(MyControlsSpace.USE) },
         IsTextControlHint = true,
         JoystickFormatParams = new object[] { MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE) },
     };
 }
 MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
 {
     return new MyActionDescription()
     {
         Text = MySpaceTexts.NotificationHintPressToOpenControlPanel,
         FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL), Block.DefinitionDisplayNameText },
         IsTextControlHint = true,
         JoystickText = MySpaceTexts.NotificationHintJoystickPressToOpenControlPanel,
         JoystickFormatParams = new object[] { Block.DefinitionDisplayNameText },
     };
 }
Example #7
0
            public void RequestUse(UseActionEnum actionEnum, MyCharacter user)
            {
                var msg = new UseMsg();

                msg.EntityId = m_block.EntityId;
                msg.UsedByEntityId = user.EntityId;
                msg.ActionEnum = actionEnum;

                Sync.Layer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);

            }
Example #8
0
        MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
        {
            var key = MyInput.Static.GetGameControl(MyControlsSpace.USE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);

            return(new MyActionDescription()
            {
                Text = MySpaceTexts.NotificationPickupObject,
                FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.USE), m_displayedText },
                IsTextControlHint = false,
                JoystickFormatParams = new object[] { MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE), m_displayedText },
            });
        }
 public void Use(string dummyName, UseActionEnum actionEnum, MyEntity user)
 {
     if (!MyMultiplayerModApi.Static.IsServer)
     {
         return;
     }
     if (actionEnum != UseActionEnum.Manipulate)
     {
         return;
     }
     Switch();
 }
        public virtual void RequestUse(UseActionEnum actionEnum, IMyControllableEntity usedBy)
        {
            Debug.Assert(Entity is IMyUsableEntity, "Entity must implement IMyUsableEntity to use it");

            UseObject_UseMsg msg = new UseObject_UseMsg();

            msg.EntityId       = SyncedEntityId;
            msg.UseAction      = actionEnum;
            msg.UsedByEntityId = usedBy.Entity.EntityId;

            MySession.Static.SyncLayer.SendMessageToServer(ref msg);
        }
        public void Use(string dummyName, UseActionEnum actionEnum, MyEntity user)
        {
            if (actionEnum != UseActionEnum.Manipulate)
            {
                return;
            }
            var switchable = Definition.FindSwitchableByDummy(dummyName);

            if (!switchable.HasValue)
            {
                return;
            }
            Switch(switchable.Value);
        }
        public override MyActionDescription GetActionInfo(UseActionEnum actionEnum)
        {
            var block = Entity as MyCubeBlock;
            var text  = block != null ? block.DefinitionDisplayNameText : Entity.DisplayNameText;

            return(new MyActionDescription()
            {
                Text = MySpaceTexts.NotificationHintPressToOpenInventory,
                FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL), text },
                IsTextControlHint = true,
                JoystickText = MySpaceTexts.NotificationHintJoystickPressToOpenControlPanel,
                JoystickFormatParams = new object[] { text },
            });
        }
Example #13
0
        public MyActionDescription GetActionInfo(string dummyName, UseActionEnum actionEnum)
        {
            if (actionEnum != UseActionEnum.Manipulate)
            {
                return(InvalidActionDesc);
            }
            var state = StateForDummy(dummyName);

            if (state != null)
            {
                return(state.AttachedCharacter != null ? state.Definition.OccupiedActionDesc : state.Definition.EmptyActionDesc);
            }
            return(InvalidActionDesc);
        }
Example #14
0
        public void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            if (m_isOpen)
            {
                return;
            }

            var user     = entity as MyCharacter;
            var relation = GetUserRelationToOwner(user.ControllerInfo.Controller.Player.Identity.IdentityId);

            if (OwnerId == 0)
            {
                OnOwnerUse(actionEnum, user);
            }
            else
            {
                switch (relation)
                {
                case VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies:
                case VRage.Game.MyRelationsBetweenPlayerAndBlock.Neutral:       // HACK: relation is neutral if sharing is set to none and we would like to access a faction text panel text field
                    if (MySession.Static.Factions.TryGetPlayerFaction(user.ControllerInfo.Controller.Player.Identity.IdentityId) == MySession.Static.Factions.TryGetPlayerFaction(IDModule.Owner) &&
                        actionEnum == UseActionEnum.Manipulate && IsAccessibleForFaction)
                    {
                        OnFactionUse(actionEnum, user);
                    }
                    else
                    {
                        OnEnemyUse(actionEnum, user);
                    }
                    break;

                case VRage.Game.MyRelationsBetweenPlayerAndBlock.NoOwnership:
                case VRage.Game.MyRelationsBetweenPlayerAndBlock.FactionShare:
                    if (OwnerId == 0 && IsAccessibleForOnlyOwner)
                    {
                        OnOwnerUse(actionEnum, user);
                    }
                    else
                    {
                        OnFactionUse(actionEnum, user);
                    }
                    break;

                case VRage.Game.MyRelationsBetweenPlayerAndBlock.Owner:
                    OnOwnerUse(actionEnum, user);
                    break;
                }
            }
        }
        void IMyUseObject.Use(UseActionEnum actionEnum, MyCharacter user)
        {
            // How to distinct between server sending message?
            // - it's response...always

            // This is request
            // 1) use - server call
            // -- on server: take control of entity
            // -- -- on success, use it, broadcast
            // -- -- on failure, don't use it, report back

            // Something like:
            // -- extension method IControllableEntity.RequestUse(actionEnum, user, handler)
            if(Cockpit is MyCockpit)
                (Cockpit as MyCockpit).RequestUse(actionEnum, user);
        }
Example #16
0
        private void OnFactionUse(UseActionEnum actionEnum, MyCharacter user)
        {
            bool isAccessible         = IsAccessibleForFaction;
            bool readOnlyNotification = false;

            if (IsAccessibleForFaction)
            {
                if (actionEnum == UseActionEnum.Manipulate)
                {
                    if (IsWritableForFaction)
                    {
                        OpenWindow(true, true, false);
                    }
                    else if (IsReadableForFaction)
                    {
                        OpenWindow(false, true, false);
                    }
                    else
                    {
                        Debug.Fail("Unknown state of text panel");
                    }
                }
                else if (actionEnum == UseActionEnum.OpenTerminal)
                {
                    if (IsWritableForFaction)
                    {
                        MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, this);
                    }
                    else
                    {
                        readOnlyNotification = true;
                    }
                }
            }

            if (user.ControllerInfo.Controller.Player == MySession.LocalHumanPlayer)
            {
                if (!isAccessible)
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                else if (readOnlyNotification)
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.TextPanelReadOnly);
                }
            }
        }
        public MyActionDescription GetActionInfo(string dummyName, UseActionEnum actionEnum)
        {
            switch (actionEnum)
            {
            case UseActionEnum.Manipulate:
                return(new MyActionDescription {
                    IsPrimary = true, Text = TextSwitch
                });

            case UseActionEnum.OpenTerminal:
                return(new MyActionDescription {
                    IsPrimary = false, Text = TextConfig
                });

            default:
                return(default(MyActionDescription));
            }
        }
        public MyActionDescription GetActionInfo(string dummyName, UseActionEnum actionEnum)
        {
            if (actionEnum != UseActionEnum.Manipulate)
            {
                return(default(MyActionDescription));
            }
            var switchable = Definition.FindSwitchableByDummy(dummyName);

            // ReSharper disable once ConvertIfStatementToReturnStatement
            if (switchable.HasValue)
            {
                return new MyActionDescription {
                           Text = MyStringId.GetOrCompute("Switch")
                }
            }
            ;
            return(default(MyActionDescription));
        }
        void IMyUseObject.Use(UseActionEnum actionEnum, MyCharacter user)
        {
            // How to distinct between server sending message?
            // - it's response...always

            // This is request
            // 1) use - server call
            // -- on server: take control of entity
            // -- -- on success, use it, broadcast
            // -- -- on failure, don't use it, report back

            // Something like:
            // -- extension method IControllableEntity.RequestUse(actionEnum, user, handler)
            if (Cockpit is MyCockpit)
            {
                (Cockpit as MyCockpit).RequestUse(actionEnum, user);
            }
        }
Example #20
0
        public void Use(string dummyName, UseActionEnum actionEnum, MyEntity user)
        {
            if (actionEnum != UseActionEnum.Manipulate)
            {
                return;
            }
            if (user != MyAPIGateway.Session.ControlledObject)
            {
                return;
            }
            var state = StateForDummy(dummyName);

            if (state == null)
            {
                return;
            }
            user.Get <EquiEntityControllerComponent>()?.RequestControl(state);
        }
        public void Use(string dummyName, UseActionEnum actionEnum, MyEntity user)
        {
            MrzUtils.ShowNotificationDebug("InvInteraction::Use", 200);
            if (!actionEnum.HasFlags(actionEnum))
            {
                return;
            }

            if (MrzUtils.IsServer)
            {
                MrzUtils.ShowNotificationDebug("InvInteraction::Server-side Use", 200);
                RequestInventoryInteraction(user.EntityId, !MyAPIGateway.Input.IsAnyShiftKeyDown());
            }
            else
            {
                MrzUtils.ShowNotificationDebug("InvInteraction::Client-side Use", 200);
                MyAPIGateway.Multiplayer.RaiseEvent(this, x => RequestInventoryInteraction, user.EntityId, !MyAPIGateway.Input.IsAnyShiftKeyDown());
            }
        }
        public override void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user  = entity as MyCharacter;
            var block = Entity as MyCubeBlock;

            if (block != null)
            {
                var relation = block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
                if (!relation.IsFriendly())
                {
                    if (user.ControllerInfo.IsLocallyHumanControlled())
                    {
                        MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                    }
                    return;
                }
            }

            //by Gregory: on use action the button pressed should be checked because on use action we will always get only Inventory TODO: refactor somehow
            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.TERMINAL))
            {
                MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, Entity);
            }
            else
            {
                MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
            }

            /*
             * switch (actionEnum)
             * {
             *  case UseActionEnum.OpenInventory:
             *      MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
             *      break;
             *  case UseActionEnum.OpenTerminal:
             *      MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
             *      break;
             *  default:
             *      //MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
             *      break;
             * }
             */
        }
        void IMyUseObject.Use(UseActionEnum actionEnum, MyCharacter user)
        {
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
            if (relation != Common.MyRelationsBetweenPlayerAndBlock.Owner && relation != Common.MyRelationsBetweenPlayerAndBlock.FactionShare)
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
                case UseActionEnum.Manipulate:
                    MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = new MyGuiScreenWardrobe(user));
                    break;
            }
        }
        private void UseInternal(UseActionEnum actionEnum, MyCharacter user)
        {
            if (!IsWorking)
            {
                return;
            }
            if (m_user == null)
            {
                m_user = user;
                m_rechargeSocket.PlugIn(m_user.SuitBattery);
                StartProgressLoopSound();
            }
            m_lastTimeUsed = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            if (IsWorking)
            {
                m_user.AddHealth(0.075f);
            }
        }
Example #25
0
        public override void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            MyCharacter user = entity as MyCharacter;

            if (!this.Door.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId).IsFriendly() && !MySession.Static.AdminSettings.HasFlag(AdminSettingsEnum.UseTerminals))
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
            }
            else if (actionEnum == UseActionEnum.Manipulate)
            {
                this.Door.SetOpenRequest(!this.Door.Open, user.ControllerInfo.ControllingIdentityId);
            }
            else if (actionEnum == UseActionEnum.OpenTerminal)
            {
                MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, this.Door);
            }
        }
        void IMyUseObject.Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user = entity as MyCharacter;
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
            if (!relation.IsFriendly())
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
                case UseActionEnum.Manipulate:
                    MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = new MyGuiScreenWardrobe(user));
                    break;
            }
        }
Example #27
0
        void IMyUseObject.Use(UseActionEnum actionEnum, MyCharacter user)
        {
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);

            if (relation != Common.MyRelationsBetweenPlayerAndBlock.Owner && relation != Common.MyRelationsBetweenPlayerAndBlock.FactionShare)
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
            case UseActionEnum.Manipulate:
                MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = new MyGuiScreenWardrobe(user));
                break;
            }
        }
        public override void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user = entity as MyCharacter;

            switch (actionEnum)
            {
            case UseActionEnum.Manipulate:
                if (!m_buttonPanel.IsWorking)
                {
                    return;
                }
                if (!m_buttonPanel.AnyoneCanUse && !m_buttonPanel.HasLocalPlayerAccess())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                    return;
                }
                m_buttonPanel.Toolbar.UpdateItem(m_index);
                m_buttonPanel.Toolbar.ActivateItemAtIndex(m_index);
                m_buttonPanel.PressButton(m_index);
                break;

            case UseActionEnum.OpenTerminal:
                if (!m_buttonPanel.HasLocalPlayerAccess())
                {
                    return;
                }
                MyToolbarComponent.CurrentToolbar = m_buttonPanel.Toolbar;
                MyGuiScreenBase screen = MyGuiScreenCubeBuilder.Static;
                if (screen == null)
                {
                    screen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, m_buttonPanel);
                }
                MyToolbarComponent.AutoUpdate = false;
                screen.Closed += (source) => MyToolbarComponent.AutoUpdate = true;
                MyGuiSandbox.AddScreen(screen);
                break;

            default:
                break;
            }
        }
Example #29
0
        void IMyUseObject.Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user     = entity as MyCharacter;
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);

            if (!relation.IsFriendly())
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
            case UseActionEnum.Manipulate:
                MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = new MyGuiScreenWardrobe(user));
                break;
            }
        }
        public void Use(UseActionEnum actionEnum, MyCharacter user)
        {
            if (m_isOpen)
            {
                return;
            }

            var relation = GetUserRelationToOwner(user.ControllerInfo.Controller.Player.Identity.IdentityId);

            if (OwnerId == 0)
            {
                OnOwnerUse(actionEnum, user);
            }
            else
            {
                switch (relation)
                {
                case Common.MyRelationsBetweenPlayerAndBlock.Enemies:
                case Common.MyRelationsBetweenPlayerAndBlock.Neutral:
                    OnEnemyUse(actionEnum, user);
                    break;

                case Common.MyRelationsBetweenPlayerAndBlock.FactionShare:
                    if (OwnerId == 0 && IsAccessibleForOnlyOwner)
                    {
                        OnOwnerUse(actionEnum, user);
                    }
                    else
                    {
                        OnFactionUse(actionEnum, user);
                    }
                    break;

                case Common.MyRelationsBetweenPlayerAndBlock.Owner:
                    OnOwnerUse(actionEnum, user);
                    break;
                }
            }
        }
Example #31
0
        public virtual UseActionResult CanUse(UseActionEnum actionEnum, IMyControllableEntity user)
        {
            if (m_pilot != null)
            {
                return(UseActionResult.UsedBySomeoneElse);
            }

            long identityId = user.ControllerInfo.ControllingIdentityId;

            if (identityId != 0)
            {
                bool accessAllowed = HasPlayerAccess(identityId);
                if (!accessAllowed)
                {
                    return(UseActionResult.AccessDenied);
                }

                return(UseActionResult.OK);
            }

            return(UseActionResult.AccessDenied);
        }
Example #32
0
 public override void Use(UseActionEnum actionEnum, IMyEntity entity)
 {
     if (MySession.Static.CheckDLCAndNotify(this.Block.BlockDefinition))
     {
         MyCharacter user = entity as MyCharacter;
         if (!this.Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId).IsFriendly() && !MySession.Static.AdminSettings.HasFlag(AdminSettingsEnum.UseTerminals))
         {
             if (user.ControllerInfo.IsLocallyHumanControlled())
             {
                 MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
             }
         }
         else if (actionEnum == UseActionEnum.OpenTerminal)
         {
             MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, this.Block);
         }
         else if ((actionEnum == UseActionEnum.OpenInventory) && (this.Block.GetInventory(0) != null))
         {
             MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, this.Block);
         }
     }
 }
        public override void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user = entity as MyCharacter;
            var block = Entity as MyCubeBlock;

            if (block != null)
            {
                var relation = block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
                if (!relation.IsFriendly())
                {
                    if (user.ControllerInfo.IsLocallyHumanControlled())
                    {
                        MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                    }
                    return;
                }
            }

            //by Gregory: on use action the button pressed should be checked because on use action we will always get only Inventory TODO: refactor somehow
            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.TERMINAL))
                MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, Entity);
            else
                MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
            
            /*
            switch (actionEnum)
            {
                case UseActionEnum.OpenInventory:
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
                    break;
                case UseActionEnum.OpenTerminal:
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
                    break;
                default:
                    //MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Entity);
                    break;
            }
            */
        }
Example #34
0
        private void OnFactionUse(UseActionEnum actionEnum, MyCharacter user)
        {
            bool readOnlyNotification = false;

            if (actionEnum == UseActionEnum.Manipulate)
            {
                var relation = GetUserRelationToOwner(user.GetPlayerIdentityId());

                if (relation == MyRelationsBetweenPlayerAndBlock.FactionShare)
                {
                    OpenWindow(true, true, true);
                }
                else
                {
                    OpenWindow(false, true, true);
                }
            }
            else if (actionEnum == UseActionEnum.OpenTerminal)
            {
                var relation = GetUserRelationToOwner(user.GetPlayerIdentityId());

                if (relation == MyRelationsBetweenPlayerAndBlock.FactionShare)
                {
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, this);
                }
                else
                {
                    readOnlyNotification = true;
                }
            }

            if (user.ControllerInfo.Controller.Player == MySession.Static.LocalHumanPlayer)
            {
                if (readOnlyNotification)
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.TextPanelReadOnly);
                }
            }
        }
Example #35
0
        private void UseInternal(UseActionEnum actionEnum, MyCharacter user)
        {
            if (!IsWorking)
            {
                return;
            }
            if (m_user == null)
            {
                m_user = user;
                m_user.SuitBattery.ResourceSink.TemporaryConnectedEntity = this;
                m_rechargeSocket.PlugIn(m_user.SuitBattery.ResourceSink);
                StartProgressLoopSound();
            }
            m_lastTimeUsed = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            if (IsWorking)
            {
                if (m_user.StatComp != null)
                {
                    m_user.StatComp.DoAction("MedRoomHeal");
                }
            }
        }
        void IMyUseObject.Use(UseActionEnum actionEnum, MyCharacter user)
        {
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
            if (relation != Common.MyRelationsBetweenPlayerAndBlock.Owner && relation != Common.MyRelationsBetweenPlayerAndBlock.FactionShare)
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
                case UseActionEnum.OpenTerminal:
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, Block);
                    break;
                case UseActionEnum.OpenInventory:
                    if (Block as IMyInventoryOwner != null)
                        MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Block);
                    break;
            }
        }
        void IMyUseObject.Use(UseActionEnum actionEnum, MyCharacter user)
        {
            var relation = Door.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
            if (relation != Common.MyRelationsBetweenPlayerAndBlock.Owner && relation != Common.MyRelationsBetweenPlayerAndBlock.FactionShare)
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
                case UseActionEnum.Manipulate:
                    Door.SetOpenRequest(!Door.Open, user.ControllerInfo.ControllingIdentityId);
                    break;

                case UseActionEnum.OpenTerminal:
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, Door);
                    break;
            }
        }
Example #38
0
        public override void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user     = entity as MyCharacter;
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);

            if (!relation.IsFriendly())
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
            case UseActionEnum.Manipulate:
                if (Block is MyMedicalRoom)
                {
                    MyMedicalRoom medRoom = (MyMedicalRoom)Block;
                    if (!medRoom.SuitChangeAllowed)
                    {
                        MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                        break;
                    }

                    if (medRoom.CustomWardrobesEnabled)
                    {
                        MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = new MyGuiScreenWardrobe(user, medRoom.CustomWardrobeNames));
                        break;
                    }
                }

                MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = new MyGuiScreenWardrobe(user));
                break;
            }
        }
Example #39
0
        MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
        {
            MyActionDescription description;

            if (!MySandboxGame.Config.ControlsHints)
            {
                description = new MyActionDescription {
                    Text = MyCommonTexts.CustomText,
                    IsTextControlHint = false
                };
                description.FormatParams = new object[] { this.m_displayedText };
                return(description);
            }
            if (actionEnum == UseActionEnum.Manipulate)
            {
                MyInput.Static.GetGameControl(MyControlsSpace.USE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
                description = new MyActionDescription {
                    Text = MyCommonTexts.NotificationPickupObject
                };
                description.FormatParams         = new object[] { "[" + MyInput.Static.GetGameControl(MyControlsSpace.USE) + "]", this.m_displayedText };
                description.IsTextControlHint    = true;
                description.JoystickFormatParams = new object[] { "[" + MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE).ToString() + "]", this.m_displayedText };
                return(description);
            }
            if (actionEnum != UseActionEnum.PickUp)
            {
                return(new MyActionDescription());
            }
            MyInput.Static.GetGameControl(MyControlsSpace.PICK_UP).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
            description = new MyActionDescription {
                Text = MyCommonTexts.NotificationPickupObject
            };
            description.FormatParams         = new object[] { "[" + MyInput.Static.GetGameControl(MyControlsSpace.PICK_UP) + "]", this.m_displayedText };
            description.IsTextControlHint    = true;
            description.JoystickFormatParams = new object[] { "[" + MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PICK_UP).ToString() + "]", this.m_displayedText };
            return(description);
        }
        public override void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user = entity as MyCharacter;
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
            if (!relation.IsFriendly())
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
                case UseActionEnum.Manipulate:
                    if (Block is MyMedicalRoom)
                    {
                        MyMedicalRoom medRoom = (MyMedicalRoom)Block;
                        if (!medRoom.SuitChangeAllowed)
                        {
                            MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                            break;
                        }

                        if (medRoom.CustomWardrobesEnabled)
                        {
                            MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = new MyGuiScreenWardrobe(user, medRoom.CustomWardrobeNames));
                            break;
                        }
                    }
 
                    MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = new MyGuiScreenWardrobe(user));
                    break;
            }
        }
 void GetNotification(IMyUseObject useObject, UseActionEnum actionType, ref MyHudNotification notification)
 {
     if ((useObject.SupportedActions & actionType) != 0)
     {
         var actionInfo = useObject.GetActionInfo(actionType);
         Character.RemoveNotification(ref notification);
         notification = new MyHudNotification(actionInfo.Text, 0, level: actionInfo.IsTextControlHint ? MyNotificationLevel.Control : MyNotificationLevel.Normal);
         if (!MyInput.Static.IsJoystickConnected())
         {
             notification.SetTextFormatArguments(actionInfo.FormatParams);
         }
         else
         {
             if (actionInfo.JoystickText.HasValue)
             {
                 notification.Text = actionInfo.JoystickText.Value;
             }
             if (actionInfo.JoystickFormatParams != null)
             {
                 notification.SetTextFormatArguments(actionInfo.JoystickFormatParams);
             }
         }
     }
 }
Example #42
0
 private void GetNotification(IMyUseObject useObject, UseActionEnum actionType, ref MyHudNotification notification)
 {
     if ((useObject.SupportedActions & actionType) != UseActionEnum.None)
     {
         MyActionDescription actionInfo = useObject.GetActionInfo(actionType);
         base.Character.RemoveNotification(ref notification);
         notification = new MyHudNotification(actionInfo.Text, 0, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, actionInfo.IsTextControlHint ? MyNotificationLevel.Control : MyNotificationLevel.Normal);
         if (!MyDebugDrawSettings.DEBUG_DRAW_JOYSTICK_CONTROL_HINTS && (!MyInput.Static.IsJoystickConnected() || !MyInput.Static.IsJoystickLastUsed))
         {
             notification.SetTextFormatArguments(actionInfo.FormatParams);
         }
         else
         {
             if (actionInfo.JoystickText != null)
             {
                 notification.Text = actionInfo.JoystickText.Value;
             }
             if (actionInfo.JoystickFormatParams != null)
             {
                 notification.SetTextFormatArguments(actionInfo.JoystickFormatParams);
             }
         }
     }
 }
Example #43
0
        void IMyUseObject.Use(UseActionEnum actionEnum, MyCharacter user)
        {
            var relation = Door.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);

            if (relation != Common.MyRelationsBetweenPlayerAndBlock.Owner && relation != Common.MyRelationsBetweenPlayerAndBlock.FactionShare)
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
            case UseActionEnum.Manipulate:
                Door.SetOpenRequest(!Door.Open, user.ControllerInfo.ControllingIdentityId);
                break;

            case UseActionEnum.OpenTerminal:
                MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, Door);
                break;
            }
        }
        void IMyUseObject.Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user = entity as MyCharacter;
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
            if (!relation.IsFriendly())
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
                case UseActionEnum.OpenTerminal:
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, Block);
                    break;
                case UseActionEnum.OpenInventory:
                    if (Block as IMyInventoryOwner != null)
                        MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Block);
                    break;
            }
        }
        void IMyUseObject.Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user = entity as MyCharacter;
            var relation = Block.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
            if (relation != Sandbox.Common.MyRelationsBetweenPlayerAndBlock.Owner && relation != Sandbox.Common.MyRelationsBetweenPlayerAndBlock.FactionShare)
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
                case UseActionEnum.OpenInventory:
                case UseActionEnum.OpenTerminal:
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Block);
                    break;
                default:
                    //MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, Block);
                    break;
            }
        }
        public override void Use(UseActionEnum actionEnum, IMyEntity entity)
        {
            var user = entity as MyCharacter;
            var relation = Door.GetUserRelationToOwner(user.ControllerInfo.ControllingIdentityId);
            if (!relation.IsFriendly())
            {
                if (user.ControllerInfo.IsLocallyHumanControlled())
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            switch (actionEnum)
            {
                case UseActionEnum.Manipulate:
                    Door.ChangeOpenClose(!Door.Open);
                    break;

                case UseActionEnum.OpenTerminal:
                    MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, Door);
                    break;
            }
        }
Example #47
0
        public override MyActionDescription GetActionInfo(UseActionEnum actionEnum)
        {
            MyActionDescription description;

            if ((actionEnum == UseActionEnum.OpenTerminal) || (actionEnum != UseActionEnum.OpenInventory))
            {
                description = new MyActionDescription {
                    Text = MySpaceTexts.NotificationHintPressToOpenControlPanel
                };
                description.FormatParams         = new object[] { "[" + MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) + "]", this.Block.DefinitionDisplayNameText };
                description.IsTextControlHint    = true;
                description.JoystickText         = new MyStringId?(MySpaceTexts.NotificationHintJoystickPressToOpenControlPanel);
                description.JoystickFormatParams = new object[] { this.Block.DefinitionDisplayNameText };
                return(description);
            }
            description = new MyActionDescription {
                Text = MySpaceTexts.NotificationHintPressToOpenInventory
            };
            description.FormatParams         = new object[] { "[" + MyInput.Static.GetGameControl(MyControlsSpace.INVENTORY) + "]", this.Block.DefinitionDisplayNameText };
            description.IsTextControlHint    = true;
            description.JoystickText         = new MyStringId?(MySpaceTexts.NotificationHintJoystickPressToOpenInventory);
            description.JoystickFormatParams = new object[] { this.Block.DefinitionDisplayNameText };
            return(description);
        }
 public override void Use(UseActionEnum actionEnum, IMyEntity entity)
 {
     var user = entity as MyCharacter;
     m_medicalRoom.Use(actionEnum, user);
 }
 void IMyUseObject.Use(UseActionEnum actionEnum, IMyEntity entity)
 {
     var user = entity as MyCharacter;
     m_medicalRoom.Use(actionEnum, user);
 }
Example #50
0
 public static bool IsActionSupported(this IMyUseObject useObject, UseActionEnum action)
 {
     return (useObject.SupportedActions & action) == action;
 }
Example #51
0
        public void Use(UseActionEnum actionEnum, MyCharacter user)
        {
            var relation = GetUserRelationToOwner(user.ControllerInfo.Controller.Player.Identity.IdentityId);
            if (!relation.IsFriendly())
            {
                if (user.ControllerInfo.Controller.Player == MySession.LocalHumanPlayer)
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
                }
                return;
            }

            if(actionEnum == UseActionEnum.OpenTerminal)
            {
                MyGuiScreenTerminal.Show(MyTerminalPageEnum.ControlPanel, user, this);
            }
            else if (actionEnum == UseActionEnum.Manipulate)
            {
                if (m_user != null && m_user != user)
                    return;
                SyncObject.RequestUse(actionEnum, user);
            }
        }
 /// <summary>
 /// Uses object by specified action
 /// Caller calls this method only on supported actions
 /// </summary>
 void IMyUseObject.Use(UseActionEnum actionEnum, IMyEntity entity)
 {
     var user = entity as MyCharacter;
     if (MyPerGameSettings.TerminalEnabled)
     {
         MyGuiScreenTerminal.Show(MyTerminalPageEnum.Inventory, user, this);
     }
     if (MyPerGameSettings.GUI.InventoryScreen != null && IsDead)
     {
         var inventory = Components.Get<MyInventoryAggregate>();
         if (inventory != null)
         {
             var screen = user.ShowAggregateInventoryScreen(inventory);
         }
     }
 }
Example #53
0
        private void UseInternal(UseActionEnum actionEnum, MyCharacter user)
        {
            if (!IsWorking)
                return;
            if (m_user == null)
            {
                m_user = user;
                m_rechargeSocket.PlugIn(m_user.SuitBattery);
                StartProgressLoopSound();
            }
            m_lastTimeUsed = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            if (IsWorking)
            {
				if (m_user.StatComp != null)
					m_user.StatComp.DoAction("MedRoomHeal");
            }
        }
Example #54
0
 void sync_UseFailed(UseActionEnum actionEnum, UseActionResult actionResult, IMyControllableEntity user)
 {
     if (user != null && user.ControllerInfo.IsLocallyHumanControlled())
     {
         if (actionResult == UseActionResult.UsedBySomeoneElse)
             MyHud.Notifications.Add(new MyHudNotification(MySpaceTexts.AlreadyUsedBySomebodyElse, 2500, MyFontEnum.Red));
         else if (actionResult == UseActionResult.AccessDenied)
             MyHud.Notifications.Add(MyNotificationSingletons.AccessDenied);
         else if (actionResult == UseActionResult.Unpowered)
             MyHud.Notifications.Add(new MyHudNotification(MySpaceTexts.BlockIsNotPowered, 2500, MyFontEnum.Red));
         else if (actionResult == UseActionResult.CockpitDamaged)
             MyHud.Notifications.Add(new MyHudNotification(MySpaceTexts.Notification_CockpitIsDamaged, 2500, MyFontEnum.Red));
     }
 }
Example #55
0
 public void RequestUse(UseActionEnum actionEnum, MyCharacter user)
 {
     SyncObject.RequestUse(actionEnum, user);
 }
Example #56
0
 public UseActionResult CanUse(UseActionEnum actionEnum, IMyControllableEntity user)
 {
     if (m_previousControlledEntity != null && user != m_previousControlledEntity)
     {
         return UseActionResult.UsedBySomeoneElse;
     }
     return UseActionResult.OK;
 }
Example #57
0
        protected override void sync_UseSuccess(UseActionEnum actionEnum, IMyControllableEntity user)
        {
            base.sync_UseSuccess(actionEnum, user);

            AcquireControl(user);

            if (user.ControllerInfo != null && user.ControllerInfo.Controller != null)
            {
                user.SwitchControl(this);

                RefreshTerminal();
            }

            //switch to binded camera
            if (m_bindedCamera != 0)
            {
                MyEntity entity;
                if (MyEntities.TryGetEntityById(m_bindedCamera, out entity))
                {
                    MyCameraBlock camera = entity as MyCameraBlock;
                    if (camera != null)
                    {
                        camera.RequestSetView();
        }
                    else
                    {
                        m_bindedCamera.Value = 0;
                    }
                }
                else
                {
                    m_bindedCamera.Value = 0;
                }
            }
        }
 /// <summary>
 /// Gets action text
 /// Caller calls this method only on supported actions
 /// </summary>
 MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
 {
     return new MyActionDescription()
     {
         Text = MySpaceTexts.NotificationHintPressToOpenInventory,
         FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.INVENTORY), DisplayName },
         IsTextControlHint = true,
         JoystickText = MyCommonTexts.NotificationHintJoystickPressToOpenInventory,
         JoystickFormatParams = new object[] { DisplayName },
     };
 }
Example #59
0
 protected virtual void sync_UseSuccess(UseActionEnum actionEnum, IMyControllableEntity user)
 {
 }
        public MyActionDescription GetActionInfo(UseActionEnum actionEnum)
        {
            m_buttonPanel.Toolbar.UpdateItem(m_index);
            var slot = m_buttonPanel.Toolbar.GetItemAtIndex(m_index);
            switch (actionEnum)
            {
                case UseActionEnum.Manipulate:

                    if (m_buttonDesc == null)
                    {
                        m_buttonDesc = new MyGps();
                        
                        m_buttonDesc.Description = "";
                        m_buttonDesc.Coords = ActivationMatrix.Translation;
                        m_buttonDesc.ShowOnHud = true;
                        m_buttonDesc.DiscardAt = null;
                    }

                    MyHud.ButtonPanelMarkers.RegisterMarker(m_buttonDesc);

                    SetButtonName(m_buttonPanel.GetCustomButtonName(m_index));

                    if (slot != null)
                    {
                        return new MyActionDescription()
                        {
                            Text = MySpaceTexts.NotificationHintPressToUse,
                            FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.USE), slot.DisplayName },
                            IsTextControlHint = true,
                            JoystickFormatParams = new object[] { MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE), slot.DisplayName },
                        };
                    }
                    else
                    {
                        return new MyActionDescription() { Text = MySpaceTexts.Blank };
                    }

                case UseActionEnum.OpenTerminal:
                    return new MyActionDescription()
                    {
                        Text = MySpaceTexts.NotificationHintPressToOpenButtonPanel,
                        FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) },
                        IsTextControlHint = true,
                        JoystickText = MySpaceTexts.NotificationHintJoystickPressToOpenButtonPanel,
                    };

                default:
                    Debug.Fail("Invalid branch reached.");
                    return new MyActionDescription()
                    {
                        Text = MySpaceTexts.NotificationHintPressToOpenButtonPanel,
                        FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) },
                        IsTextControlHint = true
                    };
            }
        }