Exemplo n.º 1
0
        ///<summary>
        ///Method to allow the user to swap the mode of the RCD by clicking it in hand, the actual in hand clicking bit is done over on UseEntity()
        ///@param UseEntityEventArgs = The entity which triggered this method call, used to know where to play the "click" sound.
        ///</summary>

        public void SwapMode(UseEntityEventArgs eventArgs)
        {
            _entitySystemManager.GetEntitySystem <AudioSystem>().PlayFromEntity("/Audio/Items/genhit.ogg", Owner);
            int mode = (int)_mode;                                                                       //Firstly, cast our RCDmode mode to an int (enums are backed by ints anyway by default)

            mode  = (++mode) % _modes.Length;                                                            //Then, do a rollover on the value so it doesnt hit an invalid state
            _mode = (RcdMode)mode;                                                                       //Finally, cast the newly acquired int mode to an RCDmode so we can use it.
            Owner.PopupMessage(eventArgs.User, Loc.GetString("The RCD is now set to {0} mode.", _mode)); //Prints an overhead message above the RCD
        }
Exemplo n.º 2
0
        ///<summary>
        ///Method to allow the user to swap the mode of the RCD by clicking it in hand, the actual in hand clicking bit is done over on UseEntity()
        ///@param UseEntityEventArgs = The entity which triggered this method call, used to know where to play the "click" sound.
        ///</summary>

        public void SwapMode(UseEntityEventArgs eventArgs)
        {
            SoundSystem.Play(Filter.Pvs(Owner), _swapModeSound.GetSound(), Owner);
            var mode = (int)_mode;            //Firstly, cast our RCDmode mode to an int (enums are backed by ints anyway by default)

            mode  = (++mode) % _modes.Length; //Then, do a rollover on the value so it doesnt hit an invalid state
            _mode = (RcdMode)mode;            //Finally, cast the newly acquired int mode to an RCDmode so we can use it.
            Owner.PopupMessage(eventArgs.User,
                               Loc.GetString(
                                   "rcd-component-change-mode",
                                   ("mode", _mode.ToString())
                                   )
                               ); //Prints an overhead message above the RCD
        }
Exemplo n.º 3
0
        ///<summary>
        ///Method to allow the user to swap the mode of the RCD by clicking it in hand, the actual in hand clicking bit is done over on UseEntity()
        ///@param UseEntityEventArgs = The entity which triggered this method call, used to know where to play the "click" sound.
        ///</summary>

        public void SwapMode(UseEntityEventArgs eventArgs)
        {
            _entitySystemManager.GetEntitySystem <AudioSystem>().PlayFromEntity("/Audio/Items/genhit.ogg", Owner);
            int mode = (int)this._mode;            //Firstly, cast our RCDmode mode to an int (enums are backed by ints anyway by default)

            mode       = (++mode) % _modes.Length; //Then, do a rollover on the value so it doesnt hit an invalid state
            this._mode = (RcdMode)mode;            //Finally, cast the newly acquired int mode to an RCDmode so we can use it.
            switch (this._mode)
            {
            case RcdMode.Floors:
                _outputTile = "floor_steel";
                break;

            case RcdMode.Walls:
                _outputTile = "base_wall";
                break;

            case RcdMode.Deconstruct:
                _outputTile = "space";
                break;
            }
            _serverNotifyManager.PopupMessage(Owner, eventArgs.User, $"The RCD is now set to {this._mode} mode."); //Prints an overhead message above the RCD
        }
Exemplo n.º 4
0
        private bool IsRCDStillValid(AfterInteractEventArgs eventArgs, IMapGrid mapGrid, TileRef tile, Vector2i snapPos, RcdMode startingMode)
        {
            //Less expensive checks first. Failing those ones, we need to check that the tile isn't obstructed.
            if (_ammo <= 0)
            {
                Owner.PopupMessage(eventArgs.User, Loc.GetString("The RCD is out of ammo!"));
                return(false);
            }

            if (_mode != startingMode)
            {
                return(false);
            }

            var coordinates = mapGrid.ToCoordinates(tile.GridIndices);

            if (coordinates == EntityCoordinates.Invalid || !eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
            {
                return(false);
            }

            switch (_mode)
            {
            //Floor mode just needs the tile to be a space tile (subFloor)
            case RcdMode.Floors:
                if (!tile.Tile.IsEmpty)
                {
                    Owner.PopupMessage(eventArgs.User, Loc.GetString("You can only build a floor on space!"));
                    return(false);
                }

                return(true);

            //We don't want to place a space tile on something that's already a space tile. Let's do the inverse of the last check.
            case RcdMode.Deconstruct:
                if (tile.Tile.IsEmpty)
                {
                    return(false);
                }

                //They tried to decon a turf but the turf is blocked
                if (eventArgs.Target == null && tile.IsBlockedTurf(true))
                {
                    Owner.PopupMessage(eventArgs.User, Loc.GetString("That tile is obstructed!"));
                    return(false);
                }
                //They tried to decon a non-turf but it's not in the whitelist
                if (eventArgs.Target != null && !eventArgs.Target.TryGetComponent(out RCDDeconstructWhitelist rcd_decon))
                {
                    Owner.PopupMessage(eventArgs.User, Loc.GetString("You can't deconstruct that!"));
                    return(false);
                }

                return(true);

            //Walls are a special behaviour, and require us to build a new object with a transform rather than setting a grid tile, thus we early return to avoid the tile set code.
            case RcdMode.Walls:
                if (tile.Tile.IsEmpty)
                {
                    Owner.PopupMessage(eventArgs.User, Loc.GetString("You cannot build a wall on space!"));
                    return(false);
                }

                if (tile.IsBlockedTurf(true))
                {
                    Owner.PopupMessage(eventArgs.User, Loc.GetString("That tile is obstructed!"));
                    return(false);
                }
                return(true);

            case RcdMode.Airlock:
                if (tile.Tile.IsEmpty)
                {
                    Owner.PopupMessage(eventArgs.User, Loc.GetString("Cannot build an airlock on space!"));
                    return(false);
                }
                if (tile.IsBlockedTurf(true))
                {
                    Owner.PopupMessage(eventArgs.User, Loc.GetString("That tile is obstructed!"));
                    return(false);
                }
                return(true);

            default:
                return(false);    //I don't know why this would happen, but sure I guess. Get out of here invalid state!
            }
        }
Exemplo n.º 5
0
        private bool IsRCDStillValid(RCDComponent rcd, AfterInteractEvent eventArgs, IMapGrid mapGrid, TileRef tile, RcdMode startingMode)
        {
            //Less expensive checks first. Failing those ones, we need to check that the tile isn't obstructed.
            if (rcd.CurrentAmmo <= 0)
            {
                _popup.PopupEntity(Loc.GetString("rcd-component-no-ammo-message"), rcd.Owner, Filter.Entities(eventArgs.User));
                return(false);
            }

            if (rcd.Mode != startingMode)
            {
                return(false);
            }

            var unobstructed = eventArgs.Target == null
                ? _interactionSystem.InRangeUnobstructed(eventArgs.User, mapGrid.GridTileToWorld(tile.GridIndices), popup : true)
                : _interactionSystem.InRangeUnobstructed(eventArgs.User, eventArgs.Target.Value, popup: true);

            if (!unobstructed)
            {
                return(false);
            }

            switch (rcd.Mode)
            {
            //Floor mode just needs the tile to be a space tile (subFloor)
            case RcdMode.Floors:
                if (!tile.Tile.IsEmpty)
                {
                    _popup.PopupEntity(Loc.GetString("rcd-component-cannot-build-floor-tile-not-empty-message"), rcd.Owner, Filter.Entities(eventArgs.User));
                    return(false);
                }

                return(true);

            //We don't want to place a space tile on something that's already a space tile. Let's do the inverse of the last check.
            case RcdMode.Deconstruct:
                if (tile.Tile.IsEmpty)
                {
                    return(false);
                }

                //They tried to decon a turf but the turf is blocked
                if (eventArgs.Target == null && tile.IsBlockedTurf(true))
                {
                    _popup.PopupEntity(Loc.GetString("rcd-component-tile-obstructed-message"), rcd.Owner, Filter.Entities(eventArgs.User));
                    return(false);
                }
                //They tried to decon a non-turf but it's not in the whitelist
                if (eventArgs.Target != null && !_tagSystem.HasTag(eventArgs.Target.Value, "RCDDeconstructWhitelist"))
                {
                    _popup.PopupEntity(Loc.GetString("rcd-component-deconstruct-target-not-on-whitelist-message"), rcd.Owner, Filter.Entities(eventArgs.User));
                    return(false);
                }

                return(true);

            //Walls are a special behaviour, and require us to build a new object with a transform rather than setting a grid tile, thus we early return to avoid the tile set code.
            case RcdMode.Walls:
                if (tile.Tile.IsEmpty)
                {
                    _popup.PopupEntity(Loc.GetString("rcd-component-cannot-build-wall-tile-not-empty-message"), rcd.Owner, Filter.Entities(eventArgs.User));
                    return(false);
                }

                if (tile.IsBlockedTurf(true))
                {
                    _popup.PopupEntity(Loc.GetString("rcd-component-tile-obstructed-message"), rcd.Owner, Filter.Entities(eventArgs.User));
                    return(false);
                }
                return(true);

            case RcdMode.Airlock:
                if (tile.Tile.IsEmpty)
                {
                    _popup.PopupEntity(Loc.GetString("rcd-component-cannot-build-airlock-tile-not-empty-message"), rcd.Owner, Filter.Entities(eventArgs.User));
                    return(false);
                }
                if (tile.IsBlockedTurf(true))
                {
                    _popup.PopupEntity(Loc.GetString("rcd-component-tile-obstructed-message"), rcd.Owner, Filter.Entities(eventArgs.User));
                    return(false);
                }
                return(true);

            default:
                return(false);    //I don't know why this would happen, but sure I guess. Get out of here invalid state!
            }
        }