removed old stuff
This commit is contained in:
@@ -66,7 +66,8 @@ namespace RebootReality.jelycho {
|
||||
|
||||
async UniTask PressAsync() {
|
||||
m_Graphics.localScale = new Vector3(1, 0.1f, 1);
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(m_CooldownDuration), cancellationToken: destroyCancellationToken);
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(m_CooldownDuration),
|
||||
cancellationToken: destroyCancellationToken);
|
||||
m_Graphics.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace RebootReality.jelycho.Items {
|
||||
[Serializable]
|
||||
public struct ItemActorMountingConfig {
|
||||
public AssetReferenceGameObject actor;
|
||||
[MaxLength(32)] public string slotName;
|
||||
[InfoBox("Max length: 32")] public string slotName;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -41,7 +41,7 @@ namespace RebootReality.jelycho.Items {
|
||||
public ulong baseDamage = 10;
|
||||
|
||||
[Header("Mounting")]
|
||||
[MaxLength(32)] public string characterEquippedMountSlotName = "hand_right";
|
||||
[InfoBox("Max length: 32")] public string characterEquippedMountSlotName = "hand_right";
|
||||
|
||||
public ItemActorMountingConfig[] additionalActorsToMount;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using R3;
|
||||
using RebootKit.Engine.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
@@ -14,32 +13,41 @@ namespace RebootReality.jelycho.Player.HUD {
|
||||
[field: SerializeField] public PlayerInventoryUI InventoryUI { get; private set; }
|
||||
|
||||
PlayerActor m_PlayerActor;
|
||||
DisposableBag m_ActorBag;
|
||||
|
||||
void OnEnable() {
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
InventoryUI.CleanUp();
|
||||
m_ActorBag.Dispose();
|
||||
}
|
||||
|
||||
public void SetPlayerActor(PlayerActor actor) {
|
||||
m_ActorBag.Dispose();
|
||||
|
||||
if (actor == null) {
|
||||
m_PlayerActor = null;
|
||||
InventoryUI.CleanUp();
|
||||
UnsetPlayerActor();
|
||||
|
||||
if (actor.OrNull() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_ActorBag = new DisposableBag();
|
||||
m_PlayerActor = actor;
|
||||
InventoryUI.Configure(m_MainDocument.rootVisualElement.Q("player-hud__inventory-slots"), actor.Inventory);
|
||||
|
||||
actor.SelectedInventorySlot.Subscribe(x => {
|
||||
InventoryUI.SetSelectedSlot(x);
|
||||
}).AddTo(ref m_ActorBag);
|
||||
actor.OnSelectedInventorySlotChanged += OnInventorySelectedSlotChanged;
|
||||
InventoryUI.SetSelectedSlot(actor.SelectedInventorySlot);
|
||||
}
|
||||
|
||||
void UnsetPlayerActor() {
|
||||
if (m_PlayerActor.OrNull() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_PlayerActor.OnSelectedInventorySlotChanged -= OnInventorySelectedSlotChanged;
|
||||
|
||||
m_PlayerActor = null;
|
||||
InventoryUI.CleanUp();
|
||||
}
|
||||
|
||||
void OnInventorySelectedSlotChanged(int newIndex) {
|
||||
InventoryUI.SetSelectedSlot(newIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using R3;
|
||||
using RebootKit.Engine.Extensions;
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Network;
|
||||
@@ -77,7 +76,20 @@ namespace RebootReality.jelycho.Player {
|
||||
[SerializeField] int m_InventorySize = 10;
|
||||
|
||||
public Inventory Inventory { get; private set; }
|
||||
public ReactiveProperty<int> SelectedInventorySlot { get; private set; } = new ReactiveProperty<int>(0);
|
||||
|
||||
int m_SelectedInventorySlotIndex = 0;
|
||||
public int SelectedInventorySlot {
|
||||
get {
|
||||
return m_SelectedInventorySlotIndex;
|
||||
}
|
||||
|
||||
set {
|
||||
m_SelectedInventorySlotIndex = value;
|
||||
OnSelectedInventorySlotChanged?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
public Action<int> OnSelectedInventorySlotChanged = delegate {};
|
||||
|
||||
ItemActor m_EquippedItem;
|
||||
|
||||
@@ -109,13 +121,21 @@ namespace RebootReality.jelycho.Player {
|
||||
}
|
||||
}
|
||||
|
||||
readonly ReactiveProperty<IInteractable> m_TargetInteractable = new ReactiveProperty<IInteractable>(null);
|
||||
public ReadOnlyReactiveProperty<IInteractable> TargetInteractable {
|
||||
IInteractable m_TargetInteractable = null;
|
||||
public IInteractable TargetInteractable {
|
||||
get {
|
||||
return m_TargetInteractable;
|
||||
}
|
||||
|
||||
private set {
|
||||
s_Logger.Info("NEW");
|
||||
m_TargetInteractable = value;
|
||||
OnTargetInteractableChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
public Action<IInteractable> OnTargetInteractableChanged = delegate {};
|
||||
|
||||
readonly List<Actor> m_AdditionalMountedActor = new List<Actor>();
|
||||
|
||||
protected override IActorData CreateActorData() {
|
||||
@@ -195,7 +215,7 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
if (m_EquippedItem != null) {
|
||||
var command = new PlayerActorDropItemCommand {
|
||||
InventorySlotIndex = (byte) SelectedInventorySlot.Value
|
||||
InventorySlotIndex = (byte) SelectedInventorySlot
|
||||
};
|
||||
SendActorCommand((byte) PlayerActorCommands.DropItem, ref command);
|
||||
}
|
||||
@@ -362,10 +382,10 @@ namespace RebootReality.jelycho.Player {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_TargetInteractable.Value is ItemActor itemActor) {
|
||||
if (TargetInteractable is ItemActor itemActor) {
|
||||
Pickup(itemActor);
|
||||
} else if (m_TargetInteractable.Value is not null) {
|
||||
m_TargetInteractable.Value.Interact();
|
||||
} else if (TargetInteractable is not null) {
|
||||
TargetInteractable.Interact();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,7 +499,7 @@ namespace RebootReality.jelycho.Player {
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedInventorySlot.Value = command.SlotIndex;
|
||||
SelectedInventorySlot = command.SlotIndex;
|
||||
UpdateEquippedItem();
|
||||
break;
|
||||
}
|
||||
@@ -650,8 +670,13 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
void SenseInteractable() {
|
||||
IInteractable interactable = m_InteractablesSensor.Sense();
|
||||
if (interactable != m_TargetInteractable.Value) {
|
||||
m_TargetInteractable.Value = interactable;
|
||||
if (interactable != null) {
|
||||
s_Logger.Info("NOT NULL");
|
||||
}
|
||||
|
||||
if (interactable != TargetInteractable) {
|
||||
s_Logger.Info("sensed different interactable");
|
||||
TargetInteractable = interactable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,7 +776,7 @@ namespace RebootReality.jelycho.Player {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemActor itemActor = Inventory.GetItem(SelectedInventorySlot.Value);
|
||||
ItemActor itemActor = Inventory.GetItem(SelectedInventorySlot);
|
||||
if (itemActor == m_EquippedItem) {
|
||||
return;
|
||||
}
|
||||
@@ -910,14 +935,14 @@ namespace RebootReality.jelycho.Player {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SelectedInventorySlot.Value > 0) {
|
||||
SelectedInventorySlot.Value--;
|
||||
if (SelectedInventorySlot > 0) {
|
||||
SelectedInventorySlot--;
|
||||
} else {
|
||||
SelectedInventorySlot.Value = Inventory.SlotsCount - 1;
|
||||
SelectedInventorySlot = Inventory.SlotsCount - 1;
|
||||
}
|
||||
|
||||
var command = new PlayerActorSelectItemSlotCommand {
|
||||
SlotIndex = SelectedInventorySlot.Value
|
||||
SlotIndex = SelectedInventorySlot
|
||||
};
|
||||
SendActorCommand((byte) PlayerActorCommands.SelectItemSlot, ref command);
|
||||
}
|
||||
@@ -928,14 +953,14 @@ namespace RebootReality.jelycho.Player {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SelectedInventorySlot.Value < Inventory.SlotsCount - 1) {
|
||||
SelectedInventorySlot.Value++;
|
||||
if (SelectedInventorySlot < Inventory.SlotsCount - 1) {
|
||||
SelectedInventorySlot++;
|
||||
} else {
|
||||
SelectedInventorySlot.Value = 0;
|
||||
SelectedInventorySlot = 0;
|
||||
}
|
||||
|
||||
var command = new PlayerActorSelectItemSlotCommand {
|
||||
SlotIndex = SelectedInventorySlot.Value
|
||||
SlotIndex = SelectedInventorySlot
|
||||
};
|
||||
SendActorCommand((byte) PlayerActorCommands.SelectItemSlot, ref command);
|
||||
}
|
||||
@@ -951,10 +976,10 @@ namespace RebootReality.jelycho.Player {
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedInventorySlot.Value = slotIndex;
|
||||
SelectedInventorySlot = slotIndex;
|
||||
|
||||
var command = new PlayerActorSelectItemSlotCommand {
|
||||
SlotIndex = SelectedInventorySlot.Value
|
||||
SlotIndex = SelectedInventorySlot
|
||||
};
|
||||
SendActorCommand((byte) PlayerActorCommands.SelectItemSlot, ref command);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using R3;
|
||||
using RebootKit.Engine.Extensions;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Network;
|
||||
@@ -19,7 +19,6 @@ namespace RebootReality.jelycho.Player {
|
||||
PlayerActor m_Actor;
|
||||
PlayerHUD m_HUD;
|
||||
|
||||
DisposableBag m_OwnerActorDisposableBag = new DisposableBag();
|
||||
IDisposable m_TargetInteractableLabelDisposable;
|
||||
|
||||
IInteractable m_Interactable;
|
||||
@@ -34,7 +33,9 @@ namespace RebootReality.jelycho.Player {
|
||||
m_HUD = null;
|
||||
}
|
||||
|
||||
m_OwnerActorDisposableBag.Dispose();
|
||||
if (m_Actor.OrNull() != null) {
|
||||
UnsubscribeFromPlayerActorEvents();
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable() {
|
||||
@@ -57,28 +58,8 @@ namespace RebootReality.jelycho.Player {
|
||||
}
|
||||
|
||||
m_Actor.SetupAsOwner();
|
||||
|
||||
m_OwnerActorDisposableBag.Dispose();
|
||||
m_OwnerActorDisposableBag = new DisposableBag();
|
||||
|
||||
m_Actor.TargetInteractable.Subscribe(interactable => {
|
||||
m_Interactable?.SetHighlight(false);
|
||||
|
||||
if (m_TargetInteractableLabelDisposable != null) {
|
||||
m_TargetInteractableLabelDisposable.Dispose();
|
||||
m_TargetInteractableLabelDisposable = null;
|
||||
}
|
||||
|
||||
m_Interactable = interactable;
|
||||
m_Interactable?.SetHighlight(true);
|
||||
|
||||
if (interactable is Actor interactableActor) {
|
||||
m_TargetInteractableLabelDisposable =
|
||||
m_HUD.ObjectsLabels.CreateLabel(interactableActor.transform,
|
||||
interactableActor.ActorName);
|
||||
}
|
||||
})
|
||||
.AddTo(ref m_OwnerActorDisposableBag);
|
||||
m_Actor.OnTargetInteractableChanged += OnTargetInteractableChanged;
|
||||
OnTargetInteractableChanged(m_Actor.TargetInteractable);
|
||||
|
||||
m_HUD.SetPlayerActor(m_Actor);
|
||||
|
||||
@@ -89,11 +70,37 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
protected override void OnUnpossessActor(Actor actor) {
|
||||
base.OnUnpossessActor(actor);
|
||||
|
||||
m_OwnerActorDisposableBag.Dispose();
|
||||
m_OwnerActorDisposableBag = new DisposableBag();
|
||||
|
||||
UnsubscribeFromPlayerActorEvents();
|
||||
m_Actor = null;
|
||||
}
|
||||
|
||||
void UnsubscribeFromPlayerActorEvents() {
|
||||
if (m_Actor.OrNull() == null) {
|
||||
s_Logger.Error("Cannot unsubscribe from player actor events: actor is not set");
|
||||
return;
|
||||
}
|
||||
|
||||
m_Actor.OnTargetInteractableChanged -= OnTargetInteractableChanged;
|
||||
}
|
||||
|
||||
void OnTargetInteractableChanged(IInteractable interactable) {
|
||||
m_Interactable?.SetHighlight(false);
|
||||
|
||||
if (m_TargetInteractableLabelDisposable != null) {
|
||||
m_TargetInteractableLabelDisposable.Dispose();
|
||||
m_TargetInteractableLabelDisposable = null;
|
||||
}
|
||||
|
||||
m_Interactable = interactable;
|
||||
m_Interactable?.SetHighlight(true);
|
||||
|
||||
if (interactable is Actor interactableActor) {
|
||||
m_TargetInteractableLabelDisposable =
|
||||
m_HUD.ObjectsLabels.CreateLabel(interactableActor.transform,
|
||||
interactableActor.ActorName);
|
||||
}
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (m_Actor is null) {
|
||||
|
||||
Reference in New Issue
Block a user