diff --git a/addons/dialogue_manager/DialogueManager.cs b/addons/dialogue_manager/DialogueManager.cs index 1cb84b69..16b2f9ae 100644 --- a/addons/dialogue_manager/DialogueManager.cs +++ b/addons/dialogue_manager/DialogueManager.cs @@ -8,416 +8,419 @@ using System.Threading.Tasks; namespace DialogueManagerRuntime { - public enum TranslationSource + public enum TranslationSource + { + None, + Guess, + CSV, + PO + } + + public partial class DialogueManager : Node + { + public delegate void PassedTitleEventHandler(string title); + public delegate void GotDialogueEventHandler(DialogueLine dialogueLine); + public delegate void MutatedEventHandler(Dictionary mutation); + public delegate void DialogueEndedEventHandler(Resource dialogueResource); + + public static PassedTitleEventHandler? PassedTitle; + public static GotDialogueEventHandler? GotDialogue; + public static MutatedEventHandler? Mutated; + public static DialogueEndedEventHandler? DialogueEnded; + + [Signal] public delegate void ResolvedEventHandler(Variant value); + + private static GodotObject? instance; + public static GodotObject Instance { - None, - Guess, - CSV, - PO + get + { + if (instance == null) + { + instance = Engine.GetSingleton("DialogueManager"); + } + return instance; + } } - public partial class DialogueManager : Node + + public static Godot.Collections.Array GameStates { - public delegate void PassedTitleEventHandler(string title); - public delegate void GotDialogueEventHandler(DialogueLine dialogueLine); - public delegate void MutatedEventHandler(Dictionary mutation); - public delegate void DialogueEndedEventHandler(Resource dialogueResource); - - public static PassedTitleEventHandler? PassedTitle; - public static GotDialogueEventHandler? GotDialogue; - public static MutatedEventHandler? Mutated; - public static DialogueEndedEventHandler? DialogueEnded; - - [Signal] public delegate void ResolvedEventHandler(Variant value); - - private static GodotObject? instance; - public static GodotObject Instance - { - get - { - if (instance == null) - { - instance = Engine.GetSingleton("DialogueManager"); - } - return instance; - } - } + get => (Godot.Collections.Array)Instance.Get("game_states"); + set => Instance.Set("game_states", value); + } - public static Godot.Collections.Array GameStates - { - get => (Godot.Collections.Array)Instance.Get("game_states"); - set => Instance.Set("game_states", value); - } + public static bool IncludeSingletons + { + get => (bool)Instance.Get("include_singletons"); + set => Instance.Set("include_singletons", value); + } - public static bool IncludeSingletons - { - get => (bool)Instance.Get("include_singletons"); - set => Instance.Set("include_singletons", value); - } + public static bool IncludeClasses + { + get => (bool)Instance.Get("include_classes"); + set => Instance.Set("include_classes", value); + } - public static bool IncludeClasses - { - get => (bool)Instance.Get("include_classes"); - set => Instance.Set("include_classes", value); - } + public static TranslationSource TranslationSource + { + get => (TranslationSource)(int)Instance.Get("translation_source"); + set => Instance.Set("translation_source", (int)value); + } - public static TranslationSource TranslationSource - { - get => (TranslationSource)(int)Instance.Get("translation_source"); - set => Instance.Set("translation_source", (int)value); - } + public static Func GetCurrentScene + { + set => Instance.Set("get_current_scene", Callable.From(value)); + } - public static Func GetCurrentScene - { - set => Instance.Set("get_current_scene", Callable.From(value)); - } + public void Prepare() + { + Instance.Connect("passed_title", Callable.From((string title) => PassedTitle?.Invoke(title))); + Instance.Connect("got_dialogue", Callable.From((RefCounted line) => GotDialogue?.Invoke(new DialogueLine(line)))); + Instance.Connect("mutated", Callable.From((Dictionary mutation) => Mutated?.Invoke(mutation))); + Instance.Connect("dialogue_ended", Callable.From((Resource dialogueResource) => DialogueEnded?.Invoke(dialogueResource))); + } - public void Prepare() - { - Instance.Connect("passed_title", Callable.From((string title) => PassedTitle?.Invoke(title))); - Instance.Connect("got_dialogue", Callable.From((RefCounted line) => GotDialogue?.Invoke(new DialogueLine(line)))); - Instance.Connect("mutated", Callable.From((Dictionary mutation) => Mutated?.Invoke(mutation))); - Instance.Connect("dialogue_ended", Callable.From((Resource dialogueResource) => DialogueEnded?.Invoke(dialogueResource))); - } + public static async Task GetSingleton() + { + if (instance != null) + return instance; + + var tree = Engine.GetMainLoop(); + int x = 0; + + // Try and find the singleton for a few seconds + while (!Engine.HasSingleton("DialogueManager") && x < 300) + { + await tree.ToSignal(tree, SceneTree.SignalName.ProcessFrame); + x++; + } + + // If it times out something is wrong + if (x >= 300) + { + throw new Exception("The DialogueManager singleton is missing."); + } + + instance = Engine.GetSingleton("DialogueManager"); + return instance; + } + + public static async Task GetNextDialogueLine(Resource dialogueResource, string key = "", Array? extraGameStates = null) + { + Instance.Call("_bridge_get_next_dialogue_line", dialogueResource, key, extraGameStates ?? new Array()); + var result = await Instance.ToSignal(Instance, "bridge_get_next_dialogue_line_completed"); + + if ((RefCounted)result[0] == null) + return null; + + return new DialogueLine((RefCounted)result[0]); + } - public static async Task GetSingleton() - { - if (instance != null) return instance; - - var tree = Engine.GetMainLoop(); - int x = 0; - - // Try and find the singleton for a few seconds - while (!Engine.HasSingleton("DialogueManager") && x < 300) - { - await tree.ToSignal(tree, SceneTree.SignalName.ProcessFrame); - x++; - } - - // If it times out something is wrong - if (x >= 300) - { - throw new Exception("The DialogueManager singleton is missing."); - } - - instance = Engine.GetSingleton("DialogueManager"); - return instance; - } - - public static async Task GetNextDialogueLine(Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - Instance.Call("_bridge_get_next_dialogue_line", dialogueResource, key, extraGameStates ?? new Array()); - var result = await Instance.ToSignal(Instance, "bridge_get_next_dialogue_line_completed"); - - if ((RefCounted)result[0] == null) return null; - - return new DialogueLine((RefCounted)result[0]); - } + public static CanvasLayer ShowExampleDialogueBalloon(Resource dialogueResource, string key = "", Array? extraGameStates = null) + { + return (CanvasLayer)Instance.Call("show_example_dialogue_balloon", dialogueResource, key, extraGameStates ?? new Array()); + } - public static CanvasLayer ShowExampleDialogueBalloon(Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - return (CanvasLayer)Instance.Call("show_example_dialogue_balloon", dialogueResource, key, extraGameStates ?? new Array()); - } + public static Node ShowDialogueBalloonScene(string balloonScene, Resource dialogueResource, string key = "", Array? extraGameStates = null) + { + return (Node)Instance.Call("show_dialogue_balloon_scene", balloonScene, dialogueResource, key, extraGameStates ?? new Array()); + } + + public static Node ShowDialogueBalloonScene(PackedScene balloonScene, Resource dialogueResource, string key = "", Array? extraGameStates = null) + { + return (Node)Instance.Call("show_dialogue_balloon_scene", balloonScene, dialogueResource, key, extraGameStates ?? new Array()); + } + + public static Node ShowDialogueBalloonScene(Node balloonScene, Resource dialogueResource, string key = "", Array? extraGameStates = null) + { + return (Node)Instance.Call("show_dialogue_balloon_scene", balloonScene, dialogueResource, key, extraGameStates ?? new Array()); + } - public static Node ShowDialogueBalloonScene(string balloonScene, Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - return (Node)Instance.Call("show_dialogue_balloon_scene", balloonScene, dialogueResource, key, extraGameStates ?? new Array()); - } - - public static Node ShowDialogueBalloonScene(PackedScene balloonScene, Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - return (Node)Instance.Call("show_dialogue_balloon_scene", balloonScene, dialogueResource, key, extraGameStates ?? new Array()); - } - - public static Node ShowDialogueBalloonScene(Node balloonScene, Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - return (Node)Instance.Call("show_dialogue_balloon_scene", balloonScene, dialogueResource, key, extraGameStates ?? new Array()); - } + public static Node ShowDialogueBalloon(Resource dialogueResource, string key = "", Array? extraGameStates = null) + { + return (Node)Instance.Call("show_dialogue_balloon", dialogueResource, key, extraGameStates ?? new Array()); + } - public static Node ShowDialogueBalloon(Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - return (Node)Instance.Call("show_dialogue_balloon", dialogueResource, key, extraGameStates ?? new Array()); - } + public static async void Mutate(Dictionary mutation, Array? extraGameStates = null, bool isInlineMutation = false) + { + Instance.Call("_bridge_mutate", mutation, extraGameStates ?? new Array(), isInlineMutation); + await Instance.ToSignal(Instance, "bridge_mutated"); + } - public static async void Mutate(Dictionary mutation, Array? extraGameStates = null, bool isInlineMutation = false) - { - Instance.Call("_bridge_mutate", mutation, extraGameStates ?? new Array(), isInlineMutation); - await Instance.ToSignal(Instance, "bridge_mutated"); - } - - - public bool ThingHasMethod(GodotObject thing, string method) - { - MethodInfo? info = thing.GetType().GetMethod(method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); - return info != null; - } + public bool ThingHasMethod(GodotObject thing, string method) + { + MethodInfo? info = thing.GetType().GetMethod(method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); + return info != null; + } public async void ResolveThingMethod(GodotObject thing, string method, Array args) { - MethodInfo? info = thing.GetType().GetMethod(method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); + MethodInfo? info = thing.GetType().GetMethod(method, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); - if (info == null) return; + if (info == null) + return; #nullable disable - // Convert the method args to something reflection can handle - ParameterInfo[] argTypes = info.GetParameters(); - object[] _args = new object[argTypes.Length]; - for (int i = 0; i < argTypes.Length; i++) + // Convert the method args to something reflection can handle + ParameterInfo[] argTypes = info.GetParameters(); + object[] _args = new object[argTypes.Length]; + for (int i = 0; i < argTypes.Length; i++) + { + // check if args is assignable from derived type + if (i < args.Count && args[i].Obj != null) { - // check if args is assignable from derived type - if (i < args.Count && args[i].Obj != null) - { - if (argTypes[i].ParameterType.IsAssignableFrom(args[i].Obj.GetType())) - { - _args[i] = args[i].Obj; - } - // fallback to assigning primitive types - else - { - _args[i] = Convert.ChangeType(args[i].Obj, argTypes[i].ParameterType); - } - } - else if (argTypes[i].DefaultValue != null) - { - _args[i] = argTypes[i].DefaultValue; - } + if (argTypes[i].ParameterType.IsAssignableFrom(args[i].Obj.GetType())) + { + _args[i] = args[i].Obj; + } + // fallback to assigning primitive types + else + { + _args[i] = Convert.ChangeType(args[i].Obj, argTypes[i].ParameterType); + } } - - // Add a single frame wait in case the method returns before signals can listen - await ToSignal(Engine.GetMainLoop(), SceneTree.SignalName.ProcessFrame); - - // invoke method and handle the result based on return type - object result = info.Invoke(thing, _args); - - if (result is Task taskResult) + else if (argTypes[i].DefaultValue != null) { - // await Tasks and handle result if it is a Task - await taskResult; - var taskType = taskResult.GetType(); - if (taskType.IsGenericType && taskType.GetGenericTypeDefinition() == typeof(Task<>)) - { - var resultProperty = taskType.GetProperty("Result"); - var taskResultValue = resultProperty.GetValue(taskResult); - EmitSignal(SignalName.Resolved, (Variant)taskResultValue); - } - else - { - EmitSignal(SignalName.Resolved, null); - } + _args[i] = argTypes[i].DefaultValue; + } + } + + // Add a single frame wait in case the method returns before signals can listen + await ToSignal(Engine.GetMainLoop(), SceneTree.SignalName.ProcessFrame); + + // invoke method and handle the result based on return type + object result = info.Invoke(thing, _args); + + if (result is Task taskResult) + { + // await Tasks and handle result if it is a Task + await taskResult; + var taskType = taskResult.GetType(); + if (taskType.IsGenericType && taskType.GetGenericTypeDefinition() == typeof(Task<>)) + { + var resultProperty = taskType.GetProperty("Result"); + var taskResultValue = resultProperty.GetValue(taskResult); + EmitSignal(SignalName.Resolved, (Variant)taskResultValue); } else { - EmitSignal(SignalName.Resolved, (Variant)result); + EmitSignal(SignalName.Resolved, null); } + } + else + { + EmitSignal(SignalName.Resolved, (Variant)result); + } } #nullable enable - } + } - public partial class DialogueLine : RefCounted + public partial class DialogueLine : RefCounted + { + private string id = ""; + public string Id { - private string id = ""; - public string Id - { - get => id; - set => id = value; - } - - private string type = "dialogue"; - public string Type - { - get => type; - set => type = value; - } - - private string next_id = ""; - public string NextId - { - get => next_id; - set => next_id = value; - } - - private string character = ""; - public string Character - { - get => character; - set => character = value; - } - - private string text = ""; - public string Text - { - get => text; - set => text = value; - } - - private string translation_key = ""; - public string TranslationKey - { - get => translation_key; - set => translation_key = value; - } - - private Array responses = new Array(); - public Array Responses - { - get => responses; - } - - private string? time = null; - public string? Time - { - get => time; - } - - private Dictionary pauses = new Dictionary(); - public Dictionary Pauses - { - get => pauses; - } - - private Dictionary speeds = new Dictionary(); - public Dictionary Speeds - { - get => speeds; - } - - private Array inline_mutations = new Array(); - public Array InlineMutations - { - get => inline_mutations; - } - - private Array extra_game_states = new Array(); - - private Array tags = new Array(); - public Array Tags - { - get => tags; - } - - public DialogueLine(RefCounted data) - { - type = (string)data.Get("type"); - next_id = (string)data.Get("next_id"); - character = (string)data.Get("character"); - text = (string)data.Get("text"); - translation_key = (string)data.Get("translation_key"); - pauses = (Dictionary)data.Get("pauses"); - speeds = (Dictionary)data.Get("speeds"); - inline_mutations = (Array)data.Get("inline_mutations"); - time = (string)data.Get("time"); - tags = (Array)data.Get("tags"); - - foreach (var response in (Array)data.Get("responses")) - { - responses.Add(new DialogueResponse(response)); - } - } - - - public string GetTagValue(string tagName) - { - string wrapped = $"{tagName}="; - foreach (var tag in tags) - { - if (tag.StartsWith(wrapped)) - { - return tag.Substring(wrapped.Length); - } - } - return ""; - } - - public override string ToString() - { - switch (type) - { - case "dialogue": - return $""; - case "mutation": - return ""; - default: - return ""; - } - } + get => id; + set => id = value; } - - public partial class DialogueResponse : RefCounted + private string type = "dialogue"; + public string Type { - private string next_id = ""; - public string NextId - { - get => next_id; - set => next_id = value; - } - - private bool is_allowed = true; - public bool IsAllowed - { - get => is_allowed; - set => is_allowed = value; - } - - private string text = ""; - public string Text - { - get => text; - set => text = value; - } - - private string translation_key = ""; - public string TranslationKey - { - get => translation_key; - set => translation_key = value; - } - - private Array tags = new Array(); - public Array Tags - { - get => tags; - } - - public DialogueResponse(RefCounted data) - { - next_id = (string)data.Get("next_id"); - is_allowed = (bool)data.Get("is_allowed"); - text = (string)data.Get("text"); - translation_key = (string)data.Get("translation_key"); - tags = (Array)data.Get("tags"); - } - - public string GetTagValue(string tagName) - { - string wrapped = $"{tagName}="; - foreach (var tag in tags) - { - if (tag.StartsWith(wrapped)) - { - return tag.Substring(wrapped.Length); - } - } - return ""; - } - - public override string ToString() - { - return $" type; + set => type = value; } + + private string next_id = ""; + public string NextId + { + get => next_id; + set => next_id = value; + } + + private string character = ""; + public string Character + { + get => character; + set => character = value; + } + + private string text = ""; + public string Text + { + get => text; + set => text = value; + } + + private string translation_key = ""; + public string TranslationKey + { + get => translation_key; + set => translation_key = value; + } + + private Array responses = new Array(); + public Array Responses + { + get => responses; + } + + private string? time = null; + public string? Time + { + get => time; + } + + private Dictionary pauses = new Dictionary(); + public Dictionary Pauses + { + get => pauses; + } + + private Dictionary speeds = new Dictionary(); + public Dictionary Speeds + { + get => speeds; + } + + private Array inline_mutations = new Array(); + public Array InlineMutations + { + get => inline_mutations; + } + + private Array extra_game_states = new Array(); + + private Array tags = new Array(); + public Array Tags + { + get => tags; + } + + public DialogueLine(RefCounted data) + { + type = (string)data.Get("type"); + next_id = (string)data.Get("next_id"); + character = (string)data.Get("character"); + text = (string)data.Get("text"); + translation_key = (string)data.Get("translation_key"); + pauses = (Dictionary)data.Get("pauses"); + speeds = (Dictionary)data.Get("speeds"); + inline_mutations = (Array)data.Get("inline_mutations"); + time = (string)data.Get("time"); + tags = (Array)data.Get("tags"); + + foreach (var response in (Array)data.Get("responses")) + { + responses.Add(new DialogueResponse(response)); + } + } + + + public string GetTagValue(string tagName) + { + string wrapped = $"{tagName}="; + foreach (var tag in tags) + { + if (tag.StartsWith(wrapped)) + { + return tag.Substring(wrapped.Length); + } + } + return ""; + } + + public override string ToString() + { + switch (type) + { + case "dialogue": + return $""; + case "mutation": + return ""; + default: + return ""; + } + } + } + + + public partial class DialogueResponse : RefCounted + { + private string next_id = ""; + public string NextId + { + get => next_id; + set => next_id = value; + } + + private bool is_allowed = true; + public bool IsAllowed + { + get => is_allowed; + set => is_allowed = value; + } + + private string text = ""; + public string Text + { + get => text; + set => text = value; + } + + private string translation_key = ""; + public string TranslationKey + { + get => translation_key; + set => translation_key = value; + } + + private Array tags = new Array(); + public Array Tags + { + get => tags; + } + + public DialogueResponse(RefCounted data) + { + next_id = (string)data.Get("next_id"); + is_allowed = (bool)data.Get("is_allowed"); + text = (string)data.Get("text"); + translation_key = (string)data.Get("translation_key"); + tags = (Array)data.Get("tags"); + } + + public string GetTagValue(string tagName) + { + string wrapped = $"{tagName}="; + foreach (var tag in tags) + { + if (tag.StartsWith(wrapped)) + { + return tag.Substring(wrapped.Length); + } + } + return ""; + } + + public override string ToString() + { + return $"("res://src/ui/dialogue/DialogueBalloon.tscn"); } + + public static void ShowDialogue(Resource dialogueResource, string dialogueTitle) + { + Interrupt(); + _currentlyActiveDialogue = DialogueManager.ShowDialogueBalloonScene(DialogueBalloon, dialogueResource, dialogueTitle); + } + + public static void Interrupt() + { + if (IsInstanceValid(_currentlyActiveDialogue)) + _currentlyActiveDialogue.QueueFree(); + } } diff --git a/src/game/Game.cs b/src/game/Game.cs index cc8fbee6..3587f252 100644 --- a/src/game/Game.cs +++ b/src/game/Game.cs @@ -68,7 +68,7 @@ public partial class Game : Node3D, IGame GameRepo.Pause(); DialogueManager.GetCurrentScene = (() => this); var dialogueResource = GD.Load("res://src/ui/dialogue/FloorExit.dialogue"); - DialogueManager.ShowDialogueBalloonScene(DialogueController.DialogueBalloon, dialogueResource, "floor_exit"); + DialogueController.ShowDialogue(dialogueResource, "floor_exit"); DialogueManager.DialogueEnded += (Resource resource) => { GameRepo.Resume(); }; } diff --git a/src/items/throwable/ThrowableItem.tscn b/src/items/throwable/ThrowableItem.tscn index 08e78ba7..60ef7869 100644 --- a/src/items/throwable/ThrowableItem.tscn +++ b/src/items/throwable/ThrowableItem.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=8 format=3 uid="uid://1fl6s352e2ej"] +[gd_scene load_steps=9 format=3 uid="uid://1fl6s352e2ej"] [ext_resource type="Script" path="res://src/items/throwable/ThrowableItem.cs" id="1_nac2l"] +[ext_resource type="Resource" uid="uid://bph8c6by4s047" path="res://src/items/throwable/resources/GeomanticDice.tres" id="2_pefeg"] [ext_resource type="Script" path="res://src/hitbox/Hitbox.cs" id="3_qpunu"] [sub_resource type="BoxShape3D" id="BoxShape3D_qihtb"] @@ -48,6 +49,7 @@ _data = { [node name="ThrowableItem" type="Node3D"] script = ExtResource("1_nac2l") +ThrowableItemInfo = ExtResource("2_pefeg") [node name="Hitbox" type="Area3D" parent="."] unique_name_in_owner = true diff --git a/src/map/Overworld.tscn b/src/map/Overworld.tscn index 1fa90072..e2bfef6b 100644 --- a/src/map/Overworld.tscn +++ b/src/map/Overworld.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=49 format=3 uid="uid://dvnc26rebk6o0"] +[gd_scene load_steps=47 format=3 uid="uid://dvnc26rebk6o0"] [ext_resource type="Script" path="res://src/map/dungeon/floors/Overworld.cs" id="1_5hmt3"] [ext_resource type="PackedScene" uid="uid://d4l4qutp8x40c" path="res://src/npc/rat/NPC.tscn" id="3_4sm8u"] [ext_resource type="Material" uid="uid://cv70me80rxpem" path="res://src/map/overworld/Textures/water.tres" id="4_qojho"] -[ext_resource type="PackedScene" path="res://src/dialog/Dialog.tscn" id="4_thkm7"] [ext_resource type="Material" uid="uid://c3wrhqfpx8th1" path="res://src/map/overworld/Textures/ruins.tres" id="5_6uoht"] [ext_resource type="ArrayMesh" uid="uid://dw5bnw8bkb6w8" path="res://src/map/overworld/Models/block.obj" id="6_n5nl5"] [ext_resource type="Texture2D" uid="uid://b1crojyrqmhql" path="res://src/map/overworld/Textures/kenney_prototype-textures/stick.jpeg" id="7_6df1n"] @@ -14,9 +13,6 @@ [ext_resource type="Texture2D" uid="uid://c4iqttgjb0kq3" path="res://src/map/overworld/Textures/kenney_prototype-textures/treetexture.png" id="12_i7q8i"] [ext_resource type="ArrayMesh" uid="uid://bb46flkajcbtd" path="res://src/map/overworld/Models/tree.obj" id="13_uvfqy"] -[sub_resource type="BoxShape3D" id="BoxShape3D_46qk4"] -size = Vector3(1.96582, 2.5011, 2.21289) - [sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_fi5wi"] data = PackedVector3Array(-0.9588, 0.9579, 0.4896, -0.5, 1, 0.5, -0.8391, 0.8276, 0.8336, -0.8391, 0.8276, 0.8336, -0.5, 1, 0.5, -0.4901, 0.9579, 0.9583, -0.4901, 0.9579, 0.9583, -0.5, 0.5, 1, -0.8391, 0.8276, 0.8336, -0.8391, 0.8276, 0.8336, -0.5, 0.5, 1, -0.9588, 0.4891, 0.9583, -0.9581, 0.9586, -0.4896, -1, 0.5, -0.5, -0.83, 0.8364, -0.8336, -0.83, 0.8364, -0.8336, -1, 0.5, -0.5, -0.9581, 0.4898, -0.9584, 0.861, -0.8512, 0.4495, 0.4895, -0.98, 0.4869, 0.8251, -0.8009, 0.8162, 0.8251, -0.8009, 0.8162, 0.4895, -0.98, 0.4869, 0.462, -0.8241, 0.8419, 0.9579, 0.9588, 0.4896, 0.9888, 0.4976, 0.4903, 0.8127, 0.8359, 0.8206, 0.8127, 0.8359, 0.8206, 0.9888, 0.4976, 0.4903, 0.8241, 0.462, 0.8419, 0.4107, 0.7407, -0.7286, 0.4332, 0.4392, -0.9094, 0.7491, 0.757, -0.7054, 0.7491, 0.757, -0.7054, 0.4332, 0.4392, -0.9094, 0.8323, 0.4537, -0.8118, 0.4957, -0.0035, -0.9948, 0.5, -0.5, -1, 0.959, -0.0024, -0.9576, 0.959, -0.0024, -0.9576, 0.5, -0.5, -1, 0.9584, -0.4897, -0.9584, 1, 0, 0.5, 0.9918, -0.4911, 0.4966, 0.9576, -0.0024, 0.959, 0.9576, -0.0024, 0.959, 0.9918, -0.4911, 0.4966, 0.9588, -0.4891, 0.9583, -1, 0, -0.5, -0.9985, -0.4987, -0.5, -0.9688, 0, -0.9688, -0.9688, 0, -0.9688, -0.9985, -0.4987, -0.5, -0.9688, -0.5, -0.9688, -0.5, 0, 1, -0.5, -0.5, 1, -0.9688, 0, 0.9687, -0.9688, 0, 0.9687, -0.5, -0.5, 1, -0.9579, -0.4901, 0.9583, -1, 0, 0.5, -1, -0.5, 0.5, -1, 0, 0, -1, 0, 0, -1, -0.5, 0.5, -1, -0.5, 0, 1, 0, -0.5, 1, -0.5, -0.5, 1, 0, 0, 1, 0, 0, 1, -0.5, -0.5, 1, -0.5, 0, 0.9517, 0.9495, -0.4773, 0.9903, 0.4976, -0.4889, 0.9684, 0.9678, 0.0009, 0.9684, 0.9678, 0.0009, 0.9903, 0.4976, -0.4889, 1, 0.5, 0, 0.9584, -0.9584, -0.4897, 0.5, -1, -0.5, 0.9606, -0.9599, -0.0033, 0.9606, -0.9599, -0.0033, 0.5, -1, -0.5, 0.5, -1, 0, -0.9588, 0.9579, 0.4896, -1, 0.5, 0.5, -0.9688, 0.9687, 0, -0.9688, 0.9687, 0, -1, 0.5, 0.5, -1, 0.5, 0, -0.9581, 0.9586, -0.4896, -0.5001, 0.9981, -0.4982, -0.9688, 0.9687, 0, -0.9688, 0.9687, 0, -0.5001, 0.9981, -0.4982, -0.5, 1, 0, -0.83, 0.8364, -0.8336, -0.4899, 0.9473, -0.9483, -0.9581, 0.9586, -0.4896, -0.9581, 0.9586, -0.4896, -0.4899, 0.9473, -0.9483, -0.5001, 0.9981, -0.4982, 0.8346, -0.8342, -0.8345, 0.4897, -0.9584, -0.9584, 0.9584, -0.9584, -0.4897, 0.9584, -0.9584, -0.4897, 0.4897, -0.9584, -0.9584, 0.5, -1, -0.5, 0.7491, 0.757, -0.7054, 0.8323, 0.4537, -0.8118, 0.9517, 0.9495, -0.4773, 0.9517, 0.9495, -0.4773, 0.8323, 0.4537, -0.8118, 0.9903, 0.4976, -0.4889, 0.959, -0.0024, -0.9576, 0.9584, -0.4897, -0.9584, 1, 0, -0.5, 1, 0, -0.5, 0.9584, -0.4897, -0.9584, 1, -0.5, -0.5, -1, 0, 0, -1, -0.5, 0, -1, 0, -0.5, -1, 0, -0.5, -1, -0.5, 0, -0.9985, -0.4987, -0.5, -0.9688, 0.9687, 0, -1, 0.5, 0, -0.9581, 0.9586, -0.4896, -0.9581, 0.9586, -0.4896, -1, 0.5, 0, -1, 0.5, -0.5, -0.8391, 0.8276, 0.8336, -0.9588, 0.4891, 0.9583, -0.9588, 0.9579, 0.4896, -0.9588, 0.9579, 0.4896, -0.9588, 0.4891, 0.9583, -1, 0.5, 0.5, -0.9688, 0, 0.9687, -0.9579, -0.4901, 0.9583, -1, 0, 0.5, -1, 0, 0.5, -0.9579, -0.4901, 0.9583, -1, -0.5, 0.5, 1, 0, 0, 1, -0.5, 0, 1, 0, 0.5, 1, 0, 0.5, 1, -0.5, 0, 0.9918, -0.4911, 0.4966, 0.9684, 0.9678, 0.0009, 1, 0.5, 0, 0.9579, 0.9588, 0.4896, 0.9579, 0.9588, 0.4896, 1, 0.5, 0, 0.9888, 0.4976, 0.4903, 0.9606, -0.9599, -0.0033, 0.5, -1, 0, 0.861, -0.8512, 0.4495, 0.861, -0.8512, 0.4495, 0.5, -1, 0, 0.4895, -0.98, 0.4869, -0.9688, 0.9687, 0, -0.5, 1, 0, -0.9588, 0.9579, 0.4896, -0.9588, 0.9579, 0.4896, -0.5, 1, 0, -0.5, 1, 0.5, 1, 0.5, 0, 1, 0, 0, 0.9888, 0.4976, 0.4903, 0.9888, 0.4976, 0.4903, 1, 0, 0, 1, 0, 0.5, -0.9588, 0.4891, 0.9583, -0.9688, 0, 0.9687, -1, 0.5, 0.5, -1, 0.5, 0.5, -0.9688, 0, 0.9687, -1, 0, 0.5, -1, 0.5, 0, -1, 0, 0, -1, 0.5, -0.5, -1, 0.5, -0.5, -1, 0, 0, -1, 0, -0.5, 0.8323, 0.4537, -0.8118, 0.959, -0.0024, -0.9576, 0.9903, 0.4976, -0.4889, 0.9903, 0.4976, -0.4889, 0.959, -0.0024, -0.9576, 1, 0, -0.5, -1, 0.5, 0.5, -1, 0, 0.5, -1, 0.5, 0, -1, 0.5, 0, -1, 0, 0.5, -1, 0, 0, 0.9903, 0.4976, -0.4889, 1, 0, -0.5, 1, 0.5, 0, 1, 0.5, 0, 1, 0, -0.5, 1, 0, 0, 0.4332, 0.4392, -0.9094, 0.4957, -0.0035, -0.9948, 0.8323, 0.4537, -0.8118, 0.8323, 0.4537, -0.8118, 0.4957, -0.0035, -0.9948, 0.959, -0.0024, -0.9576, 0.9888, 0.4976, 0.4903, 1, 0, 0.5, 0.8241, 0.462, 0.8419, 0.8241, 0.462, 0.8419, 1, 0, 0.5, 0.9576, -0.0024, 0.959, -1, 0.5, -0.5, -1, 0, -0.5, -0.9581, 0.4898, -0.9584, -0.9581, 0.4898, -0.9584, -1, 0, -0.5, -0.9688, 0, -0.9688, -0.5, 0.5, 1, -0.5, 0, 1, -0.9588, 0.4891, 0.9583, -0.9588, 0.4891, 0.9583, -0.5, 0, 1, -0.9688, 0, 0.9687, 1, -0.5, 0, 0.9606, -0.9599, -0.0033, 0.9918, -0.4911, 0.4966, 0.9918, -0.4911, 0.4966, 0.9606, -0.9599, -0.0033, 0.861, -0.8512, 0.4495, -0.9579, -0.4901, 0.9583, -0.8276, -0.8391, 0.8336, -1, -0.5, 0.5, -1, -0.5, 0.5, -0.8276, -0.8391, 0.8336, -0.9579, -0.9588, 0.4896, -1, -0.5, 0, -0.9672, -0.9674, 0, -0.9985, -0.4987, -0.5, -0.9985, -0.4987, -0.5, -0.9672, -0.9674, 0, -0.9503, -0.9526, -0.5, 0.9584, -0.4897, -0.9584, 0.8346, -0.8342, -0.8345, 1, -0.5, -0.5, 1, -0.5, -0.5, 0.8346, -0.8342, -0.8345, 0.9584, -0.9584, -0.4897, 1, -0.5, -0.5, 0.9584, -0.9584, -0.4897, 1, -0.5, 0, 1, -0.5, 0, 0.9584, -0.9584, -0.4897, 0.9606, -0.9599, -0.0033, -1, -0.5, 0.5, -0.9579, -0.9588, 0.4896, -1, -0.5, 0, -1, -0.5, 0, -0.9579, -0.9588, 0.4896, -0.9672, -0.9674, 0, -0.5, -0.5, 1, -0.4891, -0.9588, 0.9583, -0.9579, -0.4901, 0.9583, -0.9579, -0.4901, 0.9583, -0.4891, -0.9588, 0.9583, -0.8276, -0.8391, 0.8336, -0.9985, -0.4987, -0.5, -0.9503, -0.9526, -0.5, -0.9688, -0.5, -0.9688, -0.9688, -0.5, -0.9688, -0.9503, -0.9526, -0.5, -0.9563, -0.9565, -0.9583, 0.9918, -0.4911, 0.4966, 0.861, -0.8512, 0.4495, 0.9588, -0.4891, 0.9583, 0.9588, -0.4891, 0.9583, 0.861, -0.8512, 0.4495, 0.8251, -0.8009, 0.8162, 0.5, -0.5, -1, 0.4897, -0.9584, -0.9584, 0.9584, -0.4897, -0.9584, 0.9584, -0.4897, -0.9584, 0.4897, -0.9584, -0.9584, 0.8346, -0.8342, -0.8345, -0.5, -0.5, -1, -0.5, -0.9688, -0.9688, 0, -0.5, -1, 0, -0.5, -1, -0.5, -0.9688, -0.9688, 0, -0.9688, -0.9688, 0.4976, -0.4889, 0.9903, 0.462, -0.8241, 0.8419, 0, -0.5, 1, 0, -0.5, 1, 0.462, -0.8241, 0.8419, -0.0024, -0.9576, 0.959, 0.4889, 0.4976, 0.9903, 0.5, 0, 1, 0, 0.5, 1, 0, 0.5, 1, 0.5, 0, 1, 0, 0, 1, -0.5, 0.5, -1, -0.5, 0, -1, -0.0049, 0.4851, -0.9847, -0.0049, 0.4851, -0.9847, -0.5, 0, -1, 0, 0, -1, -0.0004, 0.9972, 0.0028, 0.4954, 0.9849, 0.0159, 0, 1, 0.5, 0, 1, 0.5, 0.4954, 0.9849, 0.0159, 0.4997, 0.9991, 0.5009, 0, -1, 0, -0.5, -1, 0, 0, -1, 0.5, 0, -1, 0.5, -0.5, -1, 0, -0.5, -1, 0.5, 0, -0.9688, -0.9688, -0.5, -0.9688, -0.9688, 0, -1, -0.5, 0, -1, -0.5, -0.5, -0.9688, -0.9688, -0.4985, -0.9987, -0.5, -0.0128, 0.8148, -0.8288, 0.4107, 0.7407, -0.7286, -0.0031, 0.9615, -0.4631, -0.0031, 0.9615, -0.4631, 0.4107, 0.7407, -0.7286, 0.4783, 0.9272, -0.4238, -0.0031, 0.9615, -0.4631, 0.4783, 0.9272, -0.4238, -0.0004, 0.9972, 0.0028, -0.0004, 0.9972, 0.0028, 0.4783, 0.9272, -0.4238, 0.4954, 0.9849, 0.0159, 0, -1, -0.5, -0.4985, -0.9987, -0.5, 0, -1, 0, 0, -1, 0, -0.4985, -0.9987, -0.5, -0.5, -1, 0, 0.5, 0, 1, 0.4976, -0.4889, 0.9903, 0, 0, 1, 0, 0, 1, 0.4976, -0.4889, 0.9903, 0, -0.5, 1, -0.5, 0, -1, -0.5, -0.5, -1, 0, 0, -1, 0, 0, -1, -0.5, -0.5, -1, 0, -0.5, -1, -0.4899, 0.9473, -0.9483, -0.5, 0.5, -1, -0.0128, 0.8148, -0.8288, -0.0128, 0.8148, -0.8288, -0.5, 0.5, -1, -0.0049, 0.4851, -0.9847, 0, -1, 0.5, -0.5, -1, 0.5, -0.0024, -0.9576, 0.959, -0.0024, -0.9576, 0.959, -0.5, -1, 0.5, -0.4891, -0.9588, 0.9583, 0.4891, 0.9588, 0.9583, 0.4889, 0.4976, 0.9903, 0, 0.9687, 0.9687, 0, 0.9687, 0.9687, 0.4889, 0.4976, 0.9903, 0, 0.5, 1, 0, 1, 0.5, 0.4997, 0.9991, 0.5009, 0, 0.9687, 0.9687, 0, 0.9687, 0.9687, 0.4997, 0.9991, 0.5009, 0.4891, 0.9588, 0.9583, 0.4997, 0.9991, 0.5009, 0.9579, 0.9588, 0.4896, 0.4891, 0.9588, 0.9583, 0.4891, 0.9588, 0.9583, 0.9579, 0.9588, 0.4896, 0.8127, 0.8359, 0.8206, 0.8127, 0.8359, 0.8206, 0.8241, 0.462, 0.8419, 0.4891, 0.9588, 0.9583, 0.4891, 0.9588, 0.9583, 0.8241, 0.462, 0.8419, 0.4889, 0.4976, 0.9903, 0.9576, -0.0024, 0.959, 0.9588, -0.4891, 0.9583, 0.5, 0, 1, 0.5, 0, 1, 0.9588, -0.4891, 0.9583, 0.4976, -0.4889, 0.9903, 0.4783, 0.9272, -0.4238, 0.9517, 0.9495, -0.4773, 0.4954, 0.9849, 0.0159, 0.4954, 0.9849, 0.0159, 0.9517, 0.9495, -0.4773, 0.9684, 0.9678, 0.0009, 0.4107, 0.7407, -0.7286, 0.7491, 0.757, -0.7054, 0.4783, 0.9272, -0.4238, 0.4783, 0.9272, -0.4238, 0.7491, 0.757, -0.7054, 0.9517, 0.9495, -0.4773, 0.4954, 0.9849, 0.0159, 0.9684, 0.9678, 0.0009, 0.4997, 0.9991, 0.5009, 0.4997, 0.9991, 0.5009, 0.9684, 0.9678, 0.0009, 0.9579, 0.9588, 0.4896, 0.8241, 0.462, 0.8419, 0.9576, -0.0024, 0.959, 0.4889, 0.4976, 0.9903, 0.4889, 0.4976, 0.9903, 0.9576, -0.0024, 0.959, 0.5, 0, 1, 0.9588, -0.4891, 0.9583, 0.8251, -0.8009, 0.8162, 0.4976, -0.4889, 0.9903, 0.4976, -0.4889, 0.9903, 0.8251, -0.8009, 0.8162, 0.462, -0.8241, 0.8419, 0, -0.5, -1, 0, -0.9688, -0.9688, 0.5, -0.5, -1, 0.5, -0.5, -1, 0, -0.9688, -0.9688, 0.4897, -0.9584, -0.9584, -0.0049, 0.4851, -0.9847, 0, 0, -1, 0.4332, 0.4392, -0.9094, 0.4332, 0.4392, -0.9094, 0, 0, -1, 0.4957, -0.0035, -0.9948, 0.5, -1, 0, 0, -1, 0, 0.4895, -0.98, 0.4869, 0.4895, -0.98, 0.4869, 0, -1, 0, 0, -1, 0.5, 0.4897, -0.9584, -0.9584, 0, -0.9688, -0.9688, 0.5, -1, -0.5, 0.5, -1, -0.5, 0, -0.9688, -0.9688, 0, -1, -0.5, 0.5, -1, -0.5, 0, -1, -0.5, 0.5, -1, 0, 0.5, -1, 0, 0, -1, -0.5, 0, -1, 0, 0, 0, -1, 0, -0.5, -1, 0.4957, -0.0035, -0.9948, 0.4957, -0.0035, -0.9948, 0, -0.5, -1, 0.5, -0.5, -1, -0.0128, 0.8148, -0.8288, -0.0049, 0.4851, -0.9847, 0.4107, 0.7407, -0.7286, 0.4107, 0.7407, -0.7286, -0.0049, 0.4851, -0.9847, 0.4332, 0.4392, -0.9094, 0.4895, -0.98, 0.4869, 0, -1, 0.5, 0.462, -0.8241, 0.8419, 0.462, -0.8241, 0.8419, 0, -1, 0.5, -0.0024, -0.9576, 0.959, -0.5, -1, 0.5, -0.9579, -0.9588, 0.4896, -0.4891, -0.9588, 0.9583, -0.4891, -0.9588, 0.9583, -0.9579, -0.9588, 0.4896, -0.8276, -0.8391, 0.8336, -0.83, 0.8364, -0.8336, -0.9581, 0.4898, -0.9584, -0.4899, 0.9473, -0.9483, -0.4899, 0.9473, -0.9483, -0.9581, 0.4898, -0.9584, -0.5, 0.5, -1, -0.9688, 0, -0.9688, -0.9688, -0.5, -0.9688, -0.5, 0, -1, -0.5, 0, -1, -0.9688, -0.5, -0.9688, -0.5, -0.5, -1, -0.4985, -0.9987, -0.5, -0.9503, -0.9526, -0.5, -0.5, -1, 0, -0.5, -1, 0, -0.9503, -0.9526, -0.5, -0.9672, -0.9674, 0, -0.5, -0.9688, -0.9688, -0.9563, -0.9565, -0.9583, -0.4985, -0.9987, -0.5, -0.4985, -0.9987, -0.5, -0.9563, -0.9565, -0.9583, -0.9503, -0.9526, -0.5, -0.5, -1, 0, -0.9672, -0.9674, 0, -0.5, -1, 0.5, -0.5, -1, 0.5, -0.9672, -0.9674, 0, -0.9579, -0.9588, 0.4896, -0.9581, 0.4898, -0.9584, -0.9688, 0, -0.9688, -0.5, 0.5, -1, -0.5, 0.5, -1, -0.9688, 0, -0.9688, -0.5, 0, -1, -0.9688, -0.5, -0.9688, -0.9563, -0.9565, -0.9583, -0.5, -0.5, -1, -0.5, -0.5, -1, -0.9563, -0.9565, -0.9583, -0.5, -0.9688, -0.9688, 0, -0.5, 1, -0.0024, -0.9576, 0.959, -0.5, -0.5, 1, -0.5, -0.5, 1, -0.0024, -0.9576, 0.959, -0.4891, -0.9588, 0.9583, 0, 0.5, 1, 0, 0, 1, -0.5, 0.5, 1, -0.5, 0.5, 1, 0, 0, 1, -0.5, 0, 1, -0.5, 1, 0, -0.0004, 0.9972, 0.0028, -0.5, 1, 0.5, -0.5, 1, 0.5, -0.0004, 0.9972, 0.0028, 0, 1, 0.5, -0.4899, 0.9473, -0.9483, -0.0128, 0.8148, -0.8288, -0.5001, 0.9981, -0.4982, -0.5001, 0.9981, -0.4982, -0.0128, 0.8148, -0.8288, -0.0031, 0.9615, -0.4631, -0.5001, 0.9981, -0.4982, -0.0031, 0.9615, -0.4631, -0.5, 1, 0, -0.5, 1, 0, -0.0031, 0.9615, -0.4631, -0.0004, 0.9972, 0.0028, 0, 0, 1, 0, -0.5, 1, -0.5, 0, 1, -0.5, 0, 1, 0, -0.5, 1, -0.5, -0.5, 1, 0, 0.9687, 0.9687, 0, 0.5, 1, -0.4901, 0.9579, 0.9583, -0.4901, 0.9579, 0.9583, 0, 0.5, 1, -0.5, 0.5, 1, -0.5, 1, 0.5, 0, 1, 0.5, -0.4901, 0.9579, 0.9583, -0.4901, 0.9579, 0.9583, 0, 1, 0.5, 0, 0.9687, 0.9687) @@ -149,21 +145,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.03633, 0.654655, 6.89279) unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.49531, 1.49242, 0) -[node name="Goddess" parent="." instance=ExtResource("3_4sm8u")] -transform = Transform3D(-6.11959e-08, 0, 1.4, 0, 1.4, 0, -1.4, 0, -6.11959e-08, -8.84798, 1.52312, -3.9493) - -[node name="Panel" parent="Goddess" instance=ExtResource("4_thkm7")] -unique_name_in_owner = true - -[node name="NPCBox" type="Area3D" parent="Goddess/Panel"] -unique_name_in_owner = true -collision_layer = 128 -collision_mask = 128 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="Goddess/Panel/NPCBox"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.8395, -1.94114, -8.99061) -shape = SubResource("BoxShape3D_46qk4") - [node name="Node3D" type="Node3D" parent="."] [node name="CSGCombiner3D" type="CSGCombiner3D" parent="Node3D"] @@ -1127,3 +1108,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -18.5177, 0, 0) [node name="CollisionShape3D" type="CollisionShape3D" parent="Node3D/StaticBody3D3"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -82.4182, 2.41226, -33.0786) shape = SubResource("BoxShape3D_okyng") + +[node name="NPC" parent="." instance=ExtResource("3_4sm8u")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.1364, 2.01954, -3.50556) diff --git a/src/map/dungeon/floors/Overworld.cs b/src/map/dungeon/floors/Overworld.cs index 9cc2c52c..a3b79926 100644 --- a/src/map/dungeon/floors/Overworld.cs +++ b/src/map/dungeon/floors/Overworld.cs @@ -12,26 +12,10 @@ public partial class Overworld : Node3D, IDungeonFloor [Dependency] public IGameRepo GameRepo => this.DependOn(); - [Node] public Area3D NPCBox { get; set; } = default!; - [Node] public Marker3D PlayerSpawnPoint { get; set; } = default!; - [Export] public Resource Dialogue { get; set; } - public void InitializeDungeon() { - NPCBox.AreaEntered += NPCBox_AreaEntered; - NPCBox.AreaExited += NPCBox_AreaExited; GameRepo.SetPlayerGlobalPosition(PlayerSpawnPoint.GlobalPosition); } - - private void NPCBox_AreaExited(Area3D area) - { - GameRepo.IsWithinDialogueSpace = false; - } - - private void NPCBox_AreaEntered(Area3D area) - { - GameRepo.IsWithinDialogueSpace = true; - } } diff --git a/src/npc/Npc.cs b/src/npc/Npc.cs index 31fecaca..52cdf375 100644 --- a/src/npc/Npc.cs +++ b/src/npc/Npc.cs @@ -12,24 +12,37 @@ public partial class Npc : Node3D [Node] public Area3D DialogueZone { get; set; } = default!; + [Node] public Area3D Hitbox { get; set; } = default!; + [Export] - public Godot.Collections.Array DialogueOptions { get; set; } = default!; + public Resource Dialogue { get; set; } = default!; private bool _isInDialogueZone = false; - - private Node _dialogueBalloon; + private bool _isIntroductionComplete = false; public void OnReady() { + SetPhysicsProcess(true); DialogueZone.BodyEntered += DialogueZone_BodyEntered; DialogueZone.BodyExited += DialogueZone_BodyExited; + Hitbox.AreaEntered += Hitbox_AreaEntered; + + } + + private void Hitbox_AreaEntered(Area3D area) + { + DialogueController.ShowDialogue(Dialogue, "hit"); + } + + private void Hitbox_BodyEntered(Node body) + { + DialogueController.ShowDialogue(Dialogue, "hit"); } private void DialogueZone_BodyExited(Node3D body) { _isInDialogueZone = false; - if (_dialogueBalloon != null) - _dialogueBalloon.QueueFree(); + DialogueController.Interrupt(); } private void DialogueZone_BodyEntered(Node3D body) @@ -40,6 +53,14 @@ public partial class Npc : Node3D public override void _UnhandledInput(InputEvent @event) { if (Input.IsActionJustPressed(GameInputs.Throw) && _isInDialogueZone) - _dialogueBalloon = DialogueManager.ShowDialogueBalloonScene(DialogueController.DialogueBalloon, DialogueOptions.First(), "introduction"); + { + if (_isIntroductionComplete) + DialogueController.ShowDialogue(Dialogue, "general"); + else + { + DialogueController.ShowDialogue(Dialogue, "introduction"); + _isIntroductionComplete = true; + } + } } } diff --git a/src/npc/rat/NPC.tscn b/src/npc/rat/NPC.tscn index f8b521f3..52c690b2 100644 --- a/src/npc/rat/NPC.tscn +++ b/src/npc/rat/NPC.tscn @@ -1,15 +1,23 @@ -[gd_scene load_steps=5 format=3 uid="uid://d4l4qutp8x40c"] +[gd_scene load_steps=7 format=3 uid="uid://d4l4qutp8x40c"] [ext_resource type="Texture2D" uid="uid://t7fbfplu2js7" path="res://src/npc/rat/ROYAL_RAT_PRINCEP.png" id="1_0r0wh"] [ext_resource type="Script" path="res://src/npc/Npc.cs" id="1_cpdf2"] [ext_resource type="Resource" uid="uid://cf7ycgdiihyh" path="res://src/npc/rat/ratdialogue.dialogue" id="2_uo38w"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_wfhgc"] -radius = 2.5 +radius = 3.0 + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_kg3qv"] +radius = 0.837722 +height = 2.8375 + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_nwuwj"] +height = 2.24425 +radius = 1.00578 [node name="NPC" type="Node3D"] script = ExtResource("1_cpdf2") -DialogueOptions = Array[Resource]([ExtResource("2_uo38w")]) +Dialogue = ExtResource("2_uo38w") [node name="Sprite" type="Sprite3D" parent="."] unique_name_in_owner = true @@ -28,3 +36,19 @@ collision_mask = 2 [node name="CollisionShape3D" type="CollisionShape3D" parent="DialogueZone"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00131226, 0, -0.00723076) shape = SubResource("CylinderShape3D_wfhgc") + +[node name="Collision" type="RigidBody3D" parent="."] +collision_mask = 0 +gravity_scale = 0.0 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Collision"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.169075, 0, 0) +shape = SubResource("CapsuleShape3D_kg3qv") + +[node name="Hitbox" type="Area3D" parent="."] +unique_name_in_owner = true +collision_layer = 16 +collision_mask = 16 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"] +shape = SubResource("CylinderShape3D_nwuwj") diff --git a/src/npc/rat/ratdialogue.dialogue b/src/npc/rat/ratdialogue.dialogue index 75b01dc7..0c44b0c1 100644 --- a/src/npc/rat/ratdialogue.dialogue +++ b/src/npc/rat/ratdialogue.dialogue @@ -7,4 +7,42 @@ Royal Rat Princep, Tekohcyo: Though it be in mind only, I am traitor to mine cou Royal Rat Princep, Tekohcyo: Alas, the tower has rejected me, so here I reside. Unable to return home, but unable to climb it. -=> END \ No newline at end of file +=> END + +~ general +% => B1 +% => B2 +% => B3 +% => B4 +% => B5 +=> END + +~ B1 +Royal Rat Princep, Tekohcyo: It became too much to bear, imagining what secrets they spoke within the walls. + The Goddess could change their hearts… + At least, it is what I dreamed of. +=> END + +~ B2 +Royal Rat Princep, Tekohcyo: I knew the Tower would save me. When it showed itself to me, I felt a hope I hadn’t felt since I was a child. + Though it must have been a false hope in those days. What despairs did I possibly have to define that hope by? + I was surrounded by love and play. The ideal environment for all living creatures. +=> END + +~ B3 +Royal Rat Princep, Tekohcyo: Though I am fearful of what my resolve could lead me to, I have yet to step foot in the audience chamber at the top. + The thousand hands of the tower have always placed me gently where I fell, where I wished, and where I appear before you... +=> END + +~ B4 +Royal Rat Princep, Tekohcyo: Is it my own heart that needs to change, or the subjects around me? +=> END + +~ B5 +Royal Rat Princep, Tekohcyo: The walls of the Tower may deceive you. +=> END + +~ hit +Royal Rat Princep, Tekohcyo: I suppose in the end, any end is, relievingly, an end. +=> END + diff --git a/src/player/Player.cs b/src/player/Player.cs index 41fafa06..ab0dd791 100644 --- a/src/player/Player.cs +++ b/src/player/Player.cs @@ -124,7 +124,6 @@ namespace GameJamDungeon }) .Handle((in PlayerLogic.Output.ThrowItem output) => { - ThrowItem(); }); this.Provide(); diff --git a/src/ui/dialogue/DialogueBalloon.tscn b/src/ui/dialogue/DialogueBalloon.tscn index d56a2043..116f67dd 100644 --- a/src/ui/dialogue/DialogueBalloon.tscn +++ b/src/ui/dialogue/DialogueBalloon.tscn @@ -107,15 +107,14 @@ theme = SubResource("Theme_qq3yp") [node name="Dialogue" type="MarginContainer" parent="Balloon"] layout_mode = 1 -anchors_preset = 15 +anchors_preset = 12 +anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = 21.0 -offset_top = 897.0 -offset_right = 21.0 -offset_bottom = 897.0 +offset_top = -124.0 +offset_bottom = 1.0 grow_horizontal = 2 -grow_vertical = 2 +grow_vertical = 0 [node name="VBoxContainer" type="VBoxContainer" parent="Balloon/Dialogue"] layout_mode = 2 @@ -147,7 +146,6 @@ theme_override_styles/fill = SubResource("StyleBoxEmpty_vtj1a") theme_override_styles/background = SubResource("StyleBoxEmpty_c2c5i") theme_override_styles/focus = SubResource("StyleBoxEmpty_wv0ko") theme_override_styles/normal = SubResource("StyleBoxEmpty_dboi3") -text = "Dialogue..." [node name="CenterContainer" type="CenterContainer" parent="Balloon"] layout_mode = 1