public bool Interact(MouseDrop interaction) { Logger.Log("Interaction detected on InteractableTiles."); LayerTile tile = LayerTileAt(interaction.ShadowWorldLocation, true); if (tile is BasicTile basicTile) { var tileApply = new TileApply(interaction.Performer, interaction.UsedObject, interaction.Intent, (Vector2Int)WorldToCell(interaction.ShadowWorldLocation), this, basicTile, null, -((Vector2)interaction.Performer.transform.position - interaction.ShadowWorldLocation), TileApply.ApplyType.MouseDrop); var tileMouseDrop = new TileMouseDrop(interaction.Performer, interaction.UsedObject, interaction.Intent, (Vector2Int)WorldToCell(interaction.ShadowWorldLocation), this, basicTile, -((Vector2)interaction.Performer.transform.position - interaction.ShadowWorldLocation)); foreach (var tileInteraction in basicTile.TileInteractions) { if (tileInteraction == null) { continue; } if (tileInteraction.WillInteract(tileApply, NetworkSide.Client) && Cooldowns.TryStartClient(interaction, CommonCooldowns.Instance.Interaction)) { //request the tile interaction because we think one will happen RequestInteractMessage.SendTileMouseDrop(tileMouseDrop, this); return(true); } } } return(false); }
public static void SendTileMouseDrop(TileMouseDrop mouseDrop, InteractableTiles interactableTiles) { if (!mouseDrop.Performer.Equals(PlayerManager.LocalPlayer)) { Logger.LogError("Client attempting to perform an interaction on behalf of another player." + " This is not allowed. Client can only perform an interaction as themselves. Message" + " will not be sent.", Category.Exploits); return; } var msg = new NetMessage() { ComponentType = typeof(InteractableTiles), InteractionType = typeof(TileMouseDrop), ProcessorObject = GetNetId(interactableTiles.gameObject), Intent = mouseDrop.Intent, UsedObject = GetNetId(mouseDrop.UsedObject), TargetVector = mouseDrop.TargetVector }; Send(msg); }
public static void SendTileMouseDrop(TileMouseDrop mouseDrop, InteractableTiles interactableTiles) { if (!mouseDrop.Performer.Equals(PlayerManager.LocalPlayer)) { Logger.LogError("Client attempting to perform an interaction on behalf of another player." + " This is not allowed. Client can only perform an interaction as themselves. Message" + " will not be sent.", Category.NetMessage); return; } var msg = new RequestInteractMessage() { ComponentType = typeof(InteractableTiles), InteractionType = typeof(TileMouseDrop), ProcessorObject = interactableTiles.GetComponent <NetworkIdentity>().netId, Intent = mouseDrop.Intent, UsedObject = mouseDrop.UsedObject.NetId(), TargetVector = mouseDrop.TargetVector }; msg.Send(); }