feat: add initial architecture
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
using Game.Shared.Domain;
|
||||
|
||||
namespace Game.Features.Player.Domain;
|
||||
|
||||
public class PlayerData
|
||||
{
|
||||
public EntityId Id { get; private set; }
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cjblpuqhlu1yf
|
||||
@@ -0,0 +1,10 @@
|
||||
using Game.Features.Player.Domain;
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
namespace Game.Features.Player.Godot;
|
||||
|
||||
public partial class PlayerController : Node3D
|
||||
{
|
||||
[Export] public CharacterBody3D Body;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://mjm7ghkibnxa
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,13 @@
|
||||
[gd_scene format=3 uid="uid://curuqmbndymi6"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://blkhom228sqgi" path="res://assets/models/floor_ceiling_hr_4.glb" id="1_7nnv3"]
|
||||
|
||||
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_7nnv3"]
|
||||
points = PackedVector3Array(-2, 2.861023e-06, -2, -2, 2.861023e-06, 2, -2, 0.4000031, -2, 2, 2.861023e-06, -2, -2, 0.39996395, 2, 2, 2.861023e-06, 2, 2, 0.4000031, -2, 2, 0.39996395, 2)
|
||||
|
||||
[node name="floor_ceiling_hr_42" unique_id=33949496 instance=ExtResource("1_7nnv3")]
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." index="1" unique_id=1729023140]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="0" unique_id=1193592610]
|
||||
shape = SubResource("ConvexPolygonShape3D_7nnv3")
|
||||
@@ -0,0 +1,8 @@
|
||||
using Game.Features.Player.Godot;
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class GameWorld : Node
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://drctu5y21ey2y
|
||||
@@ -0,0 +1,56 @@
|
||||
[gd_scene format=3 uid="uid://c44pljehe0qun"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b5i827vmueyei" path="res://assets/textures/skyboxes/skybox_emx_19.png" id="1_g4n7o"]
|
||||
[ext_resource type="PackedScene" uid="uid://curuqmbndymi6" path="res://src/Infrastructure/Floor/FloorCeilingHr42.tscn" id="2_1kpcd"]
|
||||
[ext_resource type="PackedScene" uid="uid://bka1dmgdi5btd" path="res://src/Features/Player/Godot/PlayerNode.tscn" id="2_mvtit"]
|
||||
|
||||
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_epykj"]
|
||||
panorama = ExtResource("1_g4n7o")
|
||||
|
||||
[sub_resource type="Sky" id="Sky_1kpcd"]
|
||||
sky_material = SubResource("PanoramaSkyMaterial_epykj")
|
||||
|
||||
[sub_resource type="Environment" id="Environment_mvtit"]
|
||||
background_mode = 2
|
||||
sky = SubResource("Sky_1kpcd")
|
||||
glow_enabled = true
|
||||
|
||||
[node name="GameWorld" type="Node" unique_id=222644234]
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1669211403]
|
||||
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=847581298]
|
||||
environment = SubResource("Environment_mvtit")
|
||||
|
||||
[node name="Player" parent="." unique_id=26823676 instance=ExtResource("2_mvtit")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
|
||||
[node name="Entities" type="Node3D" parent="." unique_id=851492709]
|
||||
|
||||
[node name="floor_ceiling_hr_46" parent="Entities" unique_id=33949496 instance=ExtResource("2_1kpcd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 4)
|
||||
|
||||
[node name="floor_ceiling_hr_47" parent="Entities" unique_id=277851190 instance=ExtResource("2_1kpcd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 4)
|
||||
|
||||
[node name="floor_ceiling_hr_44" parent="Entities" unique_id=1904740552 instance=ExtResource("2_1kpcd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, -4)
|
||||
|
||||
[node name="floor_ceiling_hr_45" parent="Entities" unique_id=1096250035 instance=ExtResource("2_1kpcd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -4)
|
||||
|
||||
[node name="floor_ceiling_hr_43" parent="Entities" unique_id=1799505353 instance=ExtResource("2_1kpcd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 0)
|
||||
|
||||
[node name="floor_ceiling_hr_42" parent="Entities" unique_id=1144273698 instance=ExtResource("2_1kpcd")]
|
||||
|
||||
[node name="floor_ceiling_hr_48" parent="Entities" unique_id=252704215 instance=ExtResource("2_1kpcd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 0, 4)
|
||||
|
||||
[node name="floor_ceiling_hr_49" parent="Entities" unique_id=1131416798 instance=ExtResource("2_1kpcd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 0, -4)
|
||||
|
||||
[node name="floor_ceiling_hr_50" parent="Entities" unique_id=1804933431 instance=ExtResource("2_1kpcd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 0, 0)
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Game.Shared.Events;
|
||||
|
||||
public interface IEvent
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bc6g3mar6am56
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Game.Shared.Events;
|
||||
|
||||
public interface IEventBus
|
||||
{
|
||||
IDisposable Subscribe<TEvent>(Action<TEvent> handler) where TEvent : IEvent;
|
||||
|
||||
void Publish<TEvent>(TEvent gameEvent) where TEvent : IEvent;
|
||||
|
||||
void Clear();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c6txowanjmm5j
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Game.Shared.Events;
|
||||
|
||||
public sealed class InMemoryEventBus : IEventBus
|
||||
{
|
||||
private readonly Dictionary<Type, List<Delegate>> _handlers = [];
|
||||
private readonly object _lock = new();
|
||||
|
||||
public IDisposable Subscribe<TEvent>(Action<TEvent> handler) where TEvent : IEvent
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(handler);
|
||||
|
||||
var eventType = typeof(TEvent);
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
if (!_handlers.TryGetValue(eventType, out var list))
|
||||
{
|
||||
list = [];
|
||||
_handlers[eventType] = list;
|
||||
}
|
||||
|
||||
list.Add(handler);
|
||||
}
|
||||
|
||||
return new EventSubscription(() => Unsubscribe(eventType, handler));
|
||||
}
|
||||
|
||||
public void Publish<TEvent>(TEvent gameEvent) where TEvent : IEvent
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(gameEvent);
|
||||
|
||||
List<Delegate> snapshot = null;
|
||||
var eventType = typeof(TEvent);
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
if (_handlers.TryGetValue(eventType, out var list))
|
||||
{
|
||||
snapshot = new List<Delegate>(list);
|
||||
}
|
||||
}
|
||||
|
||||
if (snapshot == null) return;
|
||||
|
||||
foreach (var subscriber in snapshot)
|
||||
{
|
||||
((Action<TEvent>)subscriber)(gameEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void Unsubscribe(Type eventType, Delegate handler)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (!_handlers.TryGetValue(eventType, out var list)) return;
|
||||
|
||||
list.Remove(handler);
|
||||
|
||||
if (list.Count == 0)
|
||||
{
|
||||
_handlers.Remove(eventType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_handlers.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class EventSubscription(Action unsubscribeAction) : IDisposable
|
||||
{
|
||||
private Action _unsubscribeAction = unsubscribeAction;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_unsubscribeAction?.Invoke();
|
||||
_unsubscribeAction = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dsai75jgta1v3
|
||||
Reference in New Issue
Block a user