Re-introduce prototype code
This commit is contained in:
44
src/map/dungeon/rooms/DungeonRoom.cs
Normal file
44
src/map/dungeon/rooms/DungeonRoom.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
|
||||
public interface IDungeonRoom : INode3D
|
||||
{
|
||||
DungeonRoomLogic DungeonRoomLogic { get; }
|
||||
public Marker3D PlayerSpawn { get; set; }
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class DungeonRoom : Node3D, IDungeonRoom, IProvide<DungeonRoomLogic>
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
DungeonRoomLogic IProvide<DungeonRoomLogic>.Value() => DungeonRoomLogic;
|
||||
|
||||
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||
|
||||
public DungeonRoomLogic DungeonRoomLogic { get; set; } = default!;
|
||||
|
||||
[Node] public Marker3D PlayerSpawn { get; set; } = default!;
|
||||
|
||||
public DungeonRoomLogic.IBinding DungeonRoomBinding { get; set; } = default!;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
DungeonRoomLogic = new DungeonRoomLogic();
|
||||
DungeonRoomLogic.Set(this as IDungeonRoom);
|
||||
DungeonRoomLogic.Set(GameRepo);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
DungeonRoomBinding = DungeonRoomLogic.Bind();
|
||||
|
||||
GameRepo.SetPlayerGlobalPosition(PlayerSpawn.GlobalPosition);
|
||||
|
||||
DungeonRoomLogic.Start();
|
||||
this.Provide();
|
||||
}
|
||||
}
|
||||
14
src/map/dungeon/rooms/DungeonRoomLogic.cs
Normal file
14
src/map/dungeon/rooms/DungeonRoomLogic.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public interface IDungeonRoomLogic : ILogicBlock<DungeonRoomLogic.State>;
|
||||
|
||||
[Meta, Id("dungeon_room_logic")]
|
||||
[LogicBlock(typeof(State), Diagram = true)]
|
||||
public partial class DungeonRoomLogic : LogicBlock<DungeonRoomLogic.State>, IDungeonRoomLogic
|
||||
{
|
||||
public override Transition GetInitialState() => To<State.Idle>();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dhpwwqow1ahrc"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dhpwwqow1ahrc"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_0tfda"]
|
||||
[ext_resource type="Script" path="res://src/map/dungeon/rooms/DungeonRoom.cs" id="1_ti7ur"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckaw6wjmi0fom" path="res://src/map/dungeon/door/Door.tscn" id="2_mdawx"]
|
||||
[ext_resource type="Texture2D" uid="uid://bidlc5a6lft6" path="res://src/map/dungeon/textures/map_brickwall.jpg" id="2_rw3uc"]
|
||||
|
||||
@@ -12,6 +13,9 @@ uv1_triplanar = true
|
||||
[node name="DungeonRoom3D" type="Node3D"]
|
||||
script = ExtResource("1_0tfda")
|
||||
|
||||
[node name="DungeonRoom" type="Node3D" parent="."]
|
||||
script = ExtResource("1_ti7ur")
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
material_override = SubResource("StandardMaterial3D_gt3ar")
|
||||
use_collision = true
|
||||
@@ -24,7 +28,11 @@ use_collision = true
|
||||
size = Vector3(9, 9, 9)
|
||||
|
||||
[node name="DOOR" parent="CSGBox3D" instance=ExtResource("2_mdawx")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.47376, 4.74571)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.54039, 4.74571)
|
||||
|
||||
[node name="DOOR2" parent="CSGBox3D" instance=ExtResource("2_mdawx")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.51619, -4.73548)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.58282, -4.73548)
|
||||
|
||||
[node name="PlayerSpawn" type="Marker3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -4.23461, 0)
|
||||
|
||||
11
src/map/dungeon/rooms/state/DungeonRoomLogic.State.cs
Normal file
11
src/map/dungeon/rooms/state/DungeonRoomLogic.State.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.LogicBlocks;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public partial class DungeonRoomLogic
|
||||
{
|
||||
[Meta]
|
||||
public abstract partial record State : StateLogic<State>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Chickensoft.Introspection;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
public partial class DungeonRoomLogic
|
||||
{
|
||||
public partial record State
|
||||
{
|
||||
[Meta, Id("dungeon_room_logic_state_idle")]
|
||||
public partial record Idle : State
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user