diff --git a/Assets/Resources/TheGame/RealityRebootKit.asset b/Assets/Resources/TheGame/RealityRebootKit.asset index 553829b..3f0b867 100755 --- a/Assets/Resources/TheGame/RealityRebootKit.asset +++ b/Assets/Resources/TheGame/RealityRebootKit.asset @@ -12,8 +12,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ae5fb4e9fdf89f64b8d2e2d147cb0231, type: 3} m_Name: RealityRebootKit m_EditorClassIdentifier: - initializeOnLoad: 1 - coreServices: {fileID: 11400000, guid: f075fa2d60632ae4f9449445a2b794fa, type: 2} + inputConfig: + inputActionAsset: {fileID: -944628639613478452, guid: f991e9abd9a53ee4b94b329a5ce96cb2, type: 3} gamePrefab: {fileID: 7133476019135208936, guid: 04a34e58b066c014eaaeb846b2bd3213, type: 3} mainMenuScene: m_AssetGUID: abb7fe7f372ba7640b0ab138239c7f78 diff --git a/Assets/jelycho/Code/Abilities/AbilityAsset.cs b/Assets/jelycho/Code/Abilities/AbilityAsset.cs index b586d52..6432b39 100644 --- a/Assets/jelycho/Code/Abilities/AbilityAsset.cs +++ b/Assets/jelycho/Code/Abilities/AbilityAsset.cs @@ -1,5 +1,4 @@ -using RebootKit.Engine.Services.Simulation; -using RebootKit.Engine.Simulation; +using RebootKit.Engine.Simulation; using RebootReality.jelycho.Main; using UnityEngine; diff --git a/Assets/jelycho/Code/Items/Inventory.cs b/Assets/jelycho/Code/Items/Inventory.cs new file mode 100644 index 0000000..7ba8ed3 --- /dev/null +++ b/Assets/jelycho/Code/Items/Inventory.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using RebootKit.Engine.Foundation; + +namespace RebootReality.jelycho.Items { + public class Inventory { + static readonly Logger s_Logger = new Logger(nameof(Inventory)); + + class ItemState { + public List Actors = new List(); + } + + readonly ItemState[] m_Items; + + public event Action OnItemPickedUp = delegate { }; + public event Action OnItemDropped = delegate { }; + public event Action OnSlotUpdated = delegate { }; + + public int SlotsCount { + get { + return m_Items.Length; + } + } + + public Inventory(int slotsCount) { + m_Items = new ItemState[slotsCount]; + + for (int i = 0; i < slotsCount; i++) { + m_Items[i] = new ItemState(); + } + } + + public bool TryPickup(ItemActor actor) { + if (Contains(actor)) { + s_Logger.Error($"Item {actor.name} is already in the inventory."); + return false; + } + + (int slotIndex, ItemState freeItemState) = FindFreeItemState(); + if (freeItemState == null) { + s_Logger.Error("Inventory is full, cannot pick up item."); + return false; + } + + freeItemState.Actors.Add(actor); + OnItemPickedUp?.Invoke(actor); + OnSlotUpdated?.Invoke(slotIndex); + return true; + } + + public bool TryDrop(ItemActor actor) { + for (int i = 0; i < m_Items.Length; i++) { + if (m_Items[i].Actors.Remove(actor)) { + OnItemDropped?.Invoke(actor); + OnSlotUpdated?.Invoke(i); + return true; + } + } + + s_Logger.Error($"Item {actor.name} is not in the inventory."); + return false; + } + + public int GetQuantity(int slotIndex) { + if (slotIndex < 0 || slotIndex >= m_Items.Length) { + throw new ArgumentOutOfRangeException(nameof(slotIndex), "Slot index is out of range."); + } + + return m_Items[slotIndex].Actors.Count; + } + + public ItemActor GetFirstItem(int slotIndex) { + if (slotIndex < 0 || slotIndex >= m_Items.Length) { + throw new ArgumentOutOfRangeException(nameof(slotIndex), "Slot index is out of range."); + } + + if (m_Items[slotIndex].Actors.Count > 0) { + return m_Items[slotIndex].Actors[0]; + } + + s_Logger.Error($"No items in slot {slotIndex}."); + return null; + } + + public bool Contains(ItemActor actor) { + for (int i = 0; i < m_Items.Length; i++) { + if (m_Items[i].Actors.Contains(actor)) { + return true; + } + } + return false; + } + + (int, ItemState) FindFreeItemState() { + for (int i = 0; i < m_Items.Length; i++) { + if (m_Items[i].Actors.Count == 0) { + return (i, m_Items[i]); + } + } + return (-1, null); + } + } +} \ No newline at end of file diff --git a/Assets/jelycho/Code/Items/Inventory.cs.meta b/Assets/jelycho/Code/Items/Inventory.cs.meta new file mode 100644 index 0000000..68c0518 --- /dev/null +++ b/Assets/jelycho/Code/Items/Inventory.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f84c0e35a7df482c8c7de30104bd05f2 +timeCreated: 1752181679 \ No newline at end of file diff --git a/Assets/jelycho/Code/Items/ItemActor.cs b/Assets/jelycho/Code/Items/ItemActor.cs index 2682153..b282279 100644 --- a/Assets/jelycho/Code/Items/ItemActor.cs +++ b/Assets/jelycho/Code/Items/ItemActor.cs @@ -1,19 +1,30 @@ using RebootKit.Engine.Simulation; using Unity.Netcode; +using UnityEngine; +using Logger = RebootKit.Engine.Foundation.Logger; namespace RebootReality.jelycho.Items { - public class ItemActor : Actor { + public class ItemActor : Actor, IInteractable { + static readonly Logger s_Logger = new Logger(nameof(ItemActor)); + class ItemActorData : IActorData { - public string ItemID; + public ItemConfig Config; public void Serialize(FastBufferWriter writer) { } public void Deserialize(FastBufferReader reader) { } } + + [field: SerializeField] public ItemConfig Config { get; private set; } protected override IActorData CreateActorData() { - return new ItemActorData(); + return new ItemActorData { + Config = Config + }; + } + + public void Interact() { } } } \ No newline at end of file diff --git a/Assets/jelycho/Code/Items/ItemConfig.cs b/Assets/jelycho/Code/Items/ItemConfig.cs new file mode 100644 index 0000000..cde19a6 --- /dev/null +++ b/Assets/jelycho/Code/Items/ItemConfig.cs @@ -0,0 +1,11 @@ +using System; +using Unity.Collections; +using UnityEngine; + +namespace RebootReality.jelycho.Items { + [Serializable] + public struct ItemConfig { + public FixedString32Bytes itemID; + public Sprite icon; + } +} \ No newline at end of file diff --git a/Assets/jelycho/Code/Items/ItemConfig.cs.meta b/Assets/jelycho/Code/Items/ItemConfig.cs.meta new file mode 100644 index 0000000..3060dbd --- /dev/null +++ b/Assets/jelycho/Code/Items/ItemConfig.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7870350a856f43c19d9b830b9eeb7a46 +timeCreated: 1752164733 \ No newline at end of file diff --git a/Assets/jelycho/Code/Main/JelychoGame.cs b/Assets/jelycho/Code/Main/JelychoGame.cs index bf89aeb..3974eb9 100755 --- a/Assets/jelycho/Code/Main/JelychoGame.cs +++ b/Assets/jelycho/Code/Main/JelychoGame.cs @@ -1,8 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using RebootKit.Engine.Console; using RebootKit.Engine.Main; -using RebootKit.Engine.Services.Console; -using RebootKit.Engine.Services.Simulation; +using RebootKit.Engine.Simulation; using RebootReality.jelycho.Player; +using RebootReality.jelycho.Player.HUD; using Unity.Collections; using Unity.Netcode; using UnityEngine; @@ -11,7 +13,7 @@ using Logger = RebootKit.Engine.Foundation.Logger; namespace RebootReality.jelycho.Main { class PlayerState : INetworkSerializable { - public ulong clientID; + public ulong ClientID; public PlayerController Controller; public PlayerActor Actor; @@ -25,7 +27,7 @@ namespace RebootReality.jelycho.Main { [Header("Player")] [SerializeField] PlayerController m_PlayerControllerPrefab; [SerializeField] PlayerActor m_PlayerActorPrefab; - + readonly List m_PlayerStates = new List(); void Awake() { } @@ -72,7 +74,7 @@ namespace RebootReality.jelycho.Main { controller.NetworkObject.SpawnAsPlayerObject(clientID); m_PlayerStates.Add(new PlayerState { - clientID = clientID, + ClientID = clientID, Controller = controller, }); } @@ -83,7 +85,7 @@ namespace RebootReality.jelycho.Main { if (IsServer) { for (int i = m_PlayerStates.Count - 1; i >= 0; i--) { - if (m_PlayerStates[i].clientID == clientID) { + if (m_PlayerStates[i].ClientID == clientID) { s_Logger.Info($"Removing player state for client {clientID}"); m_PlayerStates.RemoveAtSwapBack(i); break; @@ -94,7 +96,7 @@ namespace RebootReality.jelycho.Main { PlayerState GetPlayerState(ulong clientID) { foreach (PlayerState state in m_PlayerStates) { - if (state.clientID == clientID) { + if (state.ClientID == clientID) { return state; } } diff --git a/Assets/jelycho/Code/Outlines.meta b/Assets/jelycho/Code/Outlines.meta new file mode 100644 index 0000000..05a785f --- /dev/null +++ b/Assets/jelycho/Code/Outlines.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 16de37dffae64252bb9e33ebe89e9266 +timeCreated: 1752151116 \ No newline at end of file diff --git a/Assets/jelycho/Code/Outlines/OutlinesRendererFeature.cs b/Assets/jelycho/Code/Outlines/OutlinesRendererFeature.cs new file mode 100644 index 0000000..f32f855 --- /dev/null +++ b/Assets/jelycho/Code/Outlines/OutlinesRendererFeature.cs @@ -0,0 +1,25 @@ +using UnityEngine.Rendering; +using UnityEngine.Rendering.RenderGraphModule; +using UnityEngine.Rendering.Universal; + +namespace RebootReality.jelycho.Outlines { + public class OutlinesRendererFeature : ScriptableRendererFeature { + class OutlinesRenderPass : ScriptableRenderPass { + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { + base.RecordRenderGraph(renderGraph, frameData); + } + } + + OutlinesRenderPass m_RenderPass; + + public override void Create() { + m_RenderPass = new OutlinesRenderPass { + renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing + }; + } + + public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) { + renderer.EnqueuePass(m_RenderPass); + } + } +} \ No newline at end of file diff --git a/Assets/jelycho/Code/Outlines/OutlinesRendererFeature.cs.meta b/Assets/jelycho/Code/Outlines/OutlinesRendererFeature.cs.meta new file mode 100644 index 0000000..a96890d --- /dev/null +++ b/Assets/jelycho/Code/Outlines/OutlinesRendererFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4926ff5ce47e454fad5255be684a85b7 +timeCreated: 1752151128 \ No newline at end of file diff --git a/Assets/jelycho/Code/Player/FPPCamera.cs b/Assets/jelycho/Code/Player/FPPCamera.cs index e26419a..c0b0cfc 100644 --- a/Assets/jelycho/Code/Player/FPPCamera.cs +++ b/Assets/jelycho/Code/Player/FPPCamera.cs @@ -1,6 +1,5 @@ using System; using RebootKit.Engine.Foundation; -using RebootKit.Engine.Services.Simulation.Sensors; using RebootKit.Engine.Simulation.Sensors; using RebootReality.jelycho.Main; using Unity.Cinemachine; diff --git a/Assets/jelycho/Code/Player/GenericSensor.cs b/Assets/jelycho/Code/Player/GenericSensor.cs new file mode 100644 index 0000000..787c678 --- /dev/null +++ b/Assets/jelycho/Code/Player/GenericSensor.cs @@ -0,0 +1,41 @@ +using System; +using RebootKit.Engine.Simulation.Sensors; +using UnityEngine; + +namespace RebootReality.jelycho.Player { + [Serializable] + public struct GenericSensor : ISensor { + [SerializeField] Transform m_Origin; + [SerializeField] LayerMask m_LayerMask; + [SerializeField] float m_MaxDistance; + + public GameObject Sense() { + Ray ray = new Ray(m_Origin.position, m_Origin.forward); + + if (Physics.Raycast(ray, out RaycastHit hit, m_MaxDistance, m_LayerMask)) { + return hit.collider.gameObject; + } + + return null; + } + } + + [Serializable] + public struct GenericSensor : ISensor where T : class { + [SerializeField] Transform m_Origin; + [SerializeField] LayerMask m_LayerMask; + [SerializeField] float m_MaxDistance; + + public T Sense() { + Ray ray = new Ray(m_Origin.position, m_Origin.forward); + + if (Physics.Raycast(ray, out RaycastHit hit, m_MaxDistance, m_LayerMask)) { + if (hit.collider.TryGetComponent(out T component)) { + return component; + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/Assets/jelycho/Code/Player/GenericSensor.cs.meta b/Assets/jelycho/Code/Player/GenericSensor.cs.meta new file mode 100644 index 0000000..65537e2 --- /dev/null +++ b/Assets/jelycho/Code/Player/GenericSensor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 584138e7a2834fbaa3f29d381ee6d0f5 +timeCreated: 1752181704 \ No newline at end of file diff --git a/Assets/jelycho/Code/Player/HUD.meta b/Assets/jelycho/Code/Player/HUD.meta new file mode 100644 index 0000000..8388b22 --- /dev/null +++ b/Assets/jelycho/Code/Player/HUD.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 433c5938a11248afa61f1ced56bd407d +timeCreated: 1752067932 \ No newline at end of file diff --git a/Assets/jelycho/Code/Player/HUD/ObjectsLabelsVC.cs b/Assets/jelycho/Code/Player/HUD/ObjectsLabelsVC.cs new file mode 100644 index 0000000..3ade1f4 --- /dev/null +++ b/Assets/jelycho/Code/Player/HUD/ObjectsLabelsVC.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using RebootKit.Engine.Main; +using Unity.Collections; +using UnityEngine; +using UnityEngine.Pool; +using UnityEngine.UIElements; + +namespace RebootReality.jelycho.Player.HUD { + public class ObjectsLabelsVC : MonoBehaviour { + [SerializeField] UIDocument m_Document; + [SerializeField] VisualTreeAsset m_LabelTemplate; + + IObjectPool m_LabelPool; + + readonly List m_ActiveLabels = new List(); + + void Awake() { + m_LabelPool = new ObjectPool(() => { + LabelEntry entry = new LabelEntry(); + entry.Parent = this; + + entry.Root = new VisualElement(); + entry.Root.style.position = Position.Absolute; + entry.Root.style.visibility = Visibility.Hidden; + entry.Root.style.minWidth = 300; + entry.Root.style.height = 64; + + m_LabelTemplate.CloneTree(entry.Root); + entry.Label = entry.Root.Q