39 lines
956 B
C#
39 lines
956 B
C#
using System;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
namespace Reset.Items{
|
|
public class ItemDrop : NetworkBehaviour, IInteractable{
|
|
public Item item;
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start(){
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update(){
|
|
|
|
}
|
|
|
|
public void Interact(){
|
|
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsConnectedClient) {
|
|
Debug.Log("RPC Sent");
|
|
DestroyOnOwnerRpc();
|
|
} else {
|
|
Debug.Log("Destroyed");
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
public void CancelInteract(){
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
[Rpc(SendTo.Owner)]
|
|
public void DestroyOnOwnerRpc(){
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|