Trying teleport again

This commit is contained in:
2024-09-07 05:42:51 -07:00
parent 03a9130bc5
commit 4c2731bc7b
9 changed files with 135 additions and 101 deletions

43
src/map/Overworld.cs Normal file
View File

@@ -0,0 +1,43 @@
using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection;
using GameJamDungeon;
using Godot;
using System;
public interface IOverworld : INode3D;
[Meta(typeof(IAutoNode))]
public partial class Overworld : Node3D
{
public override void _Notification(int what) => this.Notify(what);
public IInstantiator Instantiator { get; set; } = default!;
[Dependency] public IAppRepo AppRepo => this.DependOn<IAppRepo>();
[Node] public Area3D Teleport { get; set; } = default!;
private const string FIRST_DUNGEON_PATH = "res://src/map/dungeon/floors/FirstFloor.tscn";
public void Initialize()
{
Instantiator = new Instantiator(GetTree());
Teleport.BodyEntered += Teleport_BodyEntered;
}
private async void Teleport_BodyEntered(Node3D body)
{
Instantiator.SceneTree.Paused = true;
AppRepo.OnShowLoadingScreen();
await ToSignal(GetTree().CreateTimer(2f), "timeout");
var dungeon = Instantiator.LoadAndInstantiate<Node3D>(FIRST_DUNGEON_PATH);
GetParent().AddChild(dungeon);
CallDeferred(MethodName.QueueFree);
}
public void OnExit()
{
AppRepo.Dispose();
}
}

34
src/map/Overworld.tscn Normal file
View File

@@ -0,0 +1,34 @@
[gd_scene load_steps=5 format=3 uid="uid://dvnc26rebk6o0"]
[ext_resource type="PackedScene" uid="uid://b6atdgf2e6e2t" path="res://src/items/weapons/models/CommonSword.tscn" id="1_dnrj0"]
[ext_resource type="Script" path="res://src/map/Overworld.cs" id="1_duf4r"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_amchs"]
albedo_color = Color(0, 0, 0.211765, 0.164706)
[sub_resource type="CylinderShape3D" id="CylinderShape3D_cduj5"]
[node name="Overworld" type="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.63488, -5.13176)
script = ExtResource("1_duf4r")
[node name="CSGBox3D" type="CSGBox3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.82007, 0.766602, -1.46094)
flip_faces = true
size = Vector3(20, 10, 20)
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.15009, 0)
flip_faces = true
material = SubResource("StandardMaterial3D_amchs")
[node name="Teleport" type="Area3D" parent="CSGCylinder3D"]
unique_name_in_owner = true
collision_layer = 2
collision_mask = 2
[node name="CollisionShape3D" type="CollisionShape3D" parent="CSGCylinder3D/Teleport"]
shape = SubResource("CylinderShape3D_cduj5")
[node name="CommonSword" parent="." instance=ExtResource("1_dnrj0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -4.188, -3.81491)

View File

@@ -0,0 +1,12 @@
[gd_scene load_steps=5 format=3 uid="uid://u1e5ae7whhxg"]
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonGenerator3D.gd" id="1_yb2mo"]
[ext_resource type="PackedScene" uid="uid://dhpwwqow1ahrc" path="res://src/map/dungeon/rooms/Room1.tscn" id="2_0kqcj"]
[ext_resource type="PackedScene" uid="uid://bbwgmqy3evhh2" path="res://src/map/dungeon/rooms/Room2.tscn" id="3_6orvx"]
[ext_resource type="PackedScene" uid="uid://bn4gslp2gk8ds" path="res://src/map/dungeon/corridor/Corridor.tscn" id="4_4tgqj"]
[node name="FirstFloor" type="Node3D"]
script = ExtResource("1_yb2mo")
room_scenes = Array[PackedScene]([ExtResource("2_0kqcj"), ExtResource("3_6orvx")])
corridor_room_scene = ExtResource("4_4tgqj")
dungeon_size = Vector3i(10, 1, 10)