public void ServerPerformInteraction(PositionalHandApply interaction) { PlayerNetworkActions pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); if (interaction.HandObject == null) { // No item in hand, so let's TEACH THIS RACK A LESSON Chat.AddCombatMsgToChat(interaction.Performer, "You kick the rack. Nice job!", interaction.Performer.ExpensiveName() + " kicks the rack."); integrity.ApplyDamage(Random.Range(4, 8), AttackType.Melee, DamageType.Brute); return; } // If the player is using a wrench on the rack, deconstruct it if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Wrench) && interaction.Intent != Intent.Help) { SoundManager.PlayNetworkedAtPos("Wrench", interaction.WorldPositionTarget, 1f); Spawn.ServerPrefab(rackParts, interaction.WorldPositionTarget.RoundToInt(), interaction.TargetObject.transform.parent); Despawn.ServerSingle(gameObject); return; } // Like a table, but everything is neatly stacked. Vector3 targetPosition = interaction.WorldPositionTarget.RoundToInt(); targetPosition.z = -0.2f; pna.CmdPlaceItem(interaction.HandSlot.NamedSlot.GetValueOrDefault(NamedSlot.none), targetPosition, interaction.Performer, true); }
public void ServerPerformInteraction(PositionalHandApply interaction) { PlayerNetworkActions pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); if (interaction.HandObject == null) { // No item in hand, so let's TEACH THIS RACK A LESSON Chat.AddCombatMsgToChat(interaction.Performer, "You kick the rack. Nice job!", interaction.Performer.ExpensiveName() + " kicks the rack."); integrity.ApplyDamage(Random.Range(4, 8), AttackType.Melee, DamageType.Brute); return; } // If the player is using a wrench on the rack, deconstruct it if (Validations.IsTool(interaction.HandObject, ToolType.Wrench) && !interaction.Performer.Player().Script.playerMove.IsHelpIntent) { SoundManager.PlayNetworkedAtPos("Wrench", interaction.WorldPositionTarget, 1f); PoolManager.PoolNetworkInstantiate(rackParts, interaction.WorldPositionTarget.RoundToInt(), interaction.TargetObject.transform.parent); PoolManager.PoolNetworkDestroy(gameObject); return; } // Like a table, but everything is neatly stacked. Vector3 targetPosition = interaction.WorldPositionTarget.RoundToInt(); targetPosition.z = -0.2f; pna.CmdPlaceItem(interaction.HandSlot.equipSlot, targetPosition, interaction.Performer, true); }
protected override void ServerPerformInteraction(HandApply interaction) { //Is the player trying to put something in the closet if (interaction.HandObject != null && !IsClosed) { PlayerNetworkActions pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); pna.CmdPlaceItem(interaction.HandSlot.SlotName, registerTile.WorldPosition, null, false); } else if (!IsLocked) { ToggleLocker(); } }
private bool DetermineTileAction(GameObject originator, Vector3 position, string hand) { metaTileMap = originator.GetComponentInParent <MetaTileMap>(); objectLayer = originator.GetComponentInParent <ObjectLayer>(); PlayerNetworkActions pna = originator.GetComponent <PlayerNetworkActions>(); Vector3Int pos = objectLayer.transform.InverseTransformPoint(position).RoundToInt(); pos.z = 0; Vector3Int cellPos = baseTileMap.WorldToCell(position); LayerTile tile = metaTileMap.GetTile(pos); GameObject handObj; //if we are client, our pna.Inventory is always empty so we should get the hand item a different way if (!isServer) { if (originator != PlayerManager.LocalPlayer) { Logger.LogError("Client is attempting to determine the tile actions of a player other than" + " themselves. This should not happen and should be fixed. Client should only determine their own" + " actions."); return(false); } else { handObj = UIManager.InventorySlots[hand].Item; } } else { handObj = pna.Inventory[hand].Item; } // Nothing in hand, do nothing if (handObj == null) { return(false); } if (tile != null) { switch (tile.TileType) { case TileType.Table: { Vector3 targetPosition = position; targetPosition.z = -0.2f; pna.CmdPlaceItem(hand, targetPosition, originator, true); return(true); } case TileType.Floor: { //Crowbar if (handObj.GetComponent <CrowbarTrigger>()) { pna.CmdCrowBarRemoveFloorTile(originator, LayerType.Floors, new Vector2(cellPos.x, cellPos.y), position); return(true); } break; } case TileType.Base: { if (handObj.GetComponent <UniFloorTile>()) { pna.CmdPlaceFloorTile(originator, new Vector2(cellPos.x, cellPos.y), handObj); return(true); } break; } case TileType.Window: { //Check Melee: MeleeTrigger melee = windowTileMap.gameObject.GetComponent <MeleeTrigger>(); if (melee != null && melee.MeleeInteract(originator, hand)) { return(true); } break; } case TileType.Grill: { //Check Melee: MeleeTrigger melee = grillTileMap.gameObject.GetComponent <MeleeTrigger>(); if (melee != null && melee.MeleeInteract(originator, hand)) { return(true); } break; } case TileType.Wall: { Welder welder = handObj.GetComponent <Welder>(); if (welder) { if (welder.isOn) { //Request to deconstruct from the server: RequestTileDeconstructMessage.Send(originator, gameObject, TileType.Wall, cellPos, position); return(true); } } break; } } } return(false); }
private bool DetermineTileAction(GameObject originator, Vector3 position, string hand) { metaTileMap = originator.GetComponentInParent <MetaTileMap>(); objectLayer = originator.GetComponentInParent <ObjectLayer>(); PlayerNetworkActions pna = originator.GetComponent <PlayerNetworkActions>(); Vector3Int pos = objectLayer.transform.InverseTransformPoint(position).RoundToInt(); pos.z = 0; Vector3Int cellPos = baseTileMap.WorldToCell(position); LayerTile tile = metaTileMap.GetTile(pos); GameObject handObj = UIManager.Hands.CurrentSlot.Item; // Nothing in hand, do nothing if (handObj == null) { return(false); } if (tile != null) { switch (tile.TileType) { case TileType.Table: { Vector3 targetPosition = position; targetPosition.z = -0.2f; pna.CmdPlaceItem(hand, targetPosition, originator, true); return(true); } case TileType.Floor: { //Crowbar if (handObj.GetComponent <CrowbarTrigger>()) { pna.CmdCrowBarRemoveFloorTile(originator, LayerType.Floors, new Vector2(cellPos.x, cellPos.y), position); return(true); } break; } case TileType.Base: { if (handObj.GetComponent <UniFloorTile>()) { pna.CmdPlaceFloorTile(originator, new Vector2(cellPos.x, cellPos.y), handObj); return(true); } break; } case TileType.Window: { //Check Melee: MeleeTrigger melee = windowTileMap.gameObject.GetComponent <MeleeTrigger>(); if (melee != null && melee.MeleeInteract(originator, hand)) { return(true); } break; } case TileType.Grill: { //Check Melee: MeleeTrigger melee = grillTileMap.gameObject.GetComponent <MeleeTrigger>(); if (melee != null && melee.MeleeInteract(originator, hand)) { return(true); } break; } case TileType.Wall: { Welder welder = handObj.GetComponent <Welder>(); if (welder) { if (welder.isOn) { //Request to deconstruct from the server: RequestTileDeconstructMessage.Send(originator, gameObject, TileType.Wall, cellPos, position); return(true); } } break; } } } return(false); }
public bool Interact(PositionalHandApply interaction) { if (!DefaultWillInteract.PositionalHandApply(interaction, NetworkSide.Client)) { return(false); } PlayerNetworkActions pna = interaction.Performer.GetComponent <PlayerNetworkActions>(); Vector3Int pos = objectLayer.transform.InverseTransformPoint(interaction.WorldPositionTarget).RoundToInt(); pos.z = 0; Vector3Int cellPos = baseLayer.WorldToCell(interaction.WorldPositionTarget); LayerTile tile = metaTileMap.GetTile(pos); if (tile != null) { switch (tile.TileType) { case TileType.Table: { Vector3 targetPosition = interaction.WorldPositionTarget; targetPosition.z = -0.2f; pna.CmdPlaceItem(interaction.HandSlot.equipSlot, targetPosition, interaction.Performer, true); return(true); } case TileType.Floor: { //Crowbar if (Validations.IsTool(interaction.HandObject, ToolType.Crowbar)) { pna.CmdCrowBarRemoveFloorTile(interaction.Performer, LayerType.Floors, new Vector2(cellPos.x, cellPos.y), interaction.WorldPositionTarget); return(true); } break; } case TileType.Base: { if (Validations.HasComponent <UniFloorTile>(interaction.HandObject)) { pna.CmdPlaceFloorTile(interaction.Performer, new Vector2(cellPos.x, cellPos.y), interaction.HandObject); return(true); } break; } case TileType.Window: { //Check Melee: Meleeable melee = windowLayer.gameObject.GetComponent <Meleeable>(); if (melee != null && melee.Interact(PositionalHandApply.ByLocalPlayer(gameObject))) { return(true); } break; } case TileType.Grill: { //Check Melee: Meleeable melee = grillTileMap.gameObject.GetComponent <Meleeable>(); if (melee != null && melee.Interact(PositionalHandApply.ByLocalPlayer(gameObject))) { return(true); } break; } case TileType.Wall: { Welder welder = interaction.HandObject != null?interaction.HandObject.GetComponent <Welder>() : null; if (welder != null) { if (welder.isOn) { //Request to deconstruct from the server: RequestTileDeconstructMessage.Send(interaction.Performer, gameObject, TileType.Wall, cellPos, interaction.WorldPositionTarget); return(true); } } break; } } } return(false); }