private void Indocrinate(GameObject target) { if (Random.value > 0.2f) { Chat.AddWarningMsgFromServer(target, Messages.PickRandom()); } else { Chat.AddWarningMsgFromServer(target, DrasticMessages.PickRandom()); } }
private bool CanSell(VendorItem itemToSpawn, ConnectedPlayer player) { // check if selected item is valid var isSelectionValid = (itemToSpawn != null && itemToSpawn.Stock > 0); if (!isSelectionValid) { return(false); } // check if this player has vending cooldown right now if (VendingCooldown) { if (player != null && player.Script) { var hasCooldown = !Cooldowns.TryStartServer(player.Script, VendingCooldown); if (hasCooldown) { return(false); } } } // check player access if (player != null && accessRestrictions && !isEmagged) { var hasAccess = accessRestrictions.CheckAccess(player.GameObject); if (!hasAccess) { Chat.AddWarningMsgFromServer(player.GameObject, noAccessMessage); return(false); } } if (itemToSpawn.Price > 0) { var playerStorage = player.GameObject.GetComponent <ItemStorage>(); var idCardObj = playerStorage.GetNamedItemSlot(NamedSlot.id).ItemObject; var idCard = AccessRestrictions.GetIDCard(idCardObj); if (idCard.currencies[(int)itemToSpawn.Currency] >= itemToSpawn.Price) { idCard.currencies[(int)itemToSpawn.Currency] -= itemToSpawn.Price; } else { Chat.AddWarningMsgFromServer(player.GameObject, tooExpensiveMessage); return(false); } } return(isSelectionValid); }
public void ServerPerformInteraction(HandApply interaction) { if (interaction.HandObject == null && securable.IsAnchored) { if (!isOn) { if (!TryToggleOn()) { Chat.AddWarningMsgFromServer(interaction.Performer, $"The generator needs more fuel!"); } } else { ToggleOff(); } } else { foreach (ItemTrait fuelType in fuelTypes) { if (Validations.HasItemTrait(interaction.HandObject, fuelType)) { int amountTransfered; var handStackable = interaction.HandObject.GetComponent <Stackable>(); if (itemSlot.Item) { var stackable = itemSlot.Item.GetComponent <Stackable>(); if (stackable.SpareCapacity == 0) { Chat.AddWarningMsgFromServer(interaction.Performer, "The generator sheet storage is full!"); return; } amountTransfered = stackable.ServerCombine(handStackable); } else { amountTransfered = handStackable.Amount; Inventory.ServerTransfer(interaction.HandSlot, itemSlot, ReplacementStrategy.DropOther); } Chat.AddExamineMsgFromServer(interaction.Performer, $"You fill the generator sheet storage with {amountTransfered.ToString()} more."); } } } }
public virtual void TryFeed(HandApply touchSource) { //Hand touched if (touchSource.HandObject == null) { Chat.AddWarningMsgFromServer(touchSource.Performer, emptyHandMessages.PickRandom()); return; } //Check for right itemtrait if (!Validations.HasAnyTrait(touchSource.HandObject, acceptedItems)) { Chat.AddWarningMsgFromServer(touchSource.Performer, wrongItemMessages.PickRandom()); return; } //Is correct item if (despawnItemOnFeed) { if (touchSource.HandObject.TryGetComponent <Stackable>(out var stackable)) { if (!stackable.ServerConsume(howManyToConsume)) { //Not enough items in stack Chat.AddExamineMsgFromServer(touchSource.Performer, "The artifact looks unimpressed"); return; } } else { Despawn.ServerSingle(touchSource.HandObject); } } Chat.AddExamineMsgFromServer(touchSource.Performer, acceptedItemMessages.PickRandom()); StartCoroutine(Timer(touchSource)); }
private bool CanSell(VendorItem itemToSpawn, ConnectedPlayer player) { // check if selected item is valid var isSelectionValid = (itemToSpawn != null && itemToSpawn.Stock > 0); if (!isSelectionValid) { return(false); } // check if this player has vending cooldown right now if (VendingCooldown) { if (player != null && player.Script) { var hasCooldown = !Cooldowns.TryStartServer(player.Script, VendingCooldown); if (hasCooldown) { return(false); } } } // check player access if (player != null && accessRestrictions) { var hasAccess = accessRestrictions.CheckAccess(player.GameObject); if (!hasAccess) { Chat.AddWarningMsgFromServer(player.GameObject, noAccessMessage); return(false); } } return(isSelectionValid); }
private bool CanSell(VendorItem itemToSpawn, ConnectedPlayer player) { // check if selected item is valid var isSelectionValid = itemToSpawn != null && itemToSpawn.Stock > 0; if (isSelectionValid == false) { return(false); } // check if this player has vending cooldown right now if (VendingCooldown) { if (player != null && player.Script) { var hasCooldown = !Cooldowns.TryStartServer(player.Script, VendingCooldown); if (hasCooldown) { return(false); } } } /* --ACCESS REWORK-- * TODO Remove the AccessRestriction check when we finish migrating! * */ // check player access if (player != null && (accessRestrictions || clearanceCheckable) && !isEmagged) { var hasAccess = accessRestrictions ? accessRestrictions.CheckAccess(player.GameObject) : clearanceCheckable.HasClearance(player.GameObject); if (hasAccess == false && player.Script.PlayerState != PlayerScript.PlayerStates.Ai) { Chat.AddWarningMsgFromServer(player.GameObject, noAccessMessage); return(false); } } if (itemToSpawn.Price > 0) { var playerStorage = player.GameObject.GetComponent <DynamicItemStorage>(); var itemSlotList = playerStorage.GetNamedItemSlots(NamedSlot.id); foreach (var itemSlot in itemSlotList) { if (itemSlot.ItemObject) { var idCard = AccessRestrictions.GetIDCard(itemSlot.ItemObject); if (idCard.currencies[(int)itemToSpawn.Currency] >= itemToSpawn.Price) { idCard.currencies[(int)itemToSpawn.Currency] -= itemToSpawn.Price; break; } else { Chat.AddWarningMsgFromServer(player.GameObject, tooExpensiveMessage); return(false); } } } } return(isSelectionValid); }