public void ServerPerformInteraction(InventoryApply interaction) { ToolUtils.ServerPlayToolSound(interaction); Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, interaction.Performer.WorldPosServer().CutToInt(), transform.parent, count: 1, scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true); Inventory.ServerDespawn(interaction.FromSlot); }
public void ServerPerformInteraction(PositionalHandApply interaction) { wallPrefab.GetComponent <PosterBehaviour>().posterVariant = posterVariant; wallPrefab.GetComponent <Rotatable>().SetFaceDirectionLocalVictor((interaction.Performer.TileLocalPosition() - interaction.TargetPosition).To2Int()); Spawn.ServerPrefab(wallPrefab, interaction.WorldPositionTarget.RoundToInt(), interaction.Performer.transform.parent); Inventory.ServerDespawn(interaction.HandSlot); }
public void ServerPerformInteraction(PositionalHandApply interaction) { wallPrefab.GetComponent <PosterBehaviour>().posterVariant = posterVariant; wallPrefab.GetComponent <Directional>().InitialDirection = Orientation .From(interaction.Performer.TileWorldPosition() - interaction.WorldPositionTarget).AsEnum(); Spawn.ServerPrefab(wallPrefab, interaction.WorldPositionTarget.RoundToInt(), interaction.Performer.transform.parent); Inventory.ServerDespawn(interaction.HandSlot); }
public void ServerPerformInteraction(HandApply interaction) { // Checks to see if stackableMaterials is not true (false) if so just despawn the item in hand if (stackableMaterials != true) { Inventory.ServerDespawn(interaction.HandObject); } else { // If stackableMaterials IS true then consume the amount set by material cost interaction.HandObject.GetComponent <Stackable>().ServerConsume(materialCost); } // Spawns assembly and despawns self Spawn.ServerPrefab(assembly, gameObject.RegisterTile().WorldPosition, transform.parent, count: 1); _ = Despawn.ServerSingle(gameObject); }
public virtual void Eat(PlayerScript eater, PlayerScript feeder) { //TODO: Reimplement metabolism. SoundManager.PlayNetworkedAtPos(sound, eater.WorldPos, sourceObj: eater.gameObject); var Stomachs = eater.playerHealth.GetStomachs(); if (Stomachs.Count == 0) { //No stomachs?! return; } FoodContents.Divide(Stomachs.Count); foreach (var Stomach in Stomachs) { Stomach.StomachContents.Add(FoodContents.CurrentReagentMix.Clone()); } var feederSlot = feeder.ItemStorage.GetActiveHandSlot(); //If food has a stack component, decrease amount by one instead of deleting the entire stack. if (stackable != null) { stackable.ServerConsume(1); } else { Inventory.ServerDespawn(gameObject); } if (leavings != null) { var leavingsInstance = Spawn.ServerPrefab(leavings).GameObject; var pickupable = leavingsInstance.GetComponent <Pickupable>(); bool added = Inventory.ServerAdd(pickupable, feederSlot); if (!added) { //If stackable has leavings and they couldn't go in the same slot, they should be dropped pickupable.CustomNetTransform.SetPosition(feeder.WorldPos); } } }
public void ServerPerformInteraction(PositionalHandApply interaction) { if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Wrench)) { ToolUtils.ServerPlayToolSound(interaction); Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, interaction.WorldPositionTarget.RoundToInt(), transform.parent, count: 1, scatterRadius: Spawn.DefaultScatterRadius, cancelIfImpassable: true); _ = Despawn.ServerSingle(gameObject); return; } void ProgressComplete() { Chat.AddExamineMsgFromServer(interaction.Performer, "You assemble a rack."); Spawn.ServerPrefab(rackPrefab, interaction.WorldPositionTarget.RoundToInt(), interaction.Performer.transform.parent); var handObj = interaction.HandObject; if (handObj != null && handObj.GetInstanceID() == gameObject.GetInstanceID()) // the rack parts were assembled from the hands, despawn in inventory-fashion { // (note: instanceIDs used in case somebody starts assembling rack parts on the ground with rack parts in hand (which was not possible at the time this was written)) Inventory.ServerDespawn(interaction.HandSlot); } else // the rack parts were assembled from the ground, despawn in general fashion { _ = Despawn.ServerSingle(gameObject); } } var bar = StandardProgressAction.Create(ProgressConfig, ProgressComplete) .ServerStartProgress(interaction.WorldPositionTarget.RoundToInt(), 5f, interaction.Performer); if (bar != null) { Chat.AddExamineMsgFromServer(interaction.Performer, "You start constructing a rack..."); } }