/// <summary>
    /// General function to try to equip the item in the active hand
    /// </summary>
    public static void Equip()
    {
        // Is the player allowed to interact? (not a ghost)
        if (!isValidPlayer())
        {
            return;
        }

        // Is there an item to equip?
        var CurrentSlot = PlayerManager.LocalPlayerScript.DynamicItemStorage.GetActiveHandSlot();

        if (CurrentSlot.Item == null)
        {
            return;
        }

        //This checks which UI slot the item can be equiped to and swaps it there
        //Try to equip the item into the appropriate slot
        var bestSlot =
            BestSlotForTrait.Instance.GetBestSlot(CurrentSlot.Item, PlayerManager.LocalPlayerScript.DynamicItemStorage);

        if (bestSlot == null)
        {
            Chat.AddExamineMsg(PlayerManager.LocalPlayerScript.gameObject, "There is no available slot for that");
            return;
        }

        SwapItem(bestSlot.LocalUISlot);
    }
Example #2
0
        public void ServerPerformInteraction(HandApply interaction)
        {
            if (interaction.TargetObject != gameObject)
            {
                return;
            }


            if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Screwdriver))
            {
                if (objectBehaviour.IsPushable)
                {
                    //secure it if there's floor
                    if (MatrixManager.IsSpaceAt(registerObject.WorldPositionServer, true))
                    {
                        Chat.AddExamineMsg(interaction.Performer, "A floor must be present to secure the window!");
                        return;
                    }

                    if (!ServerValidations.IsAnchorBlocked(interaction))
                    {
                        ToolUtils.ServerUseToolWithActionMessages(interaction, 4f,
                                                                  "You start securing the window...",
                                                                  $"{interaction.Performer.ExpensiveName()} starts securing the window...",
                                                                  "You secure the window.",
                                                                  $"{interaction.Performer.ExpensiveName()} secures the window.",
                                                                  () => ScrewToFloor(interaction));
                        return;
                    }
                }
                else
                {
                    //unsecure it
                    ToolUtils.ServerUseToolWithActionMessages(interaction, 4f,
                                                              "You start unsecuring the girder...",
                                                              $"{interaction.Performer.ExpensiveName()} starts unsecuring the window...",
                                                              "You unsecure the window.",
                                                              $"{interaction.Performer.ExpensiveName()} unsecures the window.",
                                                              () => objectBehaviour.ServerSetAnchored(false, interaction.Performer));
                }
            }
            else if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Wrench))
            {
                //disassemble if it's unanchored
                if (objectBehaviour.IsPushable)
                {
                    ToolUtils.ServerUseToolWithActionMessages(interaction, 4f,
                                                              "You start to disassemble the window...",
                                                              $"{interaction.Performer.ExpensiveName()} starts to disassemble the window...",
                                                              "You disassemble the window.",
                                                              $"{interaction.Performer.ExpensiveName()} disassembles the window.",
                                                              () => Disassemble(interaction));
                    return;
                }
                else
                {
                    Chat.AddExamineMsg(interaction.Performer, "You must unsecure it first.");
                }
            }
        }
Example #3
0
    public void ServerPerformInteraction(PositionalHandApply interaction)
    {
        if (reagentContainer.ReagentMixTotal < 1)
        {               //warning
            Chat.AddExamineMsg(interaction.Performer, "Your mop is dry!");
            return;
        }
        //server is performing server-side logic for the interaction
        //do the mopping
        void CompleteProgress()
        {
            CleanTile(interaction.WorldPositionTarget);
            Chat.AddExamineMsg(interaction.Performer, "You finish mopping.");
        }

        //Start the progress bar:
        var bar = StandardProgressAction.Create(ProgressConfig, CompleteProgress)
                  .ServerStartProgress(interaction.WorldPositionTarget.RoundToInt(),
                                       useTime, interaction.Performer);

        if (bar)
        {
            Chat.AddActionMsgToChat(interaction.Performer,
                                    $"You begin to clean the floor with {gameObject.ExpensiveName()}...",
                                    $"{interaction.Performer.name} begins to clean the floor with {gameObject.ExpensiveName()}.");
        }
    }
Example #4
0
 public bool WillInteract(HandApply interaction, NetworkSide side)
 {
     if (canPickUpGifts == false)
     {
         return(false);
     }
     if (DefaultWillInteract.Default(interaction, side) == false)
     {
         return(false);
     }
     if (interaction.HandSlot.IsOccupied)
     {
         return(false);
     }
     if (hasClicked)
     {
         Chat.AddExamineMsg(interaction.Performer, "You already received a gift!", side);
         return(false);
     }
     if (side == NetworkSide.Client)
     {
         hasClicked = true;
     }
     return(true);
 }
Example #5
0
        // TODO: Share with pipe tile deconstruction script
        private void TryUnwrench(HandApply interaction)
        {
            if (registerTile.TileChangeManager.MetaTileMap.HasTile(registerTile.LocalPositionServer, LayerType.Floors))
            {
                Chat.AddExamineMsg(
                    interaction.Performer,
                    $"The floor plating must be exposed before you can disconnect the {gameObject.ExpensiveName()}!");
                return;
            }

            // Dangerous pipe pressure
            if (pipeData.mixAndVolume.GetGasMix().Pressure > AtmosConstants.ONE_ATMOSPHERE * 20)
            {
                ToolUtils.ServerUseToolWithActionMessages(interaction, 3,
                                                          $"As you begin disconnecting the {gameObject.ExpensiveName()}, " +
                                                          "a jet of gas blasts into your face... maybe you should reconsider?",
                                                          string.Empty,
                                                          string.Empty, // $"The pressure sends you flying!"
                                                          string.Empty, // $"{interaction.Performer.ExpensiveName() is sent flying by pressure!"
                                                          () => {
                    Unwrench(interaction);
                    // TODO: Knock performer around.
                });
            }
            else
            {
                ToolUtils.ServerPlayToolSound(interaction);
                Unwrench(interaction);
            }
        }
Example #6
0
        private void TryInsertingContainer()
        {
            // TODO: this should probably be converted to using ItemStorage at some point.

            // Don't insert a container if one is already present, lest we wipe out the previous container from existence.
            if (HasContainerInserted)
            {
                Chat.AddExamineMsg(interaction.Performer, "A tank is already inside this canister.");
                return;
            }

            //always null check... always...
            if (interaction.UsedObject.TryGetComponent(out GasContainer gasContainer))
            {
                //copy the containers properties over, delete the container from the player's hand
                Chat.AddActionMsgToChat(interaction.Performer,
                                        $"You insert the {interaction.UsedObject.ExpensiveName()} into the canister.",
                                        $"{interaction.Performer.ExpensiveName()} inserts a tank into the {this.ContentsName} canister.");
                Inventory.ServerDrop(interaction.HandSlot);
                InsertedContainer = interaction.UsedObject;
                interaction.UsedObject.GetComponent <CustomNetTransform>().DisappearFromWorldServer();
                ServerOnExternalTankInserted.Invoke(true);
                RefreshOverlays();
            }
            else
            {
                Logger.LogError(
                    $"{interaction.Performer} tried inserting {interaction.UsedObject} into {gameObject}, " +
                    $"but the tank didn't have a {nameof(GasContainer)} component associated with it. " +
                    $"Something terrible has happened, or an item that should not has the CanisterFillable ItemTrait."
                    );
            }
        }
Example #7
0
 public void ServerPerformInteraction(HandApply interaction)
 {
     if (interaction.TargetObject.TryGetComponent <RemoteSignaller>(out var device))
     {
         Emitter = device;
         Chat.AddExamineMsg(interaction.Performer, $"You pair the {Emitter.gameObject.ExpensiveName()} to the {radio.gameObject.ExpensiveName()}");
     }
 }
Example #8
0
 public void ServerPerformInteraction(HandApply interaction)
 {
     if (interaction.TargetObject.TryGetComponent <ButtonSignalReceiver>(out var receiver))
     {
         receiver.Emitter = this;
         Chat.AddExamineMsg(interaction.Performer.gameObject, "You assign the receiver to this emitter.");
     }
 }
Example #9
0
    public void ServerPerformInteraction(HandApply interaction)
    {
        if (interaction.HandObject == null)
        {
            if (state == LightMountState.On)
            {
                Spawn.ServerPrefab(appliableItem, interaction.Performer.WorldPosServer());
                Chat.AddExamineMsg(interaction.Performer, "You took the light tube out!");
                ServerChangeLightState(LightMountState.MissingBulb);
            }
            else if (state == LightMountState.Off)
            {
                Spawn.ServerPrefab(appliableItem, interaction.Performer.WorldPosServer());
                Chat.AddExamineMsg(interaction.Performer, "You took the light tube out!");
                ServerChangeLightState(LightMountState.MissingBulb);
            }
            else if (state == LightMountState.Broken)
            {
                Spawn.ServerPrefab(appliableBrokenItem, interaction.Performer.WorldPosServer());
                Chat.AddExamineMsg(interaction.Performer, "You took the broken light tube out!");
                ServerChangeLightState(LightMountState.MissingBulb);
            }
        }
        else if (Validations.HasItemTrait(interaction.HandObject, traitRequired) && state == LightMountState.MissingBulb)
        {
            if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Broken))
            {
                Despawn.ServerSingle(interaction.HandObject);
                Chat.AddExamineMsg(interaction.Performer, "You put broken light tube in!");
                ServerChangeLightState(LightMountState.Broken);
            }
            else
            {
                if (lightSwitch == null)
                {
                    lightSwitch = lightSource.relatedLightSwitch;
                }

                if (lightSwitch == null)
                {
                    return;
                }

                if (lightSwitch.isOn == LightSwitch.States.On)
                {
                    Despawn.ServerSingle(interaction.HandObject);
                    Chat.AddExamineMsg(interaction.Performer, "You put light tube in!");
                    ServerChangeLightState(LightMountState.On);
                }
                else
                {
                    Despawn.ServerSingle(interaction.HandObject);
                    Chat.AddExamineMsg(interaction.Performer, "You put light tube in!");
                    ServerChangeLightState(LightMountState.Off);
                }
            }
        }
    }
Example #10
0
 public void ServerPerformInteraction(HandActivate interaction)
 {
     if (HasLoudSpeak)
     {
         LoudSpeakOn = !LoudSpeakOn;
         string result = LoudSpeakOn ? "turn on" : "turn off";
         Chat.AddExamineMsg(interaction.Performer, $"You {result} the {gameObject.ExpensiveName()}");
     }
 }
 public override void Do(GameObject player)
 {
     if (IsSameSpecies(player) == false)
     {
         Chat.AddExamineMsg(player, wrongSpeciesText);
         return;
     }
     base.Do(player);
 }
 private bool VerboseFloorExists()
 {
     if (MatrixManager.IsConstructable(registerTile.WorldPositionServer, registerTile.Matrix.MatrixInfo))
     {
         return(true);
     }
     Chat.AddExamineMsg(currentInteraction.Performer, $"A floor must be present to secure the {objectName}!");
     return(false);
 }
Example #13
0
        private void SpawnAshwalker(ConnectedPlayer player, bool costEgg = true)
        {
            //Since this is being called from an Action<> this could be null.
            if (this == null || gameObject == null)
            {
                //Remove the player from all roles (as createdRoleKey will Error)
                GhostRoleManager.Instance.ServerRemoveWaitingPlayer(player);
                Logger.LogError("Ghost role spawn called on null ashwalker, was the role not removed on destruction?");
                return;
            }

            var characterSettings = player.Script.characterSettings;

            if (characterSettings == null)
            {
                characterSettings = new CharacterSettings();
            }

            //TODO this replaces their old race, character settings needs a refactor to have them per body
            characterSettings.Species = ashwalkerRaceData.name;
            characterSettings.SerialisedExternalCustom.Clear();

            //Give random lizard name
            characterSettings.Name = StringManager.GetRandomLizardName(characterSettings.GetGender());

            //Respawn the player
            player.Script.playerNetworkActions.ServerRespawnPlayerSpecial("Ashwalker", registerTile.WorldPositionServer);

            //Wipe crafting recipes and add Ashwalker ones
            var crafting = player.Script.PlayerCrafting;

            crafting.ForgetAllRecipes();
            foreach (var recipe in ashwalkerCraftingRecipesList.CraftingRecipes)
            {
                crafting.LearnRecipe(recipe);
            }

            if (costEgg)
            {
                ashwalkerEggs--;
                SetSprite();
                Chat.AddLocalMsgToChat("An egg hatches in the nest!", gameObject);
            }
            else
            {
                Chat.AddLocalMsgToChat("An creature emerges from the nest. Glory to the Necropolis!", gameObject);
            }

            //Decrease the remaining roles
            GhostRoleManager.Instance.ServerUpdateRole(createdRoleKey, 1, ashwalkerEggs, -1);

            //Remove the player so they can join again once they die
            GhostRoleManager.Instance.ServerRemoveWaitingPlayer(createdRoleKey, player);

            Chat.AddExamineMsg(player.GameObject, "You have been pulled back from beyond the grave, with a new body and renewed purpose. Glory to the Necropolis!");
        }
Example #14
0
    public void ServerPerformInteraction(HandApply interaction)
    {
        if (interaction.TargetObject != gameObject)
        {
            return;
        }

        else if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Screwdriver))
        {
            if (objectBehaviour.IsPushable)
            {
                //secure it if there's floor
                if (MatrixManager.IsSpaceAt(registerObject.WorldPositionServer, true))
                {
                    Chat.AddExamineMsg(interaction.Performer, "A floor must be present to secure the grille!");
                    return;
                }

                if (!ServerValidations.IsAnchorBlocked(interaction))
                {
                    ToolUtils.ServerUseToolWithActionMessages(interaction, 0.5f,
                                                              "You start securing the grille...",
                                                              $"{interaction.Performer.ExpensiveName()} starts securing the grille...",
                                                              "You secure the grille.",
                                                              $"{interaction.Performer.ExpensiveName()} secures the grille.",
                                                              () => ScrewInPlace(interaction));


                    return;
                }
            }
            else
            {
                //unsecure it
                ToolUtils.ServerUseToolWithActionMessages(interaction, 0.5f,
                                                          "You start unsecuring the grille...",
                                                          $"{interaction.Performer.ExpensiveName()} starts unsecuring the grille...",
                                                          "You unsecure the grille.",
                                                          $"{interaction.Performer.ExpensiveName()} unsecures the grille.",
                                                          () => objectBehaviour.ServerSetAnchored(false, interaction.Performer));
                SoundManager.PlayNetworkedAtPos("screwdriver2", gameObject.TileWorldPosition().To3Int(), Random.Range(0.9f, 1.1f));
            }
        }
        else if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Wirecutter))
        {
            ToolUtils.ServerUseToolWithActionMessages(interaction, 1f,
                                                      "You start to disassemble the grille...",
                                                      $"{interaction.Performer.ExpensiveName()} starts to disassemble the grille...",
                                                      "You disassemble the grille.",
                                                      $"{interaction.Performer.ExpensiveName()} disassembles the grille.",
                                                      () => Disassemble(interaction));


            return;
        }
    }
Example #15
0
    public void ServerPerformInteraction(InventoryApply interaction)
    {
        if (interaction.UsedObject == null || interaction.Performer == null)
        {
            return;
        }
        MagazineBehaviour clip = interaction.UsedObject.GetComponent <MagazineBehaviour>();

        Chat.AddExamineMsg(interaction.Performer, LoadFromClip(clip));
    }
Example #16
0
        bool VerboseFloorExists()
        {
            if (!MatrixManager.IsSpaceAt(registerObject.WorldPositionServer, true))
            {
                return(true);
            }

            Chat.AddExamineMsg(currentInteraction.Performer, $"A floor must be present to secure the {objectAttributes.InitialName}!");
            return(false);
        }
        /// <summary>
        /// Attaches a note to the package. This will modify its examine message.
        /// This method should only be called from server.
        /// </summary>
        /// <param name="performer"></param>
        /// <param name="text"></param>
        private void AttachNote(GameObject performer, string text)
        {
            if (noteText.IsNullOrEmpty() == false && performer != null)
            {
                Chat.AddExamineMsg(performer, $"{gameObject.ExpensiveName()} already has a note attached to it!");
                return;
            }

            ServerSetNoteText(text);
        }
 private bool IsFull(GameObject usedObject, GameObject player)
 {
     if (itemStorage.GetNextFreeIndexedSlot() == null && usedObject != null)
     {
         Chat.AddExamineMsg(player,
                            $"<color=red>The {usedObject.ExpensiveName()} won't fit in the {itemStorage.gameObject.ExpensiveName()}. Make some space!</color>");
         return(true);
     }
     return(false);
 }
Example #19
0
    public IEnumerator Emp(int EmpStrength)
    {
        int effectTime = (int)(EmpStrength * 0.75f);

        isEMPed = true;
        Chat.AddExamineMsg(PlayerManager.LocalPlayerScript.gameObject, $"Your {gameObject.ExpensiveName()} suddenly becomes very quiet...");
        yield return(WaitFor.Seconds(effectTime));

        isEMPed = false;
        Chat.AddExamineMsg(PlayerManager.LocalPlayerScript.gameObject, $"Your {gameObject.ExpensiveName()} became emmiting buzz and radio messages again.");
    }
Example #20
0
        private void Orbit(GameObject thingToOrbit)
        {
            if (thingToOrbit == null)
            {
                return;
            }
            target = thingToOrbit;

            netTransform.SetPosition(target.AssumedWorldPosServer(), false);
            UpdateManager.Add(FollowTarget, 0.1f);
            Chat.AddExamineMsg(gameObject, $"You start orbiting {thingToOrbit.ExpensiveName()}");
        }
Example #21
0
 public void ServerPerformInteraction(HandApply interaction)
 {
     if (interaction.IsAltClick == false)
     {
         return;
     }
     if (interaction.TargetObject.TryGetComponent <DoorSwitch>(out var @switch))
     {
         Chat.AddExamineMsg(interaction.Performer.gameObject, "You assign the switch to the receiver.");
         doorSwitch = @switch;
     }
 }
Example #22
0
        bool VerbosePipeTerminalExists()
        {
            if (PipeTerminalExists())
            {
                return(true);
            }

            Chat.AddExamineMsg(
                currentInteraction.Performer,
                $"The {objectAttributes.InitialName} needs a {PIPE_TERMINAL_NAME} underneath!");
            return(false);
        }
Example #23
0
        bool VerbosePlatingExposed()
        {
            if (FloorPlatingExposed())
            {
                return(true);
            }

            Chat.AddExamineMsg(
                currentInteraction.Performer,
                $"The floor plating must be exposed before you can secure the {objectAttributes.InitialName} to the floor!");
            return(false);
        }
Example #24
0
        private bool VerbosePlatingExposed()
        {
            if (tileChangeManager.MetaTileMap.HasTile(registerTile.LocalPositionServer, LayerType.Floors) == false)
            {
                return(true);
            }

            Chat.AddExamineMsg(
                currentInteraction.Performer,
                $"The floor plating must be exposed before you can secure the {objectName} to the floor!");
            return(false);
        }
Example #25
0
        private void StopOrbiting()
        {
            if (target == null)
            {
                return;
            }

            Chat.AddExamineMsg(gameObject, $"You stop orbiting {target.ExpensiveName()}");
            target = null;
            UpdateManager.Remove(CallbackType.PERIODIC_UPDATE, FollowTarget);
            ResetRotate();
        }
Example #26
0
    public void ServerPerformInteraction(InventoryApply interaction)
    {
        if (interaction.UsedObject == null || interaction.Performer == null)
        {
            return;
        }
        MagazineBehaviour clip     = interaction.UsedObject.GetComponent <MagazineBehaviour>();
        MagazineBehaviour usedclip = interaction.TargetObject.GetComponent <MagazineBehaviour>();
        string            message  = usedclip.LoadFromClip(clip);

        Chat.AddExamineMsg(interaction.Performer, message);
    }
Example #27
0
 public void ServerPerformInteraction(InventoryApply interaction)
 {
     isOn = !isOn;
     Chat.AddExamineMsg(interaction.Performer, isOn ? "You open the valve" : "You close the valve");
     if (isOn)
     {
         player = interaction.PerformerPlayerScript;
         UpdateManager.Add(PushUpdate, 0.1f);
         return;
     }
     UpdateManager.Remove(CallbackType.PERIODIC_UPDATE, PushUpdate);
 }
Example #28
0
        public void ServerPerformInteraction(HandApply interaction)
        {
            // Locking/Unlocking by alt clicking
            if (interaction.IsAltClick)
            {
                if (IsLockable && AccessRestrictions != null && ClosetStatus.Equals(ClosetStatus.Closed))
                {
                    // Default CheckAccess will check for the ID slot first
                    // so the default AltClick interaction will prioritize
                    // the ID slot, only when that would fail the hand
                    // will be checked, alternatively the user can also
                    // just click the locker with the ID inhand.
                    if (AccessRestrictions.CheckAccess(interaction.Performer))
                    {
                        if (isLocked)
                        {
                            SyncLocked(isLocked, false);
                            Chat.AddExamineMsg(interaction.Performer, $"You unlock the {closetName}.");
                        }
                        else
                        {
                            SyncLocked(isLocked, true);
                            Chat.AddExamineMsg(interaction.Performer, $"You lock the {closetName}.");
                        }
                    }
                }

                // Alt clicking is the locker's only alt click behaviour.
                return;
            }

            // Is the player trying to put something in the closet?
            if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Emag) &&
                interaction.HandObject.TryGetComponent <Emag>(out var emag) &&
                emag.EmagHasCharges())
            {
                if (IsClosed && !isEmagged)
                {
                    AudioSourceParameters audioSourceParameters = new AudioSourceParameters(pitch: 1f);
                    SoundManager.PlayNetworkedAtPos(soundOnEmag, registerTile.WorldPositionServer, audioSourceParameters, gameObject);
                    //ServerHandleContentsOnStatusChange(false);

                    isEmagged = true;
                    emag.UseCharge(interaction);
                    Chat.AddActionMsgToChat(interaction,
                                            "The access panel errors. A slight amount of smoke pours from behind the panel...",
                                            "You can smell caustic smoke from somewhere...");

                    //SyncStatus(statusSync, ClosetStatus.Open);
                    BreakLock();
                }
            }
 public void ToggleBroadcastMode()
 {
     stationBoundRadio.BroadcastToNearbyTiles = broadcastModeToggle.isOn;
     if (emittingDevice.gameObject.TryGetComponent <Pickupable>(out var pick))
     {
         if (pick.ItemSlot?.ItemStorage.OrNull()?.Player == null)
         {
             return;
         }
         string status = emittingDevice.IsPowered ? "broadcast messages to everyone nearby" : "broadcast messages for you only";
         Chat.AddExamineMsg(pick.ItemSlot.ItemStorage.Player.gameObject, $"this device will now {status}");
     }
 }
 public void ToggleDevicePower()
 {
     emittingDevice.IsPowered = radioPowerToggle.isOn;
     if (emittingDevice.gameObject.TryGetComponent <Pickupable>(out var pick))
     {
         if (pick.ItemSlot?.ItemStorage.OrNull()?.Player == null)
         {
             return;
         }
         string status = emittingDevice.IsPowered ? "on" : "off";
         Chat.AddExamineMsg(pick.ItemSlot.ItemStorage.Player.gameObject, $"this device is now turned {status}");
     }
 }