stuff
This commit is contained in:
@@ -2,11 +2,10 @@
|
||||
using R3;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using RebootReality.jelycho.Player.HUD;
|
||||
using Unity.Mathematics;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.InputSystem;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
@@ -49,49 +48,48 @@ namespace RebootReality.jelycho.Player {
|
||||
}
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
public void SetActorClientRpc(ulong networkObjectID) {
|
||||
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(networkObjectID,
|
||||
out NetworkObject networkObject)) {
|
||||
m_Actor = networkObject.GetComponent<PlayerActor>();
|
||||
s_Logger.Info($"Found Player Actor NetworkObject ID: {networkObjectID}");
|
||||
protected override void OnPossessActor(Actor actor) {
|
||||
if (actor is PlayerActor playerActor) {
|
||||
m_Actor = playerActor;
|
||||
} else {
|
||||
s_Logger.Error($"Failed to find PlayerActor with NetworkObject ID: {networkObjectID}");
|
||||
m_Actor = null;
|
||||
}
|
||||
|
||||
if (m_Actor is null) {
|
||||
s_Logger.Error($"Tried to possess non-PlayerActor: {actor.GetType().Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsServer) {
|
||||
if (RR.World.Context is WorldContext worldContext) {
|
||||
m_Actor.WarpToServerRpc(worldContext.PlayerSpawnPoint.position);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsOwner) {
|
||||
m_Actor.SetupAsOwner();
|
||||
|
||||
m_OwnerActorDisposableBag.Dispose();
|
||||
m_OwnerActorDisposableBag = new DisposableBag();
|
||||
|
||||
m_Actor.TargetInteractable.Subscribe(interactable => {
|
||||
if (m_TargetInteractableLabelDisposable != null) {
|
||||
m_TargetInteractableLabelDisposable.Dispose();
|
||||
m_TargetInteractableLabelDisposable = null;
|
||||
}
|
||||
|
||||
if (interactable is MonoBehaviour mb) {
|
||||
if (interactable is Actor interactableActor) {
|
||||
m_TargetInteractableLabelDisposable =
|
||||
m_HUD.ObjectsLabels.CreateLabel(mb.transform, mb.name);
|
||||
m_HUD.ObjectsLabels.CreateLabel(interactableActor.transform,
|
||||
interactableActor.ActorName);
|
||||
}
|
||||
})
|
||||
.AddTo(ref m_OwnerActorDisposableBag);
|
||||
|
||||
m_HUD.SetPlayerActor(m_Actor);
|
||||
}
|
||||
|
||||
if (IsServer) {
|
||||
if (RR.World.Context is WorldContext worldContext) {
|
||||
m_Actor.WarpTo(worldContext.PlayerSpawnPoint.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
public void SetNullActorClientRpc() {
|
||||
protected override void OnUnpossessActor(Actor actor) {
|
||||
base.OnUnpossessActor(actor);
|
||||
|
||||
m_OwnerActorDisposableBag.Dispose();
|
||||
m_OwnerActorDisposableBag = new DisposableBag();
|
||||
m_Actor = null;
|
||||
@@ -126,6 +124,10 @@ namespace RebootReality.jelycho.Player {
|
||||
m_Actor.StopDrag();
|
||||
}
|
||||
|
||||
if (m_Config.dropItemActionReference.action.WasReleasedThisFrame()) {
|
||||
m_Actor.DropItem();
|
||||
}
|
||||
|
||||
if (m_Config.primaryActionReference.action.WasReleasedThisFrame()) {
|
||||
m_Actor.PrimaryAction();
|
||||
}
|
||||
@@ -137,7 +139,7 @@ namespace RebootReality.jelycho.Player {
|
||||
if (m_Config.interactActionReference.action.WasReleasedThisFrame()) {
|
||||
m_Actor.Interact();
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < m_Config.inventorySlotSelectActionReferences.Length; i++) {
|
||||
if (m_Config.inventorySlotSelectActionReferences[i].action.WasReleasedThisFrame()) {
|
||||
m_Actor.SelectItemSlot(i);
|
||||
@@ -163,10 +165,11 @@ namespace RebootReality.jelycho.Player {
|
||||
public InputActionReference jumpActionReference;
|
||||
public InputActionReference sprintActionReference;
|
||||
public InputActionReference dragObjectActionReference;
|
||||
public InputActionReference dropItemActionReference;
|
||||
public InputActionReference primaryActionReference;
|
||||
public InputActionReference secondaryActionReference;
|
||||
public InputActionReference interactActionReference;
|
||||
|
||||
|
||||
public InputActionReference[] inventorySlotSelectActionReferences;
|
||||
public InputActionReference inventorySlotChangeActionReference;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user