Added RocketAssemblyStation and ReadyRocket
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public sealed class NetworkUsableHandItemInteractable : NetworkHandItemInteractable
|
||||
{
|
||||
[Tooltip("Component on this prefab implementing IHandItemUseAction.")]
|
||||
[SerializeField] private MonoBehaviour useActionComponent;
|
||||
|
||||
private IHandItemUseAction UseAction => useActionComponent as IHandItemUseAction;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
ResolveUseAction();
|
||||
}
|
||||
|
||||
private void OnValidate() => ResolveUseAction();
|
||||
|
||||
protected override void UseOnServer(NetworkObject playerObject)
|
||||
{
|
||||
if (UseAction == null)
|
||||
{
|
||||
Debug.LogWarning(
|
||||
$"{name} was used but has no IHandItemUseAction component assigned.",
|
||||
this);
|
||||
return;
|
||||
}
|
||||
|
||||
UseAction.TryUseOnServer(playerObject);
|
||||
}
|
||||
|
||||
private void ResolveUseAction()
|
||||
{
|
||||
if (useActionComponent is IHandItemUseAction)
|
||||
return;
|
||||
|
||||
foreach (MonoBehaviour component in GetComponents<MonoBehaviour>())
|
||||
{
|
||||
if (component is IHandItemUseAction)
|
||||
{
|
||||
useActionComponent = component;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
useActionComponent = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user