Added RocketAssemblyStation and ReadyRocket
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
using Unity.Netcode;
|
||||
|
||||
public interface IHandItemUseAction
|
||||
{
|
||||
bool TryUseOnServer(NetworkObject playerObject);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1e6d4d81ab34d2e9ee3a1bfa201f131
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1e6d4d81ab34d2e9ee3a1bfa201f132
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user