private bool HandleUseItemInHand(ICommonSession session, GridCoordinates coords, EntityUid uid)
        {
            // client sanitization
            if (!_mapManager.GridExists(coords.GridID))
            {
                Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}");
                return(true);
            }

            if (uid.IsClientSide())
            {
                Logger.WarningS("system.interaction",
                                $"Client sent interaction with client-side entity. Session={session}, Uid={uid}");
                return(true);
            }

            var userEntity = ((IPlayerSession)session).AttachedEntity;

            if (userEntity == null || !userEntity.IsValid())
            {
                return(true);
            }

            UserInteraction(userEntity, coords, uid);

            return(true);
        }
        private bool HandleAttack(ICommonSession session, GridCoordinates coords, EntityUid uid)
        {
            // client sanitization
            if (!_mapManager.GridExists(coords.GridID))
            {
                Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}");
                return(true);
            }

            if (uid.IsClientSide())
            {
                Logger.WarningS("system.interaction",
                                $"Client sent attack with client-side entity. Session={session}, Uid={uid}");
                return(true);
            }

            var userEntity = ((IPlayerSession)session).AttachedEntity;

            if (userEntity == null || !userEntity.IsValid())
            {
                return(true);
            }

            if (userEntity.TryGetComponent(out CombatModeComponent combatMode) && combatMode.IsInCombatMode)
            {
                DoAttack(userEntity, coords);
            }

            return(true);
        }
Example #3
0
        private bool ValidateClientInput(ICommonSession?session, EntityCoordinates coords, EntityUid uid, [NotNullWhen(true)] out EntityUid?userEntity)
        {
            userEntity = null;

            if (!coords.IsValid(_entityManager))
            {
                Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}");
                return(false);
            }

            if (uid.IsClientSide())
            {
                Logger.WarningS("system.interaction",
                                $"Client sent interaction with client-side entity. Session={session}, Uid={uid}");
                return(false);
            }

            userEntity = ((IPlayerSession?)session)?.AttachedEntity;

            if (userEntity == null || !EntityManager.EntityExists(userEntity.Value))
            {
                Logger.WarningS("system.interaction",
                                $"Client sent interaction with no attached entity. Session={session}");
                return(false);
            }

            return(true);
        }
Example #4
0
        /// <summary>
        ///     Ask the server to send back a list of server-side verbs, and for now return an incomplete list of verbs
        ///     (only those defined locally).
        /// </summary>
        public Dictionary <VerbType, SortedSet <Verb> > GetVerbs(EntityUid target, EntityUid user, VerbType verbTypes)
        {
            if (!target.IsClientSide())
            {
                RaiseNetworkEvent(new RequestServerVerbsEvent(target, verbTypes));
            }

            return(GetLocalVerbs(target, user, verbTypes));
        }
Example #5
0
        /// <summary>
        ///     Ask the server to send back a list of server-side verbs, and for now return an incomplete list of verbs
        ///     (only those defined locally).
        /// </summary>
        public SortedSet <Verb> GetVerbs(EntityUid target, EntityUid user, List <Type> verbTypes,
                                         bool force = false)
        {
            if (!target.IsClientSide())
            {
                RaiseNetworkEvent(new RequestServerVerbsEvent(target, verbTypes, adminRequest: force));
            }

            return(GetLocalVerbs(target, user, verbTypes, force));
        }
Example #6
0
        private void HandleUseItemInHand(ICommonSession session, GridCoordinates coords, EntityUid uid)
        {
            // client sanitization
            if (!coords.IsValidLocation())
            {
                Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}");
                return;
            }

            if (uid.IsClientSide())
            {
                Logger.WarningS("system.interaction", $"Client sent interaction with client-side entity. Session={session}, Uid={uid}");
                return;
            }

            UserInteraction(((IPlayerSession)session).AttachedEntity, coords, uid);
        }
Example #7
0
 protected override bool CanDelete(EntityUid uid)
 {
     return(uid.IsClientSide());
 }
        public override void Initialize(DefaultWindow window, object obj)
        {
            _entity = (EntityUid)obj;

            var scrollContainer = new ScrollContainer();

            //scrollContainer.SetAnchorPreset(Control.LayoutPreset.Wide, true);
            window.Contents.AddChild(scrollContainer);
            var vBoxContainer = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            scrollContainer.AddChild(vBoxContainer);

            // Handle top bar displaying type and ToString().
            {
                Control top;
                var     stringified = PrettyPrint.PrintUserFacingWithType(obj, out var typeStringified);
                if (typeStringified != "")
                {
                    //var smallFont = new VectorFont(_resourceCache.GetResource<FontResource>("/Fonts/CALIBRI.TTF"), 10);
                    // Custom ToString() implementation.
                    var headBox = new BoxContainer
                    {
                        Orientation        = LayoutOrientation.Vertical,
                        SeparationOverride = 0
                    };
                    headBox.AddChild(new Label {
                        Text = stringified, ClipText = true
                    });
                    headBox.AddChild(new Label
                    {
                        Text = typeStringified,
                        //    FontOverride = smallFont,
                        FontColorOverride = Color.DarkGray,
                        ClipText          = true
                    });
                    top = headBox;
                }
                else
                {
                    top = new Label {
                        Text = stringified
                    };
                }

                if (_entityManager.TryGetComponent(_entity, out ISpriteComponent? sprite))
                {
                    var hBox = new BoxContainer
                    {
                        Orientation = LayoutOrientation.Horizontal
                    };
                    top.HorizontalExpand = true;
                    hBox.AddChild(top);
                    hBox.AddChild(new SpriteView {
                        Sprite = sprite, OverrideDirection = Direction.South
                    });
                    vBoxContainer.AddChild(hBox);
                }
                else
                {
                    vBoxContainer.AddChild(top);
                }
            }

            _tabs = new TabContainer();
            _tabs.OnTabChanged += _tabsOnTabChanged;
            vBoxContainer.AddChild(_tabs);

            var clientVBox = new BoxContainer
            {
                Orientation        = LayoutOrientation.Vertical,
                SeparationOverride = 0
            };

            _tabs.AddChild(clientVBox);
            _tabs.SetTabTitle(TabClientVars, Loc.GetString("view-variable-instance-entity-client-variables-tab-title"));

            var first = true;

            foreach (var group in LocalPropertyList(obj, ViewVariablesManager, _robustSerializer))
            {
                ViewVariablesTraitMembers.CreateMemberGroupHeader(
                    ref first,
                    TypeAbbreviation.Abbreviate(group.Key),
                    clientVBox);

                foreach (var control in group)
                {
                    clientVBox.AddChild(control);
                }
            }

            _clientComponents = new BoxContainer
            {
                Orientation        = LayoutOrientation.Vertical,
                SeparationOverride = 0
            };
            _tabs.AddChild(_clientComponents);
            _tabs.SetTabTitle(TabClientComponents, Loc.GetString("view-variable-instance-entity-client-components-tab-title"));

            PopulateClientComponents();

            if (!_entity.IsClientSide())
            {
                _serverVariables = new BoxContainer
                {
                    Orientation        = LayoutOrientation.Vertical,
                    SeparationOverride = 0
                };
                _tabs.AddChild(_serverVariables);
                _tabs.SetTabTitle(TabServerVars, Loc.GetString("view-variable-instance-entity-server-variables-tab-title"));

                _serverComponents = new BoxContainer
                {
                    Orientation        = LayoutOrientation.Vertical,
                    SeparationOverride = 0
                };
                _tabs.AddChild(_serverComponents);
                _tabs.SetTabTitle(TabServerComponents, Loc.GetString("view-variable-instance-entity-server-components-tab-title"));

                PopulateServerComponents(false);
            }
        }