From d07a623dbdb2f64e56682f4c06aa15c2ac539767 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 7 Oct 2026 15:07:21 +0100 Subject: [PATCH] addons: Remove C# source files and scenes that reference them Scenes that reference `.cs` scripts cannot be loaded in the non-C#-enabled version of Godot, causing errors when upgrading all scenes to new Godot versions. Unreferenced `.cs` scripts are not actively problematic but they may confuse people into thinking that they need the C#-enabled engine. --- addons/dialogue_manager/DialogueManager.cs | 1164 ----------------- .../dialogue_manager/DialogueManager.cs.uid | 1 - .../example_balloon/ExampleBalloon.cs | 278 ---- .../example_balloon/ExampleBalloon.cs.uid | 1 - .../example_balloon/ExampleBalloon.tscn | 204 --- .../example_balloon/SmallExampleBalloon.tscn | 202 --- .../nodes/actionable/DialogueActionable2D.cs | 141 -- .../actionable/DialogueActionable2D.cs.uid | 1 - .../nodes/actionable/DialogueActionable3D.cs | 141 -- .../actionable/DialogueActionable3D.cs.uid | 1 - .../nodes/context/DialogueStateContext.cs | 82 -- .../nodes/context/DialogueStateContext.cs.uid | 1 - .../nodes/dialogue_label/DialogueLabel.cs | 356 ----- .../nodes/dialogue_label/DialogueLabel.cs.uid | 1 - .../nodes/dialogue_label/DialogueLabel.tscn | 19 - .../nodes/marker/DialogueMarker2D.cs | 79 -- .../nodes/marker/DialogueMarker2D.cs.uid | 1 - .../nodes/marker/DialogueMarker3D.cs | 87 -- .../nodes/marker/DialogueMarker3D.cs.uid | 1 - .../responses_menu/DialogueResponsesMenu.cs | 303 ----- .../DialogueResponsesMenu.cs.uid | 1 - addons/input_helper/InputHelper.cs | 287 ---- addons/input_helper/InputHelper.cs.uid | 1 - .../scripts/managers/PhantomCameraManager.cs | 36 - .../managers/PhantomCameraManager.cs.uid | 1 - .../scripts/phantom_camera/PhantomCamera.cs | 234 ---- .../phantom_camera/PhantomCamera.cs.uid | 1 - .../scripts/phantom_camera/PhantomCamera2D.cs | 380 ------ .../phantom_camera/PhantomCamera2D.cs.uid | 1 - .../scripts/phantom_camera/PhantomCamera3D.cs | 483 ------- .../phantom_camera/PhantomCamera3D.cs.uid | 1 - .../PhantomCameraNoiseEmitter2D.cs | 83 -- .../PhantomCameraNoiseEmitter2D.cs.uid | 1 - .../PhantomCameraNoiseEmitter3D.cs | 83 -- .../PhantomCameraNoiseEmitter3D.cs.uid | 1 - .../PhantomCameraTweenDirector.cs | 20 - .../phantom_camera_host/PhantomCameraHost.cs | 111 -- .../PhantomCameraHost.cs.uid | 1 - .../scripts/resources/Camera3DResource.cs | 116 -- .../scripts/resources/Camera3DResource.cs.uid | 1 - .../scripts/resources/PhantomCameraNoise2D.cs | 103 -- .../resources/PhantomCameraNoise2D.cs.uid | 1 - .../scripts/resources/PhantomCameraNoise3D.cs | 130 -- .../resources/PhantomCameraNoise3D.cs.uid | 1 - .../scripts/resources/PhantomCameraTween.cs | 75 -- .../resources/PhantomCameraTween.cs.uid | 1 - .../resources/TweenDirectorResource.cs | 89 -- 47 files changed, 5307 deletions(-) delete mode 100644 addons/dialogue_manager/DialogueManager.cs delete mode 100644 addons/dialogue_manager/DialogueManager.cs.uid delete mode 100644 addons/dialogue_manager/example_balloon/ExampleBalloon.cs delete mode 100644 addons/dialogue_manager/example_balloon/ExampleBalloon.cs.uid delete mode 100644 addons/dialogue_manager/example_balloon/ExampleBalloon.tscn delete mode 100644 addons/dialogue_manager/example_balloon/SmallExampleBalloon.tscn delete mode 100644 addons/dialogue_manager/nodes/actionable/DialogueActionable2D.cs delete mode 100644 addons/dialogue_manager/nodes/actionable/DialogueActionable2D.cs.uid delete mode 100644 addons/dialogue_manager/nodes/actionable/DialogueActionable3D.cs delete mode 100644 addons/dialogue_manager/nodes/actionable/DialogueActionable3D.cs.uid delete mode 100644 addons/dialogue_manager/nodes/context/DialogueStateContext.cs delete mode 100644 addons/dialogue_manager/nodes/context/DialogueStateContext.cs.uid delete mode 100644 addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs delete mode 100644 addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs.uid delete mode 100644 addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.tscn delete mode 100644 addons/dialogue_manager/nodes/marker/DialogueMarker2D.cs delete mode 100644 addons/dialogue_manager/nodes/marker/DialogueMarker2D.cs.uid delete mode 100644 addons/dialogue_manager/nodes/marker/DialogueMarker3D.cs delete mode 100644 addons/dialogue_manager/nodes/marker/DialogueMarker3D.cs.uid delete mode 100644 addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs delete mode 100644 addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs.uid delete mode 100644 addons/input_helper/InputHelper.cs delete mode 100644 addons/input_helper/InputHelper.cs.uid delete mode 100644 addons/phantom_camera/scripts/managers/PhantomCameraManager.cs delete mode 100644 addons/phantom_camera/scripts/managers/PhantomCameraManager.cs.uid delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCamera.cs delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCamera.cs.uid delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCamera2D.cs delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCamera2D.cs.uid delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCamera3D.cs delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCamera3D.cs.uid delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter2D.cs delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter2D.cs.uid delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter3D.cs delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter3D.cs.uid delete mode 100644 addons/phantom_camera/scripts/phantom_camera/PhantomCameraTweenDirector.cs delete mode 100644 addons/phantom_camera/scripts/phantom_camera_host/PhantomCameraHost.cs delete mode 100644 addons/phantom_camera/scripts/phantom_camera_host/PhantomCameraHost.cs.uid delete mode 100644 addons/phantom_camera/scripts/resources/Camera3DResource.cs delete mode 100644 addons/phantom_camera/scripts/resources/Camera3DResource.cs.uid delete mode 100644 addons/phantom_camera/scripts/resources/PhantomCameraNoise2D.cs delete mode 100644 addons/phantom_camera/scripts/resources/PhantomCameraNoise2D.cs.uid delete mode 100644 addons/phantom_camera/scripts/resources/PhantomCameraNoise3D.cs delete mode 100644 addons/phantom_camera/scripts/resources/PhantomCameraNoise3D.cs.uid delete mode 100644 addons/phantom_camera/scripts/resources/PhantomCameraTween.cs delete mode 100644 addons/phantom_camera/scripts/resources/PhantomCameraTween.cs.uid delete mode 100644 addons/phantom_camera/scripts/resources/TweenDirectorResource.cs diff --git a/addons/dialogue_manager/DialogueManager.cs b/addons/dialogue_manager/DialogueManager.cs deleted file mode 100644 index 19f8caaf9b..0000000000 --- a/addons/dialogue_manager/DialogueManager.cs +++ /dev/null @@ -1,1164 +0,0 @@ -using Godot; -using Godot.Collections; -using System; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; - -#nullable enable - -namespace DialogueManagerRuntime -{ - - public enum MutationBehaviour - { - Wait, - DoNotWait, - Skip - } - - public enum TranslationSource - { - None, - Guess, - CSV, - PO - } - - public partial class DialogueManager : RefCounted - { - public delegate void DialogueStartedEventHandler(Resource dialogueResource); - public delegate void PassedCueEventHandler(string cue); - public delegate void GotDialogueEventHandler(DialogueLine dialogueLine); - public delegate void WaitingForInputEventHandler(); - public delegate void WaitedForInputEventHandler(); - public delegate void MutatedEventHandler(Dictionary mutation); - - /// - /// Emitted when some dialogue has reached the end. - /// - /// The calling dialogue resource. - public delegate void DialogueEndedEventHandler(Resource dialogueResource); - - /// - /// Emitted when a dialogue balloon is created and dialogue starts. - /// - public static event DialogueStartedEventHandler? DialogueStarted; - - /// - /// Emitted when a cue is encountered while traversing dialogue, usually when jumping from a goto line. - /// - public static event PassedCueEventHandler? PassedCue; - - /// - /// Emitted when a line of dialogue is encountered. - /// - public static event GotDialogueEventHandler? GotDialogue; - - /// - /// Emitted when a mutation is encountered. - /// - public static event MutatedEventHandler? Mutated; - - /// - /// Emitted when waiting for input. - /// - public static event WaitingForInputEventHandler? WaitingForInput; - - /// - /// Emitted when waiting for input received input. - /// - public static event WaitedForInputEventHandler? WaitedForInput; - - /// - /// Emitted when some dialogue has reached the end. - /// - public static event DialogueEndedEventHandler? DialogueEnded; - - [Signal] public delegate void ResolvedEventHandler(double id, Variant value); - - private static Random random = new Random(); - - private static readonly System.Collections.Generic.Dictionary> getNextLineRequests = new(); - private static readonly System.Collections.Generic.Dictionary> getLineRequests = new(); - private static readonly System.Collections.Generic.Dictionary> mutateRequests = new(); - - private static Type[]? cachedAssemblyTypes; - private static Type[] AssemblyTypes => cachedAssemblyTypes ??= Assembly.GetExecutingAssembly().GetTypes(); - - private static readonly System.Collections.Generic.Dictionary MethodCache = new(); - private static MethodInfo[] GetMethodsForType(Type type) - { - if (!MethodCache.TryGetValue(type, out var methods)) - { - methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); - MethodCache[type] = methods; - } - return methods; - } - - private static void OnBridgeGetNextDialogueLineCompleted(int callId, RefCounted? line) - { - if (getNextLineRequests.Remove(callId, out var tcs)) - { - tcs.SetResult(line); - } - } - - private static void OnBridgeGetLineCompleted(int callId, RefCounted? line) - { - if (getLineRequests.Remove(callId, out var tcs)) - { - tcs.SetResult(line); - } - } - - private static void OnBridgeMutated(int callId) - { - if (mutateRequests.Remove(callId, out var tcs)) - { - tcs.SetResult(true); - } - } - - private static GodotObject? instance; - public static GodotObject Instance => instance ??= InitializeInstance(); - - private static GodotObject InitializeInstance() - { - var dm = Engine.GetSingleton("DialogueManager"); - dm.Connect("dialogue_started", Callable.From((Resource dialogueResource) => DialogueStarted?.Invoke(dialogueResource))); - dm.Connect("passed_cue", Callable.From((string cue) => PassedCue?.Invoke(cue))); - dm.Connect("got_dialogue", Callable.From((RefCounted line) => GotDialogue?.Invoke(new DialogueLine(line)))); - dm.Connect("mutated", Callable.From((Dictionary mutation) => Mutated?.Invoke(mutation))); - dm.Connect("waiting_for_input", Callable.From(() => WaitingForInput?.Invoke())); - dm.Connect("waited_for_input", Callable.From(() => WaitedForInput?.Invoke())); - dm.Connect("dialogue_ended", Callable.From((Resource dialogueResource) => DialogueEnded?.Invoke(dialogueResource))); - - dm.Connect("bridge_get_next_dialogue_line_completed", Callable.From((int callId, RefCounted? line) => OnBridgeGetNextDialogueLineCompleted(callId, line))); - dm.Connect("bridge_get_line_completed", Callable.From((int callId, RefCounted? line) => OnBridgeGetLineCompleted(callId, line))); - dm.Connect("bridge_mutated", Callable.From((int callId) => OnBridgeMutated(callId))); - - return dm; - } - - /// - /// The list of globals that dialogue can query. - /// - public static Godot.Collections.Array GameStates - { - get => (Godot.Collections.Array)Instance.Get("game_states"); - set => Instance.Set("game_states", value); - } - - /// - /// Allow dialogue to call singletons. - /// - public static bool IncludeSingletons - { - get => (bool)Instance.Get("include_singletons"); - set => Instance.Set("include_singletons", value); - } - - /// - /// Allow dialogue to call static methods/properties on classes - /// - public static bool IncludeClasses - { - get => (bool)Instance.Get("include_classes"); - set => Instance.Set("include_classes", value); - } - - - /// - /// Allow dialogue to call methods on the dialogue resource. - /// - public static bool IncludeDialogueResourceAsSelf - { - get => (bool)Instance.Get("include_dialogue_resource_as_self"); - set => Instance.Set("include_dialogue_resource_as_self", value); - } - - /// - /// A runtime override for the project setting to ignore missing state values. - /// - public static bool IgnoreMissingStateValues - { - get => (bool)Instance.Get("ignore_missing_state_values"); - set => Instance.Set("ignore_missing_state_values", value); - } - - /// - /// Used to resolve the current scene. Override if your game manages the current scene itself. - /// - public static Func GetCurrentScene - { - set => Instance.Set("get_current_scene", Callable.From(value)); - } - - /// - /// Used to resolve the load function used in *.dialogue files. Override this if you need safer loading or custom loading logic. - /// - public static Func LoadFromWithinDialogue = GD.Load; - - /// - /// Set a filter hook for member access on GodotObject things. The delegate is - /// stored on the GDScript-side validate_member_access Callable property - /// and is invoked whenever a thing's property, method, or string-keyed index is - /// about to be accessed at runtime. Return "" to allow, or a non-empty - /// error string to deny. - /// is one of: "property", "property_set", "method", "index". - /// - public static Func ValidateMemberAccess - { - set => Instance.Set("validate_member_access", Callable.From(value)); - } - - /// - /// Set a random seed. - /// - /// - public static void ReseedRandomizer(int nextSeed) - { - Instance.Call("reseed_randomizer", nextSeed); - } - - - /// - /// Step through lines and run any mutations until we either hit some dialogue or the end of the conversation. - /// - /// - /// - /// Array of extra nodes to expose as state to the dialogue - /// - /// The next dialogue line - public static async Task GetNextDialogueLine(Resource dialogueResource, string key = "", Array? extraGameStates = null, MutationBehaviour mutation_behaviour = MutationBehaviour.Wait) - { - int id = random.Next(); - var tcs = new TaskCompletionSource(); - getNextLineRequests[id] = tcs; - - Instance.Call("_bridge_get_next_dialogue_line", id, dialogueResource, key, extraGameStates ?? new Array(), (int)mutation_behaviour); - - var line = await tcs.Task; - return line == null ? null : new DialogueLine(line); - } - - - /// - /// Get a line by its ID - /// - /// - /// - /// Array of extra nodes to expose as state to the dialogue - /// - public static async Task GetLine(Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - int id = random.Next(); - var tcs = new TaskCompletionSource(); - getLineRequests[id] = tcs; - - Instance.Call("_bridge_get_line", id, dialogueResource, key, extraGameStates ?? new Array()); - - var line = await tcs.Task; - return line == null ? null : new DialogueLine(line); - } - - - /// - /// Generate a dialogue resource on the fly from some text - /// - /// - /// - public static Resource CreateResourceFromText(string text) - { - return (Resource)Instance.Call("create_resource_from_text", text); - } - - - - /// - /// Set the default balloon to use at runtime. - /// - /// - /// - public static Error SetDefaultBalloon(Variant balloonScene) - { - return (Error)(int)Instance.Call("set_default_balloon", balloonScene); - } - - - /// - /// Show the example balloon - /// - /// - /// - /// - /// - public static CanvasLayer ShowExampleDialogueBalloon(Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - return (CanvasLayer)Instance.Call("show_example_dialogue_balloon", dialogueResource, key, extraGameStates ?? new Array()); - } - - - /// - /// Show the configured dialogue balloon - /// - /// - /// - /// - /// - public static Node ShowDialogueBalloon(Resource dialogueResource, string key = "", Array? extraGameStates = null) - { - return (Node)Instance.Call("show_dialogue_balloon", dialogueResource, key, extraGameStates ?? new Array()); - } - - - /// - /// Show a given balloon scene - /// - /// - /// - /// - /// - /// - 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()); - } - - /// - /// Show a given balloon scene - /// - /// - /// - /// - /// - /// - 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()); - } - - /// - /// Show a given balloon scene - /// - /// - /// - /// - /// - /// - 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()); - } - - - /// - /// Resolve a static line ID to an actual line ID - /// - /// - /// - /// - public static string StaticIdToLineId(Resource dialogueResource, string staticId) - { - return (string)Instance.Call("static_id_to_line_id", dialogueResource, staticId); - } - - - /// - /// Resolve a static line ID to any actual line IDs that match - /// - /// - /// - /// - public static Array StaticIdToLineIds(Resource dialogueResource, string staticId) - { - return (Array)Instance.Call("static_id_to_line_ids", dialogueResource, staticId); - } - - - public static async Task Mutate(Dictionary mutation, Array? extraGameStates = null, bool isInlineMutation = false) - { - int id = random.Next(); - var tcs = new TaskCompletionSource(); - mutateRequests[id] = tcs; - - Instance.Call("_bridge_mutate", id, mutation, extraGameStates ?? new Array(), isInlineMutation); - - await tcs.Task; - } - - - public static Array GetMembersForScript(Script script) - { - string typeName = script.ResourcePath.GetFile().GetBaseName(); - var matchingType = AssemblyTypes.FirstOrDefault(t => t.Name == typeName); - - if (matchingType == null) return new Array(); - - return GetMembersForType(matchingType); - } - - - public static Array GetMembersForPropertyChain(Script script, Array chain) - { - string typeName = script.ResourcePath.GetFile().GetBaseName(); - var currentType = AssemblyTypes.FirstOrDefault(t => t.Name == typeName); - - if (currentType == null) return new Array(); - - foreach (var segment in chain) - { - currentType = ResolvePropertyType(currentType, segment); - if (currentType == null) return new Array(); - } - - return GetMembersForType(currentType); - } - - - public static Dictionary GetMethodInfoForPropertyChain(Script script, Array chain, string methodName) - { - string typeName = script.ResourcePath.GetFile().GetBaseName(); - var currentType = AssemblyTypes.FirstOrDefault(t => t.Name == typeName); - - if (currentType == null) return new Dictionary(); - - foreach (var segment in chain) - { - currentType = ResolvePropertyType(currentType, segment); - if (currentType == null) return new Dictionary(); - } - - var methodInfo = currentType - .GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public) - .FirstOrDefault(m => m.Name == methodName && !m.IsSpecialName); - if (methodInfo == null) return new Dictionary(); - - return BuildMethodDictionary(methodInfo); - } - - - private static Array GetMembersForType(Type type) - { - Array members = new Array(); - - if (type.IsEnum) - { - foreach (var name in type.GetEnumNames()) - { - members.Add(new Dictionary() { - { "name", name }, - { "type", "enum" } - }); - } - return members; - } - - var memberInfos = type.GetMembers(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); - foreach (var memberInfo in memberInfos) - { - switch (memberInfo.MemberType) - { - case MemberTypes.Field: - FieldInfo fieldInfo = (FieldInfo)memberInfo; - string fieldType; - if (fieldInfo.FieldType.ToString().Contains("EventHandler")) - { - fieldType = "signal"; - } - else if (fieldInfo.IsLiteral) - { - fieldType = "constant"; - } - else - { - fieldType = "property"; - } - members.Add(new Dictionary() { - { "name", memberInfo.Name }, - { "type", fieldType }, - { "class_name", GetFriendlyTypeName(fieldInfo.FieldType) } - }); - break; - - case MemberTypes.Property: - PropertyInfo propInfo = (PropertyInfo)memberInfo; - members.Add(new Dictionary() { - { "name", memberInfo.Name }, - { "type", "property" }, - { "class_name", GetFriendlyTypeName(propInfo.PropertyType) } - }); - break; - - case MemberTypes.Method: - MethodInfo methodInfo = (MethodInfo)memberInfo; - if (methodInfo.IsSpecialName) continue; - members.Add(BuildMethodDictionary(methodInfo)); - break; - - case MemberTypes.NestedType: - members.Add(new Dictionary() { - { "name", memberInfo.Name }, - { "type", "constant" } - }); - break; - - default: - continue; - } - } - - return members; - } - - - private static Dictionary BuildMethodDictionary(MethodInfo methodInfo) - { - var args = new Array(); - foreach (var param in methodInfo.GetParameters()) - { - args.Add(new Dictionary() { - { "name", param.Name ?? "" }, - { "type", (int)Variant.Type.Nil }, - { "class_name", GetFriendlyTypeName(param.ParameterType) } - }); - } - return new Dictionary() { - { "name", methodInfo.Name }, - { "type", "method" }, - { "args", args } - }; - } - - - private static Type? ResolvePropertyType(Type type, string memberName) - { - var field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); - if (field != null) return field.FieldType; - - var prop = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); - if (prop != null) return prop.PropertyType; - - var nested = type.GetNestedType(memberName, BindingFlags.Public); - if (nested != null) return nested; - - return null; - } - - - private static string GetFriendlyTypeName(Type type) - { - if (type == typeof(int)) return "int"; - if (type == typeof(long)) return "long"; - if (type == typeof(float)) return "float"; - if (type == typeof(double)) return "double"; - if (type == typeof(bool)) return "bool"; - if (type == typeof(string)) return "string"; - if (type == typeof(void)) return "void"; - if (type == typeof(byte)) return "byte"; - if (type == typeof(short)) return "short"; - if (type == typeof(char)) return "char"; - if (type == typeof(decimal)) return "decimal"; - return type.Name; - } - - - public bool ThingHasConstant(GodotObject thing, string property) - { - var memberInfos = thing.GetType().GetMember(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); - return memberInfos.Length > 0; - } - - - public Variant ResolveThingConstant(GodotObject thing, string property) - { - var memberInfos = thing.GetType().GetMember(property, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public); - foreach (var memberInfo in memberInfos) - { - if (memberInfo != null) - { - try - { - switch (memberInfo) - { - case FieldInfo fieldInfo: - return ConvertValueToVariant(fieldInfo.GetValue(thing)); - - case PropertyInfo propInfo: - return ConvertValueToVariant(propInfo.GetValue(thing)); - - case Type nestedType when nestedType.IsEnum: - return GetEnumAsDictionary(nestedType); - - default: - break; - } - } - catch (Exception e) - { - throw new Exception($"{property} is not supported by Variant.", e); - } - } - } - - throw new Exception($"{property} is not a public constant on {thing}"); - } - - - Dictionary GetEnumAsDictionary(Type enumType) - { - Dictionary dictionary = new Dictionary(); - foreach (var value in enumType.GetEnumValuesAsUnderlyingType()) - { - var key = enumType.GetEnumName(value); - if (key != null) - { - dictionary.Add(key, ConvertValueToVariant(value)); - } - } - return dictionary; - } - - - Variant ConvertValueToVariant(object? value) - { - if (value == null) return default; - - Type rawType = value.GetType(); - if (rawType.IsEnum) - { - value = Convert.ChangeType(value, Enum.GetUnderlyingType(rawType)); - } - - return value switch - { - Variant v => v, - bool v => Variant.From(v), - byte v => Variant.From((long)v), - sbyte v => Variant.From((long)v), - short v => Variant.From((long)v), - ushort v => Variant.From((long)v), - int v => Variant.From((long)v), - uint v => Variant.From((long)v), - long v => Variant.From(v), - ulong v => Variant.From((long)v), - float v => Variant.From((double)v), - double v => Variant.From(v), - string v => Variant.From(v), - Godot.Collections.Array v => v, - Godot.Collections.Dictionary v => v, - GodotObject godotObj => Variant.From(godotObj), - _ => ConvertOtherValueToVariant(value, rawType) - }; - } - - - // Anything Variant supports that isn't covered by the fast paths above (typed collections like Array and Dictionary, packed arrays, - // Vector2/3/4, Color, etc) is boxed through the generic marshaller so it survives the trip into GDScript instead of silently becoming null. - Variant ConvertOtherValueToVariant(object value, Type rawType) - { - try - { - MethodInfo from = typeof(Variant) - .GetMethods(BindingFlags.Public | BindingFlags.Static) - .First(m => m.Name == nameof(Variant.From) && m.IsGenericMethodDefinition) - .MakeGenericMethod(rawType); - return (Variant)from.Invoke(null, new[] { value })!; - } - catch (Exception) - { - return default; - } - } - - - public Array GetMethodList(GodotObject thing) - { - var methodList = new Array(); - - if (thing == null) return methodList; - - Type type = thing.GetType(); - MethodInfo[] methodInfos = GetMethodsForType(type); - - foreach (MethodInfo method in methodInfos) - { - if (method.IsSpecialName) continue; - - var methodInfo = new Dictionary(); - methodInfo["name"] = method.Name; - methodInfo["flags"] = 0; - methodInfo["dotnet"] = true; - - var argsList = new Array(); - ParameterInfo[] parameters = method.GetParameters(); - - foreach (ParameterInfo parameter in parameters) - { - var paramInfo = new Dictionary() { }; - Variant.Type godotType = ConvertToVariantType(parameter.ParameterType); - - paramInfo["name"] = parameter.Name ?? ""; - paramInfo["type"] = (int)godotType; - if (godotType == Variant.Type.Object) - { - paramInfo["class_name"] = parameter.ParameterType.Name; - } - else - { - paramInfo["class_name"] = string.Empty; - } - - argsList.Add(paramInfo); - } - - methodInfo["args"] = argsList; - methodList.Add(methodInfo); - } - - return methodList; - } - - - private Variant.Type ConvertToVariantType(Type type) - { - if (type == typeof(void)) return Variant.Type.Nil; - if (type == typeof(bool)) return Variant.Type.Bool; - if (type == typeof(long) || type == typeof(int) || type == typeof(short) || type == typeof(byte)) return Variant.Type.Int; - if (type == typeof(double) || type == typeof(float)) return Variant.Type.Float; - if (type == typeof(string)) return Variant.Type.String; - - if (type == typeof(Vector2)) return Variant.Type.Vector2; - if (type == typeof(Vector2I)) return Variant.Type.Vector2I; - if (type == typeof(Rect2)) return Variant.Type.Rect2; - if (type == typeof(Rect2I)) return Variant.Type.Rect2I; - if (type == typeof(Vector3)) return Variant.Type.Vector3; - if (type == typeof(Vector3I)) return Variant.Type.Vector3I; - if (type == typeof(Transform2D)) return Variant.Type.Transform2D; - if (type == typeof(Vector4)) return Variant.Type.Vector4; - if (type == typeof(Vector4I)) return Variant.Type.Vector4I; - if (type == typeof(Plane)) return Variant.Type.Plane; - if (type == typeof(Quaternion)) return Variant.Type.Quaternion; - if (type == typeof(Aabb)) return Variant.Type.Aabb; - if (type == typeof(Basis)) return Variant.Type.Basis; - if (type == typeof(Transform3D)) return Variant.Type.Transform3D; - if (type == typeof(Projection)) return Variant.Type.Projection; - - if (type == typeof(Color)) return Variant.Type.Color; - if (type == typeof(StringName)) return Variant.Type.StringName; - if (type == typeof(NodePath)) return Variant.Type.NodePath; - if (type == typeof(Rid)) return Variant.Type.Rid; - - if (typeof(GodotObject).IsAssignableFrom(type)) return Variant.Type.Object; - if (typeof(Dictionary).IsAssignableFrom(type)) return Variant.Type.Dictionary; - if (typeof(Godot.Collections.Array).IsAssignableFrom(type)) return Variant.Type.Array; - - if (type == typeof(byte[])) return Variant.Type.PackedByteArray; - if (type == typeof(int[])) return Variant.Type.PackedInt32Array; - if (type == typeof(long[])) return Variant.Type.PackedInt64Array; - if (type == typeof(float[])) return Variant.Type.PackedFloat32Array; - if (type == typeof(double[])) return Variant.Type.PackedFloat64Array; - if (type == typeof(string[])) return Variant.Type.PackedStringArray; - if (type == typeof(Vector2[])) return Variant.Type.PackedVector2Array; - if (type == typeof(Vector3[])) return Variant.Type.PackedVector3Array; - if (type == typeof(Color[])) return Variant.Type.PackedColorArray; - if (type == typeof(Vector4[])) return Variant.Type.PackedVector4Array; - - return Variant.Type.Nil; - } - - private bool IsCompatible(Type expectedType, Type providedType) - { - if (expectedType.IsAssignableFrom(providedType)) return true; - - Variant.Type expectedVariant = ConvertToVariantType(expectedType); - Variant.Type actualVariant = ConvertToVariantType(providedType); - - return expectedVariant == actualVariant && expectedVariant != Variant.Type.Nil; - } - - - - public bool ThingHasMethod(GodotObject thing, string method, Array args) - { - return GetMethodInfoFor(thing, method, args) != null; - } - - - public async void ResolveThingMethod(float id, GodotObject thing, string method, Array args) - { - // Add a single frame wait in case the method returns before signals can listen - await ToSignal(Engine.GetMainLoop(), SceneTree.SignalName.ProcessFrame); - - var methodInfo = GetMethodInfoFor(thing, method, args); - - if (methodInfo == null) - { - EmitSignal(SignalName.Resolved, id, default); - return; - } - -#nullable disable - // Convert the method args to something reflection can handle - ParameterInfo[] argTypes = methodInfo.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) - { - 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; - } - } - - // invoke method and handle the result based on return type - object result = methodInfo.Invoke(thing, _args); - - if (result is Task taskResult) - { - await taskResult; - try - { - object value = taskResult.GetType().GetProperty("Result").GetValue(taskResult); - EmitSignal(SignalName.Resolved, id, ConvertValueToVariant(value)); - } - catch (Exception) - { - EmitSignal(SignalName.Resolved, id, default); - } - } - else - { - EmitSignal(SignalName.Resolved, id, ConvertValueToVariant(result)); - } - } -#nullable enable - - - private MethodInfo? GetMethodInfoFor(GodotObject thing, string method, Array args) - { - return GetMethodsForType(thing.GetType()).Where(m => m.Name == method).FirstOrDefault(m => - { - ParameterInfo[] parameters = m.GetParameters(); - - if (args.Count > parameters.Length) return false; - - for (int i = args.Count; i < parameters.Length; i++) - { - if (!parameters[i].IsOptional) return false; - } - - Type[] argTypes = args.Select(arg => - { - // If the item is boxed inside a Godot Variant, extract its actual type. - if (arg is Variant godotVariant) - { - return godotVariant.VariantType switch - { - Variant.Type.Nil => typeof(object), - Variant.Type.Bool => typeof(bool), - Variant.Type.Int => typeof(long), // Godot ints map to C# longs - Variant.Type.Float => typeof(double), // Godot floats map to C# doubles - Variant.Type.String => typeof(string), - Variant.Type.Object => godotVariant.AsGodotObject()?.GetType() ?? typeof(object), - _ => godotVariant.Obj?.GetType() ?? typeof(object) - }; - } - - return arg.GetType(); - }).ToArray(); - - // Check each given parameter type against what the method wants. - for (int i = 0; i < argTypes.Length; i++) - { - Type expectedType = parameters[i].ParameterType; - Type actualType = argTypes[i]; - - // If a parameter isn't compatible skip this method overload. - if (!IsCompatible(expectedType, actualType)) - { - return false; - } - } - - return true; - }); - } - - - public static string GetErrorMessage(int error) - { - return (string)Instance.Call("_bridge_get_error_message", error); - } - - - public static string Translate(string s) - { - return (string)Instance.Call("_bridge_translate", s); - } - } - - - public partial class DialogueLine : RefCounted - { - /// - /// The ID of this line - /// - public string Id { get; set; } = ""; - - /// - /// The internal type of this dialogue object. - /// - public string Type { get; set; } = "dialogue"; - - /// - /// The next line ID after this line. - /// - public string NextId { get; set; } = ""; - - /// - /// The character name that is saying this line. - /// - public string Character { get; set; } = ""; - - /// - /// The dialogue being spoken. - /// - public string Text { get; set; } = ""; - - /// - /// The key to use for translating this line. - /// - public string StaticId { get; set; } = ""; - - /// - /// A list of responses attached to this line of dialogue. - /// - public Array Responses { get; } = new Array(); - - /// - /// How long to show this line before advancing to the next. Either a float of seconds (as a string), "auto", or empty string. - /// - public string? Time { get; private set; } - - /// - /// A map for speed changes when typing out the dialogue text. - /// - public Dictionary Speeds { get; private set; } = new Dictionary(); - - /// - /// A map of any mutations to run while typing out the dialogue text. - /// - public Array InlineMutations { get; private set; } = new Array(); - - /// - /// A list of lines that are spoken simultaneously with this one. - /// - public Array ConcurrentLines { get; } = new Array(); - - /// - /// A list of any extra game states to check when resolving variables and mutations. - /// - public Array ExtraGameStates { get; } = new Array(); - - /// - /// Any #tags that were included in the line - /// - public Array Tags { get; private set; } = new Array(); - - - public DialogueLine(RefCounted data) - { - Id = (string)data.Get("id"); - Type = (string)data.Get("type"); - NextId = (string)data.Get("next_id"); - Character = (string)data.Get("character"); - Text = (string)data.Get("text"); - StaticId = (string)data.Get("static_id"); - Speeds = (Dictionary)data.Get("speeds"); - InlineMutations = (Array)data.Get("inline_mutations"); - Time = (string)data.Get("time"); - Tags = (Array)data.Get("tags"); - ExtraGameStates = (Array)data.Get("extra_game_states"); - - foreach (var concurrent_line_data in (Array)data.Get("concurrent_lines")) - { - ConcurrentLines.Add(new DialogueLine(concurrent_line_data)); - } - - foreach (var response in (Array)data.Get("responses")) - { - Responses.Add(new DialogueResponse(response)); - } - } - - - /// - /// Check if a dialogue line has a given tag. - /// - /// - /// - public bool HasTag(string tagName) - { - if (Tags.Contains(tagName)) - { - return true; - } - else - { - string wrapped = $"{tagName}="; - foreach (var tag in Tags) - { - if (tag.StartsWith(wrapped)) - { - return true; - } - } - return false; - } - } - - - /// - /// Get the value of a tag if the tag is in the form of tag=value - /// - /// - /// - 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 - { - /// - /// The ID of this response - /// - public string NextId { get; set; } = ""; - - /// - /// true if the condition of this line was met. - /// - public bool IsAllowed { get; set; } = true; - - /// - /// The original condition text. - /// - public string ConditionAsText { get; set; } = ""; - - /// - /// The prompt for this response. - /// - public string Text { get; set; } = ""; - - /// - /// The key to use for translating the text. - /// - public string StaticId { get; set; } = ""; - - /// - /// Any #tags - /// - public Array Tags { get; private set; } = new Array(); - - - public DialogueResponse(RefCounted data) - { - NextId = (string)data.Get("next_id"); - IsAllowed = (bool)data.Get("is_allowed"); - Text = (string)data.Get("text"); - StaticId = (string)data.Get("static_id"); - Tags = (Array)data.Get("tags"); - } - - - /// - /// Check if a dialogue line has a given tag. - /// - /// - /// - public bool HasTag(string tagName) - { - if (Tags.Contains(tagName)) - { - return true; - } - else - { - string wrapped = $"{tagName}="; - foreach (var tag in Tags) - { - if (tag.StartsWith(wrapped)) - { - return true; - } - } - return false; - } - } - - - /// - /// Get the value of a tag if the tag is in the form of tag=value - /// - /// - /// - 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 $" temporaryGameStates = new Array(); - bool isWaitingForInput = false; - bool willHideBalloon = false; - - DialogueLine dialogueLine; - DialogueLine DialogueLine - { - get => dialogueLine; - set - { - // Dialogue has finished so close the balloon - if (value == null) - { - if (Owner == null) - { - QueueFree(); - } - else - { - Hide(); - } - return; - } - - dialogueLine = value; - ApplyDialogueLine(); - } - } - - Timer MutationCooldown = new Timer(); - - - public override void _Ready() - { - balloon = GetNode("%Balloon"); - characterLabel = GetNode("%CharacterLabel"); - dialogueLabel = GetNode("%DialogueLabel"); - responsesMenu = GetNode("%ResponsesMenu"); - progress = GetNode("%Progress"); - - balloon.Hide(); - - balloon.GuiInput += (@event) => - { - if (dialogueLabel.IsTyping) - { - bool mouseWasClicked = @event is InputEventMouseButton && (@event as InputEventMouseButton).ButtonIndex == MouseButton.Left && @event.IsPressed(); - bool skipButtonWasPressed = @event.IsActionPressed(SkipAction); - if (mouseWasClicked || skipButtonWasPressed) - { - GetViewport().SetInputAsHandled(); - dialogueLabel.SkipTyping(); - return; - } - } - - if (!isWaitingForInput) return; - if (dialogueLine.Responses.Count > 0) return; - - GetViewport().SetInputAsHandled(); - - if (@event is InputEventMouseButton && @event.IsPressed() && (@event as InputEventMouseButton).ButtonIndex == MouseButton.Left) - { - Next(dialogueLine.NextId); - } - else if (@event.IsActionPressed(NextAction) && GetViewport().GuiGetFocusOwner() == balloon) - { - Next(dialogueLine.NextId); - } - }; - - if (string.IsNullOrEmpty(responsesMenu.NextAction)) - { - responsesMenu.NextAction = NextAction; - } - responsesMenu.ResponseSelected += (response) => - { - Next(response.NextId); - }; - - - // Hide the balloon when a mutation is running - MutationCooldown.Timeout += () => - { - if (willHideBalloon) - { - willHideBalloon = false; - balloon.Hide(); - } - }; - AddChild(MutationCooldown); - - DialogueManager.Mutated += OnMutated; - - if (AutoStart) - { - if (!IsInstanceValid(DialogueResource)) - { - throw new System.Exception(DialogueManager.GetErrorMessage(143)); - } - Start(); - } - - // EXAMPLE MESSAGE - var warning = new Button - { - Text = DialogueManager.Translate("This is an example balloon. Create your own balloon in 'Project > Tools > Dialogue > Create Balloon...'"), - Disabled = true - }; - warning.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.TopWide); - balloon.AddChild(warning); - balloon.MoveChild(warning, 0); - // END EXAMPLE MESSAGE - } - - - public override void _ExitTree() - { - DialogueManager.Mutated -= OnMutated; - } - - - public override void _UnhandledInput(InputEvent @event) - { - // Only the balloon is allowed to handle input while it's showing - GetViewport().SetInputAsHandled(); - } - - - public override async void _Notification(int what) - { - // Detect a change of locale and update the current dialogue line to show the new language - if (what == NotificationTranslationChanged && IsInstanceValid(dialogueLabel)) - { - float visibleRatio = dialogueLabel.VisibleRatio; - DialogueLine = await DialogueManager.GetNextDialogueLine(DialogueResource, DialogueLine.Id, temporaryGameStates); - if (visibleRatio < 1.0f) - { - dialogueLabel.SkipTyping(); - } - } - } - - - public override void _Process(double delta) - { - base._Process(delta); - - if (IsInstanceValid(dialogueLine)) - { - progress.Visible = !dialogueLabel.IsTyping && dialogueLine.Responses.Count == 0 && !dialogueLine.HasTag("voice"); - } - } - - - public async void Start(Resource dialogueResource = null, string label = "", Array extraGameStates = null) - { - temporaryGameStates = new Array { this } + (extraGameStates ?? new Array()); - isWaitingForInput = false; - - if (IsInstanceValid(dialogueResource)) - { - DialogueResource = dialogueResource; - } - if (label != "") - { - StartFromLabel = label; - } - - DialogueLine = await DialogueManager.GetNextDialogueLine(DialogueResource, StartFromLabel, temporaryGameStates); - Show(); - } - - - public async void Next(string nextId) - { - DialogueLine = await DialogueManager.GetNextDialogueLine(DialogueResource, nextId, temporaryGameStates); - } - - - #region Helpers - - - private async void ApplyDialogueLine() - { - MutationCooldown.Stop(); - - isWaitingForInput = false; - balloon.FocusMode = Control.FocusModeEnum.All; - balloon.GrabFocus(); - - // Set up the character name - characterLabel.Visible = !string.IsNullOrEmpty(dialogueLine.Character); - characterLabel.Text = Tr(dialogueLine.Character, "dialogue"); - - // Set up the dialogue - dialogueLabel.Hide(); - dialogueLabel.DialogueLine = dialogueLine; - - // Set up the responses - responsesMenu.Hide(); - responsesMenu.Responses = dialogueLine.Responses; - - // Type out the text - balloon.Show(); - willHideBalloon = false; - dialogueLabel.Show(); - if (!string.IsNullOrEmpty(dialogueLine.Text)) - { - dialogueLabel.TypeOut(); - await ToSignal(dialogueLabel, DialogueLabel.SignalName.FinishedTyping); - } - - // Wait for input - if (dialogueLine.Responses.Count > 0) - { - balloon.FocusMode = Control.FocusModeEnum.None; - responsesMenu.Show(); - } - else if (!string.IsNullOrEmpty(dialogueLine.Time)) - { - float time = 0f; - if (!float.TryParse(dialogueLine.Time, out time)) - { - time = dialogueLine.Text.Length * 0.02f; - } - await ToSignal(GetTree().CreateTimer(time), Timer.SignalName.Timeout); - Next(dialogueLine.NextId); - } - else - { - isWaitingForInput = true; - balloon.FocusMode = Control.FocusModeEnum.All; - balloon.GrabFocus(); - } - } - - - #endregion - - - #region signals - - - private void OnMutated(Dictionary mutation) - { - if (!(bool)mutation["is_inline"]) - { - isWaitingForInput = false; - willHideBalloon = true; - MutationCooldown.Start(0.1f); - } - } - - - #endregion - } -} diff --git a/addons/dialogue_manager/example_balloon/ExampleBalloon.cs.uid b/addons/dialogue_manager/example_balloon/ExampleBalloon.cs.uid deleted file mode 100644 index 4b3783a5cf..0000000000 --- a/addons/dialogue_manager/example_balloon/ExampleBalloon.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://5b3w40kwakl3 diff --git a/addons/dialogue_manager/example_balloon/ExampleBalloon.tscn b/addons/dialogue_manager/example_balloon/ExampleBalloon.tscn deleted file mode 100644 index 1574805132..0000000000 --- a/addons/dialogue_manager/example_balloon/ExampleBalloon.tscn +++ /dev/null @@ -1,204 +0,0 @@ -[gd_scene format=3 uid="uid://blvx2ftn6ycqd"] - -[ext_resource type="Script" uid="uid://5b3w40kwakl3" path="res://addons/dialogue_manager/example_balloon/ExampleBalloon.cs" id="1_36de5"] -[ext_resource type="PackedScene" uid="uid://c3qmxhslp0dl7" path="res://addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.tscn" id="2_a8ve6"] -[ext_resource type="Script" uid="uid://bf0gf4upyxj5l" path="res://addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs" id="3_72ixx"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_spyqn"] -content_margin_left = 20.0 -content_margin_top = 10.0 -content_margin_right = 20.0 -content_margin_bottom = 10.0 -bg_color = Color(0, 0, 0, 1) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 3 -border_color = Color(0.329412, 0.329412, 0.329412, 1) -corner_radius_top_left = 5 -corner_radius_top_right = 5 -corner_radius_bottom_right = 5 -corner_radius_bottom_left = 5 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ri4m3"] -content_margin_left = 20.0 -content_margin_top = 10.0 -content_margin_right = 20.0 -content_margin_bottom = 10.0 -bg_color = Color(0.121569, 0.121569, 0.121569, 1) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 3 -border_color = Color(1, 1, 1, 1) -corner_radius_top_left = 5 -corner_radius_top_right = 5 -corner_radius_bottom_right = 5 -corner_radius_bottom_left = 5 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e0njw"] -content_margin_left = 20.0 -content_margin_top = 10.0 -content_margin_right = 20.0 -content_margin_bottom = 10.0 -bg_color = Color(0, 0, 0, 1) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 3 -border_color = Color(0.6, 0.6, 0.6, 1) -corner_radius_top_left = 5 -corner_radius_top_right = 5 -corner_radius_bottom_right = 5 -corner_radius_bottom_left = 5 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qkmqt"] -bg_color = Color(0, 0, 0, 1) -border_width_left = 3 -border_width_top = 3 -border_width_right = 3 -border_width_bottom = 3 -corner_radius_top_left = 5 -corner_radius_top_right = 5 -corner_radius_bottom_right = 5 -corner_radius_bottom_left = 5 - -[sub_resource type="Theme" id="Theme_qq3yp"] -default_font_size = 20 -Button/styles/disabled = SubResource("StyleBoxFlat_spyqn") -Button/styles/focus = SubResource("StyleBoxFlat_ri4m3") -Button/styles/hover = SubResource("StyleBoxFlat_e0njw") -Button/styles/normal = SubResource("StyleBoxFlat_e0njw") -MarginContainer/constants/margin_bottom = 15 -MarginContainer/constants/margin_left = 30 -MarginContainer/constants/margin_right = 30 -MarginContainer/constants/margin_top = 15 -PanelContainer/styles/panel = SubResource("StyleBoxFlat_qkmqt") - -[sub_resource type="Animation" id="Animation_nlsx6"] -length = 0.001 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Progress:position:y") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0), -"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), -"times": PackedFloat32Array(0) -} - -[sub_resource type="Animation" id="Animation_qkmqt"] -resource_name = "progress" -loop_mode = 1 -step = 0.1 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Progress:position:y") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0, 0, 0, 0, 0), -"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.2, -0.0157438, -4, -0.2, 0.0112069, 0.25, 0, -4, -0.25, 0, 0.25, 0, 0, -0.2, 0.00299701, 0.25, 0), -"times": PackedFloat32Array(0, 0.1, 0.5, 0.6, 1) -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_1337t"] -_data = { -&"RESET": SubResource("Animation_nlsx6"), -&"progress": SubResource("Animation_qkmqt") -} - -[node name="ExampleBalloon" type="CanvasLayer" unique_id=615431052] -layer = 100 -script = ExtResource("1_36de5") - -[node name="Balloon" type="Control" parent="." unique_id=197696518] -unique_name_in_owner = true -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme = SubResource("Theme_qq3yp") - -[node name="MarginContainer" type="MarginContainer" parent="Balloon" unique_id=1192375565] -layout_mode = 1 -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = -219.0 -grow_horizontal = 2 -grow_vertical = 0 - -[node name="PanelContainer" type="PanelContainer" parent="Balloon/MarginContainer" unique_id=66397601] -clip_children = 2 -layout_mode = 2 -mouse_filter = 1 - -[node name="MarginContainer" type="MarginContainer" parent="Balloon/MarginContainer/PanelContainer" unique_id=338276858] -layout_mode = 2 - -[node name="HBoxContainer" type="HBoxContainer" parent="Balloon/MarginContainer/PanelContainer/MarginContainer" unique_id=587923225] -layout_mode = 2 - -[node name="VBoxContainer" type="VBoxContainer" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer" unique_id=141270408] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="CharacterLabel" type="RichTextLabel" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer/VBoxContainer" unique_id=1867683141] -unique_name_in_owner = true -modulate = Color(1, 1, 1, 0.501961) -layout_mode = 2 -mouse_filter = 1 -bbcode_enabled = true -text = "Character" -fit_content = true -scroll_active = false - -[node name="DialogueLabel" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer/VBoxContainer" unique_id=1739101537 instance=ExtResource("2_a8ve6")] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 3 -text = "Dialogue..." - -[node name="Control" type="Control" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer" unique_id=534060310] -custom_minimum_size = Vector2(20, 10) -layout_mode = 2 -size_flags_vertical = 8 - -[node name="Progress" type="Polygon2D" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer/Control" unique_id=838836721] -unique_name_in_owner = true -polygon = PackedVector2Array(0, 0, 10, 10, 20, 0) - -[node name="AnimationPlayer" type="AnimationPlayer" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer/Control" unique_id=473539640] -libraries/ = SubResource("AnimationLibrary_1337t") -autoplay = &"progress" - -[node name="CenterContainer" type="CenterContainer" parent="Balloon" unique_id=473552711] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="ResponsesMenu" type="VBoxContainer" parent="Balloon/CenterContainer" unique_id=1321351341 node_paths=PackedStringArray("ResponseTemplate")] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 8 -theme_override_constants/separation = 2 -alignment = 1 -script = ExtResource("3_72ixx") -ResponseTemplate = NodePath("ResponseExample") - -[node name="ResponseExample" type="Button" parent="Balloon/CenterContainer/ResponsesMenu" unique_id=1595872767] -layout_mode = 2 -text = "Response example" - -[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="." unique_id=140912110] -unique_name_in_owner = true diff --git a/addons/dialogue_manager/example_balloon/SmallExampleBalloon.tscn b/addons/dialogue_manager/example_balloon/SmallExampleBalloon.tscn deleted file mode 100644 index a3f7ce1307..0000000000 --- a/addons/dialogue_manager/example_balloon/SmallExampleBalloon.tscn +++ /dev/null @@ -1,202 +0,0 @@ -[gd_scene format=3 uid="uid://dwcmp07fyu5ah"] - -[ext_resource type="Script" uid="uid://5b3w40kwakl3" path="res://addons/dialogue_manager/example_balloon/ExampleBalloon.cs" id="1_s2gbs"] -[ext_resource type="PackedScene" uid="uid://c3qmxhslp0dl7" path="res://addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.tscn" id="2_hfvdi"] -[ext_resource type="Script" uid="uid://bf0gf4upyxj5l" path="res://addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs" id="3_1j1j0"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_235ry"] -content_margin_left = 6.0 -content_margin_top = 3.0 -content_margin_right = 6.0 -content_margin_bottom = 3.0 -bg_color = Color(0.0666667, 0.0666667, 0.0666667, 1) -border_width_left = 1 -border_width_top = 1 -border_width_right = 1 -border_width_bottom = 1 -border_color = Color(0.345098, 0.345098, 0.345098, 1) -corner_radius_top_left = 3 -corner_radius_top_right = 3 -corner_radius_bottom_right = 3 -corner_radius_bottom_left = 3 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ufjut"] -content_margin_left = 6.0 -content_margin_top = 3.0 -content_margin_right = 6.0 -content_margin_bottom = 3.0 -bg_color = Color(0.227451, 0.227451, 0.227451, 1) -border_width_left = 1 -border_width_top = 1 -border_width_right = 1 -border_width_bottom = 1 -border_color = Color(1, 1, 1, 1) -corner_radius_top_left = 3 -corner_radius_top_right = 3 -corner_radius_bottom_right = 3 -corner_radius_bottom_left = 3 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fcbqo"] -content_margin_left = 6.0 -content_margin_top = 3.0 -content_margin_right = 6.0 -content_margin_bottom = 3.0 -bg_color = Color(0.0666667, 0.0666667, 0.0666667, 1) -border_width_left = 1 -border_width_top = 1 -border_width_right = 1 -border_width_bottom = 1 -corner_radius_top_left = 3 -corner_radius_top_right = 3 -corner_radius_bottom_right = 3 -corner_radius_bottom_left = 3 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_t6i7a"] -content_margin_left = 6.0 -content_margin_top = 3.0 -content_margin_right = 6.0 -content_margin_bottom = 3.0 -bg_color = Color(0.0666667, 0.0666667, 0.0666667, 1) -border_width_left = 1 -border_width_top = 1 -border_width_right = 1 -border_width_bottom = 1 -corner_radius_top_left = 3 -corner_radius_top_right = 3 -corner_radius_bottom_right = 3 -corner_radius_bottom_left = 3 - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_i6nbm"] -bg_color = Color(0, 0, 0, 1) -border_width_left = 1 -border_width_top = 1 -border_width_right = 1 -border_width_bottom = 1 -corner_radius_top_left = 3 -corner_radius_top_right = 3 -corner_radius_bottom_right = 3 -corner_radius_bottom_left = 3 - -[sub_resource type="Theme" id="Theme_qq3yp"] -default_font_size = 8 -Button/styles/disabled = SubResource("StyleBoxFlat_235ry") -Button/styles/focus = SubResource("StyleBoxFlat_ufjut") -Button/styles/hover = SubResource("StyleBoxFlat_fcbqo") -Button/styles/normal = SubResource("StyleBoxFlat_t6i7a") -MarginContainer/constants/margin_bottom = 4 -MarginContainer/constants/margin_left = 8 -MarginContainer/constants/margin_right = 8 -MarginContainer/constants/margin_top = 4 -PanelContainer/styles/panel = SubResource("StyleBoxFlat_i6nbm") - -[sub_resource type="Animation" id="Animation_i6nbm"] -resource_name = "progress" -loop_mode = 1 -step = 0.1 -tracks/0/type = "bezier" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Progress:position:y") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"handle_modes": PackedInt32Array(0, 0, 0, 0, 0), -"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.2, -0.0157438, -1, -0.2, 0.0112069, 0.25, 0, -1, -0.25, 0, 0.25, 0, 0, -0.2, 0.00299701, 0.25, 0), -"times": PackedFloat32Array(0, 0.1, 0.5, 0.6, 1) -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_6b6c8"] -_data = { -&"progress": SubResource("Animation_i6nbm") -} - -[node name="ExampleBalloon" type="CanvasLayer" unique_id=1448364161] -layer = 100 -script = ExtResource("1_s2gbs") - -[node name="Balloon" type="Control" parent="." unique_id=1854621134] -unique_name_in_owner = true -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme = SubResource("Theme_qq3yp") - -[node name="MarginContainer" type="MarginContainer" parent="Balloon" unique_id=682848477] -layout_mode = 1 -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = -71.0 -grow_horizontal = 2 -grow_vertical = 0 - -[node name="PanelContainer" type="PanelContainer" parent="Balloon/MarginContainer" unique_id=1589990687] -clip_children = 2 -layout_mode = 2 -mouse_filter = 1 - -[node name="MarginContainer" type="MarginContainer" parent="Balloon/MarginContainer/PanelContainer" unique_id=1001222780] -layout_mode = 2 - -[node name="HBoxContainer" type="HBoxContainer" parent="Balloon/MarginContainer/PanelContainer/MarginContainer" unique_id=953735783] -layout_mode = 2 - -[node name="VBoxContainer" type="VBoxContainer" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer" unique_id=636314399] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="CharacterLabel" type="RichTextLabel" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer/VBoxContainer" unique_id=571791881] -unique_name_in_owner = true -modulate = Color(1, 1, 1, 0.501961) -layout_mode = 2 -mouse_filter = 1 -bbcode_enabled = true -text = "Character" -fit_content = true -scroll_active = false - -[node name="DialogueLabel" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer/VBoxContainer" unique_id=388630144 instance=ExtResource("2_hfvdi")] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 3 -text = "Dialogue..." - -[node name="Control" type="Control" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer" unique_id=2030531972] -custom_minimum_size = Vector2(5, 3) -layout_mode = 2 -size_flags_vertical = 8 - -[node name="Progress" type="Polygon2D" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer/Control" unique_id=1185159698] -unique_name_in_owner = true -position = Vector2(0, -0.455998) -polygon = PackedVector2Array(0, 0, 2.5, 3, 5, 0) - -[node name="AnimationPlayer" type="AnimationPlayer" parent="Balloon/MarginContainer/PanelContainer/MarginContainer/HBoxContainer/Control" unique_id=1445298592] -libraries/ = SubResource("AnimationLibrary_6b6c8") -autoplay = &"progress" - -[node name="CenterContainer" type="CenterContainer" parent="Balloon" unique_id=1054790561] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="ResponsesMenu" type="VBoxContainer" parent="Balloon/CenterContainer" unique_id=260756352] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 8 -theme_override_constants/separation = 2 -script = ExtResource("3_1j1j0") - -[node name="ResponseExample" type="Button" parent="Balloon/CenterContainer/ResponsesMenu" unique_id=1031268561] -layout_mode = 2 -text = "Response Example" - -[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="." unique_id=1157057297] -unique_name_in_owner = true diff --git a/addons/dialogue_manager/nodes/actionable/DialogueActionable2D.cs b/addons/dialogue_manager/nodes/actionable/DialogueActionable2D.cs deleted file mode 100644 index 44015833ba..0000000000 --- a/addons/dialogue_manager/nodes/actionable/DialogueActionable2D.cs +++ /dev/null @@ -1,141 +0,0 @@ -using Godot; -using Godot.Collections; -using System; - -namespace DialogueManagerRuntime -{ - /// - /// A special node to hold information about starting dialogue. - /// - /// Assuming DialogueResource and DialogueCue have been configured you can - /// call Action() on this node at runtime to start dialogue. - /// - [Tool, Icon("uid://ja67jst5iqyy")] - public partial class DialogueActionable2D : Area2D - { - /// - /// Emitted when this has Action() called on it. - /// - [Signal] public delegate void ActionedEventHandler(); - - /// - /// Emitted when the dialogue resource associated with this ends. NOTE: The - /// signal is also emitted if the same resource is used for multiple nodes in the tree. - /// - [Signal] public delegate void DialogueEndedEventHandler(); - - - private Resource dialogueResource = null; - - /// - /// The dialogue resource to use when starting dialogue. - /// - [Export] - public Resource DialogueResource - { - get => dialogueResource; - set - { - dialogueResource = value; - if (dialogueResource == null) - { - DialogueCue = ""; - } - NotifyPropertyListChanged(); - } - } - - /// - /// The target cue to start dialogue from. - /// - [Export] public string DialogueCue = ""; - - /// - /// The dialogue balloon that was last used by calling Action() (if there was one). - /// - public Node DialogueBalloon; - - /// - /// The method used to start dialogue when Action() is called. Override if you need different logic. - /// - public static Func, Node> StartDialogue = (withDialogueResource, fromCue, extraGameStates) => - DialogueManager.ShowDialogueBalloon(withDialogueResource, fromCue, extraGameStates); - - - public override void _Ready() - { - if (!Engine.IsEditorHint()) - { - AddToGroup("dialogue_actionables"); - // Touch the instance to make sure the DialogueManager bridge signals are connected - _ = DialogueManager.Instance; - DialogueManager.DialogueEnded += OnDialogueEnded; - } - } - - - public override void _ExitTree() - { - if (!Engine.IsEditorHint()) - { - DialogueManager.DialogueEnded -= OnDialogueEnded; - } - } - - - #region Public - - - /// - /// Action this . If a dialogue resource and cue have been set on this node then it will start dialogue. - /// - public void Action() - { - if (IsInstanceValid(DialogueResource) && !string.IsNullOrEmpty(DialogueCue)) - { - DialogueBalloon = StartDialogue(DialogueResource, DialogueCue, new Array { new Dictionary { { "actionable", this } }, Owner }); - } - EmitSignal(SignalName.Actioned); - } - - - /// - /// Find the nearest to a given position. - /// - public static DialogueActionable2D GetNearestActionableTo(Vector2 targetPosition) - { - float nearestDistance = float.PositiveInfinity; - DialogueActionable2D nearestActionable = null; - foreach (Node node in ((SceneTree)Engine.GetMainLoop()).GetNodesInGroup("dialogue_actionables")) - { - if (node is not DialogueActionable2D actionable) continue; - - float distance = actionable.GlobalPosition.DistanceSquaredTo(targetPosition); - if (distance < nearestDistance) - { - nearestDistance = distance; - nearestActionable = actionable; - } - } - - return nearestActionable; - } - - - #endregion - - #region Signals - - - private void OnDialogueEnded(Resource endingDialogueResource) - { - if (endingDialogueResource == DialogueResource) - { - EmitSignal(SignalName.DialogueEnded); - } - } - - - #endregion - } -} diff --git a/addons/dialogue_manager/nodes/actionable/DialogueActionable2D.cs.uid b/addons/dialogue_manager/nodes/actionable/DialogueActionable2D.cs.uid deleted file mode 100644 index 49af8c7a42..0000000000 --- a/addons/dialogue_manager/nodes/actionable/DialogueActionable2D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://d0sxb0wcim1wy diff --git a/addons/dialogue_manager/nodes/actionable/DialogueActionable3D.cs b/addons/dialogue_manager/nodes/actionable/DialogueActionable3D.cs deleted file mode 100644 index 9bc76fe359..0000000000 --- a/addons/dialogue_manager/nodes/actionable/DialogueActionable3D.cs +++ /dev/null @@ -1,141 +0,0 @@ -using Godot; -using Godot.Collections; -using System; - -namespace DialogueManagerRuntime -{ - /// - /// A special node to hold information about starting dialogue. - /// - /// Assuming DialogueResource and DialogueCue have been configured you can - /// call Action() on this node at runtime to start dialogue. - /// - [Tool, Icon("uid://dppsuhlvbcbjc")] - public partial class DialogueActionable3D : Area3D - { - /// - /// Emitted when this has Action() called on it. - /// - [Signal] public delegate void ActionedEventHandler(); - - /// - /// Emitted when the dialogue resource associated with this ends. NOTE: The - /// signal is also emitted if the same resource is used for multiple nodes in the tree. - /// - [Signal] public delegate void DialogueEndedEventHandler(); - - - private Resource dialogueResource = null; - - /// - /// The dialogue resource to use when starting dialogue. - /// - [Export] - public Resource DialogueResource - { - get => dialogueResource; - set - { - dialogueResource = value; - if (dialogueResource == null) - { - DialogueCue = ""; - } - NotifyPropertyListChanged(); - } - } - - /// - /// The target cue to start dialogue from. - /// - [Export] public string DialogueCue = ""; - - /// - /// The dialogue balloon that was last used by calling Action() (if there was one). - /// - public Node DialogueBalloon; - - /// - /// The method used to start dialogue when Action() is called. Override if you need different logic. - /// - public static Func, Node> StartDialogue = (withDialogueResource, fromCue, extraGameStates) => - DialogueManager.ShowDialogueBalloon(withDialogueResource, fromCue, extraGameStates); - - - public override void _Ready() - { - if (!Engine.IsEditorHint()) - { - AddToGroup("dialogue_actionables"); - // Touch the instance to make sure the DialogueManager bridge signals are connected - _ = DialogueManager.Instance; - DialogueManager.DialogueEnded += OnDialogueEnded; - } - } - - - public override void _ExitTree() - { - if (!Engine.IsEditorHint()) - { - DialogueManager.DialogueEnded -= OnDialogueEnded; - } - } - - - #region Public - - - /// - /// Action this . If a dialogue resource and cue have been set on this node then it will start dialogue. - /// - public void Action() - { - if (IsInstanceValid(DialogueResource) && !string.IsNullOrEmpty(DialogueCue)) - { - DialogueBalloon = StartDialogue(DialogueResource, DialogueCue, new Array { new Dictionary { { "actionable", this } }, Owner }); - } - EmitSignal(SignalName.Actioned); - } - - - /// - /// Find the nearest to a given position. - /// - public static DialogueActionable3D GetNearestActionableTo(Vector3 targetPosition) - { - float nearestDistance = float.PositiveInfinity; - DialogueActionable3D nearestActionable = null; - foreach (Node node in ((SceneTree)Engine.GetMainLoop()).GetNodesInGroup("dialogue_actionables")) - { - if (node is not DialogueActionable3D actionable) continue; - - float distance = actionable.GlobalPosition.DistanceSquaredTo(targetPosition); - if (distance < nearestDistance) - { - nearestDistance = distance; - nearestActionable = actionable; - } - } - - return nearestActionable; - } - - - #endregion - - #region Signals - - - private void OnDialogueEnded(Resource endingDialogueResource) - { - if (endingDialogueResource == DialogueResource) - { - EmitSignal(SignalName.DialogueEnded); - } - } - - - #endregion - } -} diff --git a/addons/dialogue_manager/nodes/actionable/DialogueActionable3D.cs.uid b/addons/dialogue_manager/nodes/actionable/DialogueActionable3D.cs.uid deleted file mode 100644 index 916f97d091..0000000000 --- a/addons/dialogue_manager/nodes/actionable/DialogueActionable3D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://5skdphbgu68t diff --git a/addons/dialogue_manager/nodes/context/DialogueStateContext.cs b/addons/dialogue_manager/nodes/context/DialogueStateContext.cs deleted file mode 100644 index c8013e4746..0000000000 --- a/addons/dialogue_manager/nodes/context/DialogueStateContext.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Godot; - -namespace DialogueManagerRuntime -{ - /// - /// Add a to a scene to expose a node (usually the base node) to dialogue. - /// - [Tool, Icon("uid://c22t5famre1yo")] - public partial class DialogueStateContext : Node - { - private string alias = ""; - - /// - /// The name used in dialogue to refer to the exposed target node. - /// - [Export] - public string Alias - { - get => alias; - set - { - alias = value; - UpdateConfigurationWarnings(); - } - } - - private Node target = null; - - /// - /// The target whose values are exposed to dialogue. - /// - [Export] - public Node Target - { - get => target; - set - { - target = value; - UpdateConfigurationWarnings(); - } - } - - - public override void _EnterTree() - { - if (!Engine.IsEditorHint()) - { - Callable.From(() => - { - DialogueManager.Instance.Call("register_state_context", Alias, Target); - }).CallDeferred(); - } - } - - - public override void _ExitTree() - { - if (!Engine.IsEditorHint()) - { - DialogueManager.Instance.Call("unregister_state_context", Alias); - } - } - - - public override string[] _GetConfigurationWarnings() - { - var warnings = new System.Collections.Generic.List(); - - if (string.IsNullOrEmpty(Alias)) - { - warnings.Add("Alias cannot be empty."); - } - - if (Target == null) - { - warnings.Add("Target cannot be null."); - } - - return warnings.ToArray(); - } - } -} diff --git a/addons/dialogue_manager/nodes/context/DialogueStateContext.cs.uid b/addons/dialogue_manager/nodes/context/DialogueStateContext.cs.uid deleted file mode 100644 index bd809e8eb0..0000000000 --- a/addons/dialogue_manager/nodes/context/DialogueStateContext.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b4hjd43iw4vj8 diff --git a/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs b/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs deleted file mode 100644 index 2ff6215ed6..0000000000 --- a/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs +++ /dev/null @@ -1,356 +0,0 @@ -using Godot; -using System.Globalization; -using System.Threading.Tasks; - -namespace DialogueManagerRuntime -{ - /// - /// A RichTextLabel specifically for use with Dialogue Manager dialogue. - /// - [Tool, Icon("uid://s0s1348tpm6d")] - public partial class DialogueLabel : RichTextLabel - { - /// - /// Emitted for each letter typed out. - /// - [Signal] public delegate void SpokeEventHandler(string letter, int letterIndex, float speed); - - /// - /// Emitted when the player skips the typing of dialogue. - /// - [Signal] public delegate void SkippedTypingEventHandler(); - - /// - /// Emitted when typing starts. - /// - [Signal] public delegate void StartedTypingEventHandler(); - - /// - /// Emitted when typing finishes. - /// - [Signal] public delegate void FinishedTypingEventHandler(); - - - /// - /// The action to press to skip typing. - /// - [Export] public StringName SkipAction = "ui_cancel"; - - /// - /// The speed with which the text types out. - /// - [Export] public float SecondsPerStep = 0.02f; - - /// - /// Automatically have a brief pause when these characters are encountered. - /// - [Export] public string PauseAtCharacters = ".?!"; - - /// - /// Don't auto pause if the character after the pause is one of these. - /// - [Export] public string SkipPauseAtCharacterIfFollowedBy = ")\""; - - /// - /// Don't auto pause after these abbreviations (only if "." is in PauseAtCharacters). - /// Abbreviations are limited to 5 characters in length. - /// Does not support multi-period abbreviations (ex. "p.m.") - /// - [Export] public string[] SkipPauseAtAbbreviations = { "Mr", "Mrs", "Ms", "Dr", "etc", "eg", "ex" }; - - /// - /// The amount of time to pause when exposing a character present in PauseAtCharacters. - /// - [Export] public float SecondsPerPauseStep = 0.3f; - - private readonly System.Collections.Generic.List alreadyMutatedIndices = new(); - - - private DialogueLine dialogueLine = null; - - /// - /// The current line of dialogue. - /// - public DialogueLine DialogueLine - { - get => dialogueLine; - set - { - if (value != dialogueLine) - { - dialogueLine = value; - UpdateText(); - } - } - } - - /// - /// Whether the label is currently typing itself out. - /// - public bool IsTyping - { - get => isTyping && !isAwaitingMutation; - set - { - bool didJustFinish = isTyping != value && value == false && VisibleCharacters == GetTotalCharacterCount(); - isTyping = value; - if (didJustFinish) - { - EmitSignal(SignalName.FinishedTyping); - } - } - } - private bool isTyping = false; - - private int lastWaitIndex = -1; - private int lastMutationIndex = -1; - private float waitingSeconds = 0; - private bool isAwaitingMutation = false; - private bool isSkippingMutations = false; - - - public override void _Process(double delta) - { - if (isTyping) - { - // Type out text - if (VisibleRatio < 1) - { - // See if we are waiting - if (waitingSeconds > 0) - { - waitingSeconds -= (float)delta; - } - // If we are no longer waiting then keep typing - if (waitingSeconds <= 0) - { - TypeNext((float)delta, waitingSeconds); - } - } - else - { - // Make sure any mutations at the end of the line get run - _ = MutateInlineMutations(GetTotalCharacterCount()); - IsTyping = false; - } - } - } - - - /// - /// Sets the label's text from the current dialogue line. Override if you want - /// to do something more interesting in your subclass. - /// - protected virtual void UpdateText() - { - if (IsInstanceValid(dialogueLine)) - { - Text = dialogueLine.Text; - } - else - { - Text = ""; - } - } - - - /// - /// Start typing out the text. - /// - public async void TypeOut() - { - UpdateText(); - VisibleCharacters = 0; - VisibleRatio = 0; - waitingSeconds = 0; - lastWaitIndex = -1; - lastMutationIndex = -1; - alreadyMutatedIndices.Clear(); - - IsTyping = true; - EmitSignal(SignalName.StartedTyping); - - // Allow typing listeners a chance to connect - await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); - - if (GetTotalCharacterCount() == 0) - { - IsTyping = false; - } - else if (SecondsPerStep == 0) - { - MutateRemainingMutations(); - VisibleCharacters = GetTotalCharacterCount(); - IsTyping = false; - } - } - - - /// - /// Stop typing out the text and jump right to the end. - /// - public void SkipTyping() - { - MutateRemainingMutations(); - VisibleCharacters = GetTotalCharacterCount(); - IsTyping = false; - EmitSignal(SignalName.SkippedTyping); - } - - - // Type out the next character(s) - private void TypeNext(float delta, float secondsNeeded) - { - if (isAwaitingMutation) return; - - if (VisibleCharacters == GetTotalCharacterCount()) - { - return; - } - - if (lastMutationIndex != VisibleCharacters) - { - lastMutationIndex = VisibleCharacters; - _ = MutateInlineMutations(VisibleCharacters); - if (isAwaitingMutation) return; - } - - // Pause on characters like "." - float pauseWaitingSeconds = ShouldAutoPause() ? SecondsPerPauseStep : 0f; - if (lastWaitIndex != VisibleCharacters && pauseWaitingSeconds > 0) - { - lastWaitIndex = VisibleCharacters; - waitingSeconds += pauseWaitingSeconds; - } - else - { - VisibleCharacters += 1; - if (VisibleCharacters <= GetTotalCharacterCount()) - { - EmitSignal(SignalName.Spoke, GetParsedText()[VisibleCharacters - 1].ToString(), VisibleCharacters - 1, GetSpeed(VisibleCharacters)); - } - // See if there's time to type out some more in this frame - secondsNeeded += SecondsPerStep * (1.0f / GetSpeed(VisibleCharacters)); - if (secondsNeeded > delta) - { - waitingSeconds += secondsNeeded; - } - else - { - TypeNext(delta, secondsNeeded); - } - } - } - - - // Get the speed for the current typing position - private float GetSpeed(int atIndex) - { - float speed = 1; - foreach (var speedEntry in dialogueLine.Speeds) - { - if ((int)speedEntry.Key > atIndex) - { - return speed; - } - speed = (float)speedEntry.Value; - } - return speed; - } - - - // Run any inline mutations that haven't been run yet - private void MutateRemainingMutations() - { - isSkippingMutations = true; - for (int i = VisibleCharacters; i < GetTotalCharacterCount() + 1; i++) - { - _ = MutateInlineMutations(i); - } - isSkippingMutations = false; - } - - - // Run any mutations at the current typing position - private async Task MutateInlineMutations(int index) - { - if (!IsInstanceValid(dialogueLine)) return; - - foreach (Godot.Collections.Array inlineMutation in dialogueLine.InlineMutations) - { - // Inline mutations are an array of arrays in the form of [character index, resolvable function] - if ((int)inlineMutation[0] > index) - { - return; - } - if ((int)inlineMutation[0] == index && !alreadyMutatedIndices.Contains(index)) - { - if (isSkippingMutations) - { - _ = DialogueManager.Mutate(inlineMutation[1].AsGodotDictionary(), dialogueLine.ExtraGameStates, true); - } - else - { - isAwaitingMutation = true; - await DialogueManager.Mutate(inlineMutation[1].AsGodotDictionary(), dialogueLine.ExtraGameStates, true); - isAwaitingMutation = false; - } - } - } - - alreadyMutatedIndices.Add(index); - } - - - // Determine if the current autopause character at the cursor should qualify to pause typing. - private bool ShouldAutoPause() - { - if (VisibleCharacters == 0) return false; - - string parsedText = GetParsedText(); - - // Avoid out-of-bounds when the label auto-translates and the text changes to one shorter while typing out - // Note: visible characters can be larger than parsed_text after a translation event - if (VisibleCharacters >= parsedText.Length) return false; - - // Ignore pause characters if they are next to a non-pause character - if (SkipPauseAtCharacterIfFollowedBy.Contains(parsedText[VisibleCharacters])) - { - return false; - } - - // Ignore "." if it's between two numbers - if (VisibleCharacters > 3 && parsedText[VisibleCharacters - 1] == '.') - { - string possibleNumber = parsedText.Substring(VisibleCharacters - 2, 3); - if (float.TryParse(possibleNumber, NumberStyles.Float, CultureInfo.InvariantCulture, out float number) && number.ToString("0.0", CultureInfo.InvariantCulture) == possibleNumber) - { - return false; - } - } - - // Ignore "." if it's used in an abbreviation - // Note: does NOT support multi-period abbreviations (ex. p.m.) - if (PauseAtCharacters.Contains('.') && parsedText[VisibleCharacters - 1] == '.') - { - foreach (string abbreviation in SkipPauseAtAbbreviations) - { - int start = VisibleCharacters - abbreviation.Length - 1; - if (VisibleCharacters >= abbreviation.Length && start >= 0 && parsedText.Substring(start, abbreviation.Length) == abbreviation) - { - return false; - } - } - } - - // Ignore two non-"." characters next to each other - string otherPauseCharacters = PauseAtCharacters.Replace(".", ""); - if (VisibleCharacters > 1 && otherPauseCharacters.Contains(parsedText[VisibleCharacters - 1]) && otherPauseCharacters.Contains(parsedText[VisibleCharacters])) - { - return false; - } - - return PauseAtCharacters.Contains(parsedText[VisibleCharacters - 1]); - } - } -} diff --git a/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs.uid b/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs.uid deleted file mode 100644 index 010ea8f2c5..0000000000 --- a/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b8beyexrpj6n7 diff --git a/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.tscn b/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.tscn deleted file mode 100644 index 23653a81cb..0000000000 --- a/addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.tscn +++ /dev/null @@ -1,19 +0,0 @@ -[gd_scene format=3 uid="uid://c3qmxhslp0dl7"] - -[ext_resource type="Script" uid="uid://b8beyexrpj6n7" path="res://addons/dialogue_manager/nodes/dialogue_label/DialogueLabel.cs" id="1_cital"] - -[node name="DialogueLabel" type="RichTextLabel"] -anchors_preset = 10 -anchor_right = 1.0 -grow_horizontal = 2 -mouse_filter = 1 -bbcode_enabled = true -fit_content = true -scroll_active = false -shortcut_keys_enabled = false -meta_underlined = false -hint_underlined = false -deselect_on_focus_loss_enabled = false -visible_characters_behavior = 1 -script = ExtResource("1_cital") -SkipPauseAtAbbreviations = PackedStringArray("Mr", "Mrs", "Ms", "Dr", "etc", "eg", "ex") diff --git a/addons/dialogue_manager/nodes/marker/DialogueMarker2D.cs b/addons/dialogue_manager/nodes/marker/DialogueMarker2D.cs deleted file mode 100644 index 75bcf8de36..0000000000 --- a/addons/dialogue_manager/nodes/marker/DialogueMarker2D.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Godot; -using Godot.Collections; - -namespace DialogueManagerRuntime -{ - /// - /// A special marker node that helps locate the in-world representation of the speaking character. - /// Generally, you would position a at the mouth of the character and use - /// its location as the origin of a speech balloon. - /// - [Icon("uid://cim0y62o6g36i")] - public partial class DialogueMarker2D : Marker2D - { - /// - /// The name of the character that owns this marker. - /// - [Export] public string CharacterName = ""; - - - #region Static - - - /// - /// Get all nodes. - /// - public static Array All() - { - var markers = new Array(); - foreach (Node node in ((SceneTree)Engine.GetMainLoop()).GetNodesInGroup("2d_dialogue_markers")) - { - if (node is DialogueMarker2D marker) - { - markers.Add(marker); - } - } - return markers; - } - - - /// - /// Find a marker with a given character name. - /// - public static DialogueMarker2D FindForCharacter(string targetCharacterName) - { - foreach (DialogueMarker2D marker in All()) - { - if (marker.CharacterName == targetCharacterName) - { - return marker; - } - } - return null; - } - - - #endregion - - - public override void _Ready() - { - AddToGroup("2d_dialogue_markers"); - } - - - #region Helpers - - - /// - /// Get the marker's position relative to the viewport. - /// - public Vector2 GetPositionInViewport() - { - return GetGlobalTransformWithCanvas().Origin; - } - - - #endregion - } -} diff --git a/addons/dialogue_manager/nodes/marker/DialogueMarker2D.cs.uid b/addons/dialogue_manager/nodes/marker/DialogueMarker2D.cs.uid deleted file mode 100644 index 0381adc7ce..0000000000 --- a/addons/dialogue_manager/nodes/marker/DialogueMarker2D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dnftkt8d8dj8i diff --git a/addons/dialogue_manager/nodes/marker/DialogueMarker3D.cs b/addons/dialogue_manager/nodes/marker/DialogueMarker3D.cs deleted file mode 100644 index ea24029aab..0000000000 --- a/addons/dialogue_manager/nodes/marker/DialogueMarker3D.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Godot; -using Godot.Collections; - -namespace DialogueManagerRuntime -{ - /// - /// A special marker node that helps locate the in-world representation of the speaking character. - /// Generally, you would position a at the mouth of the character and use - /// its location as the origin of a speech balloon. - /// - [Icon("uid://bo1hdyjmnjdql")] - public partial class DialogueMarker3D : Marker3D - { - /// - /// The name of the character that owns this marker. - /// - [Export] public string CharacterName = ""; - - - #region Static - - - /// - /// Get all nodes. - /// - public static Array All() - { - var markers = new Array(); - foreach (Node node in ((SceneTree)Engine.GetMainLoop()).GetNodesInGroup("3d_dialogue_markers")) - { - if (node is DialogueMarker3D marker) - { - markers.Add(marker); - } - } - return markers; - } - - - /// - /// Find a marker with a given character name. - /// - public static DialogueMarker3D FindForCharacter(string targetCharacterName) - { - foreach (DialogueMarker3D marker in All()) - { - if (marker.CharacterName == targetCharacterName) - { - return marker; - } - } - return null; - } - - - #endregion - - - public override void _Ready() - { - AddToGroup("3d_dialogue_markers"); - } - - - #region Helpers - - - /// - /// Get the marker's position relative to the viewport. - /// - public Vector2 GetPositionInViewport() - { - Camera3D camera = GetViewport().GetCamera3D(); - if (IsInstanceValid(camera)) - { - return camera.UnprojectPosition(GlobalPosition); - } - else - { - return Vector2.Zero; - } - } - - - #endregion - } -} diff --git a/addons/dialogue_manager/nodes/marker/DialogueMarker3D.cs.uid b/addons/dialogue_manager/nodes/marker/DialogueMarker3D.cs.uid deleted file mode 100644 index e6c4e4b4ee..0000000000 --- a/addons/dialogue_manager/nodes/marker/DialogueMarker3D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b3hrgs61lvn5x diff --git a/addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs b/addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs deleted file mode 100644 index 47fe09c6cb..0000000000 --- a/addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs +++ /dev/null @@ -1,303 +0,0 @@ -using Godot; -using Godot.Collections; - -namespace DialogueManagerRuntime -{ - /// - /// A for dialogue responses provided by Dialogue Manager. - /// - public partial class DialogueResponsesMenu : Container - { - /// - /// Emitted when a response is focused. - /// - [Signal] public delegate void ResponseFocusedEventHandler(Variant response); - - /// - /// Emitted when a response is selected. - /// - [Signal] public delegate void ResponseSelectedEventHandler(DialogueResponse response); - - - /// - /// Optionally specify a control to duplicate for each response. - /// - [Export] public Control ResponseTemplate; - - /// - /// The action for accepting a response (is possibly overridden by parent dialogue balloon). - /// - [Export] public StringName NextAction = ""; - - /// - /// Automatically set up focus neighbours when the responses list changes. - /// - [Export] public bool AutoConfigureFocus = true; - - /// - /// Automatically focus the first item when showing. - /// - [Export] public bool AutoFocusFirstItem = true; - - /// - /// Hide any responses where IsAllowed is false. - /// - [Export] public bool HideFailedResponses = false; - - private Godot.Collections.Array responses = new(); - - /// - /// The list of dialogue responses. - /// - public Godot.Collections.Array Responses - { - get => responses; - set - { - responses = value; - ApplyResponses(); - } - } - - // The previously focused item in this menu. - private Control previouslyFocusedItem = null; - - - public override void _Ready() - { - VisibilityChanged += () => - { - if (AutoFocusFirstItem && Visible && GetMenuItems().Count > 0) - { - Control firstItem = GetMenuItems()[0]; - if (firstItem.IsInsideTree()) - { - firstItem.GrabFocus(); - } - } - }; - - if (IsInstanceValid(ResponseTemplate)) - { - ResponseTemplate.Hide(); - } - - GetViewport().GuiFocusChanged += OnFocusChanged; - } - - - public override void _ExitTree() - { - GetViewport().GuiFocusChanged -= OnFocusChanged; - } - - - /// - /// Get the selectable items in the menu. - /// - public Array GetMenuItems() - { - var items = new Array(); - foreach (Node child in GetChildren()) - { - if (child is not Control control) continue; - if (!control.Visible) continue; - if (control.Name.ToString().Contains("Disallowed")) continue; - items.Add(control); - } - - return items; - } - - - /// - /// Prepare the menu for keyboard and mouse navigation. - /// - public void ConfigureFocus() - { - Array items = GetMenuItems(); - for (int i = 0; i < items.Count; i++) - { - Control item = items[i]; - - item.FocusMode = Control.FocusModeEnum.All; - - item.FocusNeighborLeft = item.GetPath(); - item.FocusNeighborRight = item.GetPath(); - - if (i == 0) - { - item.FocusNeighborTop = item.GetPath(); - item.FocusNeighborLeft = item.GetPath(); - item.FocusPrevious = item.GetPath(); - } - else - { - item.FocusNeighborTop = items[i - 1].GetPath(); - item.FocusNeighborLeft = items[i - 1].GetPath(); - item.FocusPrevious = items[i - 1].GetPath(); - } - - if (i == items.Count - 1) - { - item.FocusNeighborBottom = item.GetPath(); - item.FocusNeighborRight = item.GetPath(); - item.FocusNext = item.GetPath(); - } - else - { - item.FocusNeighborBottom = items[i + 1].GetPath(); - item.FocusNeighborRight = items[i + 1].GetPath(); - item.FocusNext = items[i + 1].GetPath(); - } - - DialogueResponse response = (DialogueResponse)item.GetMeta("response"); - item.MouseEntered += () => OnResponseMouseEntered(item); - item.GuiInput += (@event) => OnResponseGuiInput(@event, item, response); - } - - if (items.Count == 0) return; - - previouslyFocusedItem = items[0]; - - if (AutoFocusFirstItem) - { - items[0].GrabFocus(); - } - } - - - #region Internal - - - // Set up the visual side of things. - private void ApplyResponses() - { - // Remove any current items - foreach (Node item in GetChildren()) - { - if (item == ResponseTemplate) continue; - - RemoveChild(item); - item.QueueFree(); - } - - // Add new items - if (responses.Count > 0) - { - foreach (DialogueResponse response in responses) - { - // The response might be tagged with "show_if" - if (HideFailedResponses && !response.IsAllowed && response.GetTagValue("show_if") != "true") - { - continue; - } - - if (response.GetTagValue("hide_if") == "true") - { - continue; - } - - Control item; - if (IsInstanceValid(ResponseTemplate)) - { - item = (Control)ResponseTemplate.Duplicate((int)(DuplicateFlags.Groups | DuplicateFlags.Scripts | DuplicateFlags.Signals)); - item.Show(); - } - else - { - item = new Button(); - } - item.Name = $"Response{GetChildCount()}"; - if (!response.IsAllowed) - { - item.Name = $"{item.Name}Disallowed"; - item.Set("disabled", true); - } - - // If the item has a response property then use that - string responsePropertyName = GetResponsePropertyName(item); - if (responsePropertyName != null) - { - item.Set(responsePropertyName, response); - } - // Otherwise assume we can just set the text - else - { - item.Set("text", response.Text); - } - - item.SetMeta("response", response); - - AddChild(item); - } - - if (AutoConfigureFocus) - { - ConfigureFocus(); - } - } - } - - - // Find the name of the item's "response" property (if it has one). - private static string GetResponsePropertyName(Control item) - { - foreach (Dictionary property in item.GetPropertyList()) - { - string name = (string)property["name"]; - if (name == "response" || name == "Response") - { - return name; - } - } - return null; - } - - - #endregion - - #region Signals - - - private void OnFocusChanged(Control control) - { - if (control.Name.ToString().Contains("Disallowed")) return; - if (!GetMenuItems().Contains(control)) return; - - if (previouslyFocusedItem != control) - { - previouslyFocusedItem = control; - EmitSignal(SignalName.ResponseFocused, control); - } - } - - - private void OnResponseMouseEntered(Control item) - { - if (item.Name.ToString().Contains("Disallowed")) return; - - item.GrabFocus(); - } - - - private void OnResponseGuiInput(InputEvent @event, Control item, DialogueResponse response) - { - if (item.Name.ToString().Contains("Disallowed")) return; - - if (@event is InputEventMouseButton mouseButtonEvent && mouseButtonEvent.IsPressed() && mouseButtonEvent.ButtonIndex == MouseButton.Left) - { - GetViewport().SetInputAsHandled(); - EmitSignal(SignalName.ResponseSelected, response); - } - else if (@event.IsActionPressed(NextAction.IsEmpty ? "ui_accept" : NextAction) && GetMenuItems().Contains(item)) - { - GetViewport().SetInputAsHandled(); - EmitSignal(SignalName.ResponseSelected, response); - } - } - - - #endregion - } -} diff --git a/addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs.uid b/addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs.uid deleted file mode 100644 index 0faa5e6286..0000000000 --- a/addons/dialogue_manager/nodes/responses_menu/DialogueResponsesMenu.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bf0gf4upyxj5l diff --git a/addons/input_helper/InputHelper.cs b/addons/input_helper/InputHelper.cs deleted file mode 100644 index a578125a23..0000000000 --- a/addons/input_helper/InputHelper.cs +++ /dev/null @@ -1,287 +0,0 @@ -using Godot; -using Godot.Collections; - -namespace NathanHoad -{ - public static class InputHelper - { - public delegate void DeviceChangedEventHandler(string device, int deviceIndex); - public delegate void KeyboardInputChangedEventHandler(string action, InputEvent input); - public delegate void JoypadInputChangedEventHandler(string action, InputEvent input); - public delegate void JoypadChangedEventHandler(int deviceIndex, bool isConnected); - - public static DeviceChangedEventHandler? DeviceChanged; - public static KeyboardInputChangedEventHandler? KeyboardInputChanged; - public static JoypadInputChangedEventHandler? JoypadInputChanged; - public static JoypadChangedEventHandler? JoypadChanged; - - - public const string DEVICE_KEYBOARD = "keyboard"; - public const string DEVICE_XBOX_CONTROLLER = "xbox"; - public const string DEVICE_SWITCH_CONTROLLER = "switch"; - public const string DEVICE_PLAYSTATION_CONTROLLER = "playstation"; - public const string DEVICE_STEAMDECK_CONTROLLER = "steamdeck"; - public const string DEVICE_GENERIC = "generic"; - - public const string SUB_DEVICE_XBOX_ONE_CONTROLLER = "xbox_one"; - public const string SUB_DEVICE_XBOX_SERIES_CONTROLLER = "xbox_series"; - public const string SUB_DEVICE_PLAYSTATION3_CONTROLLER = "playstation3"; - public const string SUB_DEVICE_PLAYSTATION4_CONTROLLER = "playstation4"; - public const string SUB_DEVICE_PLAYSTATION5_CONTROLLER = "playstation5"; - public const string SUB_DEVICE_SWITCH_JOYCON_LEFT_CONTROLLER = "switch_left_joycon"; - public const string SUB_DEVICE_SWITCH_JOYCON_RIGHT_CONTROLLER = "switch_right_joycon"; - - - private static Node instance; - public static Node Instance - { - get - { - if (instance == null) - { - instance = (Node)Engine.GetSingleton("InputHelper"); - instance.Connect("device_changed", Callable.From((string device, int deviceIndex) => DeviceChanged?.Invoke(device, deviceIndex))); - instance.Connect("keyboard_input_changed", Callable.From((string action, InputEvent input) => KeyboardInputChanged?.Invoke(action, input))); - instance.Connect("joypad_input_changed", Callable.From((string action, InputEvent input) => JoypadInputChanged?.Invoke(action, input))); - instance.Connect("joypad_changed", Callable.From((int deviceIndex, bool isConnected) => JoypadChanged?.Invoke(deviceIndex, isConnected))); - } - return instance; - } - } - - - public static string Device - { - get => (string)Instance.Get("device"); - } - - - public static int DeviceIndex - { - get => (int)Instance.Get("device_index"); - } - - - public static string LastKnownJoypadDevice - { - get => (string)Instance.Get("last_known_joypad_device"); - } - - - public static string LastKnownJoypadIndex - { - get => (string)Instance.Get("last_known_joypad_index"); - } - - - public static float Deadzone - { - get => (float)Instance.Get("deadzone"); - set => Instance.Set("deadzone", value); - } - - - public static int MouseMotionThreshold - { - get => (int)Instance.Get("mouse_motion_threshold"); - set => Instance.Set("mouse_motion_threshold", value); - } - - - public static string GetSimplifiedDeviceName(string rawName) - { - return (string)Instance.Call("get_simplified_device_name", rawName); - } - - - public static string GetDeviceFromEvent(InputEvent @event) - { - return (string)Instance.Call("get_device_from_event", @event); - } - - - public static int GetDeviceIndexFromEvent(InputEvent @event) - { - return (int)Instance.Call("get_device_index_from_event", @event); - } - - - public static bool HasJoypad() - { - return (bool)Instance.Call("has_joypad"); - } - - - public static string GuessDeviceName() - { - return (string)Instance.Call("guess_device_name"); - } - - - public static void ResetAllActions() - { - Instance.Call("reset_all_actions"); - } - - - public static void SetKeyboardOrJoypadInputForAction(string action, InputEvent input, bool swapIfTaken = true) - { - Instance.Call("set_keyboard_or_joypad_input_for_action", action, input, swapIfTaken); - } - - - public static InputEvent GetKeyboardOrJoypadInputForAction(string action, InputEvent input, bool swapIfTaken = true) - { - return (InputEvent)Instance.Call("get_keyboard_or_joypad_input_for_action", action, input, swapIfTaken); - } - - - public static Array GetKeyboardOrJoypadInputsForAction(string action) - { - return (Array)Instance.Call("get_keyboard_or_joypad_inputs_for_action", action); - } - - - public static string GetLabelForInput(InputEvent input) - { - return (string)Instance.Call("get_label_for_input", input); - } - - - public static string SerializeInputsForAction(string action) - { - return (string)Instance.Call("serialize_inputs_for_action", action); - } - - - public static string SerializeInputsForActions(Array actions = null) - { - if (actions == null) - { - actions = new Array(); - } - return (string)Instance.Call("serialize_inputs_for_actions", actions); - } - - - public static void DeserializeInputsForAction(string action, string serializedInputs) - { - Instance.Call("desserialize_inputs_for_action", action, serializedInputs); - } - - public static void DeserializeInputsForActions(string serializedInputs) - { - Instance.Call("deserialize_inputs_for_actions", serializedInputs); - } - - - #region Keyboard/Mouse - - public static Array GetKeyboardInputsForAction(string action) - { - return (Array)Instance.Call("get_keyboard_inputs_for_action", action); - } - - - public static InputEvent GetKeyboardInputForAction(string action) - { - return (InputEvent)Instance.Call("get_keyboard_input_for_action", action); - } - - - public static void SetKeyboardInputForAction(string action, InputEvent input, bool swapIfTaken = true) - { - Instance.Call("set_keyboard_input_for_action", action, input, swapIfTaken); - } - - - public static void ReplaceKeyboardInputForAction(string action, InputEvent currentInput, InputEvent input, bool swapIfTaken = true) - { - Instance.Call("replace_keyboard_input_for_action", action, currentInput, input, swapIfTaken); - } - - - public static void ReplaceKeyboardInputAtIndex(string action, int index, InputEvent input, bool swapIfTaken = true) - { - Instance.Call("replace_keyboard_input_at_index", action, index, input, swapIfTaken); - } - - #endregion - - - #region Joypad - - public static Array GetJoypadInputsForAction(string action) - { - return (Array)Instance.Call("get_joypad_inputs_for_action", action); - } - - - public static InputEvent GetJoypadInputForAction(string action) - { - return (InputEvent)Instance.Call("get_joypad_input_for_action", action); - } - - - public static void SetJoypadInputForAction(string action, InputEvent input, bool swapIfTaken = true) - { - Instance.Call("set_joypad_input_for_action", action, input, swapIfTaken); - } - - - public static void ReplaceJoypadInputForAction(string action, InputEvent currentInput, InputEvent input, bool swapIfTaken = true) - { - Instance.Call("replace_joypad_input_for_action", action, currentInput, input, swapIfTaken); - } - - - public static void ReplaceJoypadInputAtIndex(string action, int index, InputEvent input, bool swapIfTaken = true) - { - Instance.Call("replace_joypad_input_at_index", action, index, input, swapIfTaken); - } - - - public static void RumbleSmall(int targetDevice = 0) - { - Instance.Call("rumble_small", targetDevice); - } - - - public static void RumbleMedium(int targetDevice = 0) - { - Instance.Call("rumble_medium", targetDevice); - } - - - public static void RumbleLarge(int targetDevice = 0) - { - Instance.Call("rumble_large", targetDevice); - } - - - public static void StartRumbleSmall(int targetDevice = 0) - { - Instance.Call("start_rumble_small", targetDevice); - } - - - public static void StartRumbleMedium(int targetDevice = 0) - { - Instance.Call("start_rumble_medium", targetDevice); - } - - - public static void StartRumbleLarge(int targetDevice = 0) - { - Instance.Call("start_rumble_large", targetDevice); - } - - - public static void StopRumble(int targetDevice = 0) - { - Instance.Call("stop_rumble", targetDevice); - } - - #endregion - } -} diff --git a/addons/input_helper/InputHelper.cs.uid b/addons/input_helper/InputHelper.cs.uid deleted file mode 100644 index e80a48011c..0000000000 --- a/addons/input_helper/InputHelper.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cfs4dgwrfvb11 diff --git a/addons/phantom_camera/scripts/managers/PhantomCameraManager.cs b/addons/phantom_camera/scripts/managers/PhantomCameraManager.cs deleted file mode 100644 index f0f6b96919..0000000000 --- a/addons/phantom_camera/scripts/managers/PhantomCameraManager.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Linq; -using Godot; - -#nullable enable - -namespace PhantomCamera.Manager; - -public static class PhantomCameraManager -{ - private static GodotObject? _instance; - - public static GodotObject Instance => _instance ??= Engine.GetSingleton("PhantomCameraManager"); - - public static PhantomCamera2D[] PhantomCamera2Ds => - Instance.Call(MethodName.GetPhantomCamera2Ds).AsGodotArray() - .Select(node => new PhantomCamera2D(node)).ToArray(); - - public static PhantomCamera3D[] PhantomCamera3Ds => - Instance.Call(MethodName.GetPhantomCamera3Ds).AsGodotArray() - .Select(node => new PhantomCamera3D(node)).ToArray(); - - public static PhantomCameraHost[] PhantomCameraHosts => - Instance.Call(MethodName.GetPhantomCameraHosts).AsGodotArray() - .Select(node => new PhantomCameraHost(node)).ToArray(); - - public static PhantomCamera2D[] GetPhantomCamera2Ds() => PhantomCamera2Ds; - public static PhantomCamera3D[] GetPhantomCamera3Ds() => PhantomCamera3Ds; - public static PhantomCameraHost[] GetPhantomCameraHosts() => PhantomCameraHosts; - - public static class MethodName - { - public static readonly StringName GetPhantomCamera2Ds = new("get_phantom_camera_2ds"); - public static readonly StringName GetPhantomCamera3Ds = new("get_phantom_camera_3ds"); - public static readonly StringName GetPhantomCameraHosts = new("get_phantom_camera_hosts"); - } -} diff --git a/addons/phantom_camera/scripts/managers/PhantomCameraManager.cs.uid b/addons/phantom_camera/scripts/managers/PhantomCameraManager.cs.uid deleted file mode 100644 index cdf7f4e8c1..0000000000 --- a/addons/phantom_camera/scripts/managers/PhantomCameraManager.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://vtj8iqx4bp43 diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera.cs b/addons/phantom_camera/scripts/phantom_camera/PhantomCamera.cs deleted file mode 100644 index 7ee47a72ca..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera.cs +++ /dev/null @@ -1,234 +0,0 @@ -using Godot; -using PhantomCamera.Noise; - -#nullable enable - -namespace PhantomCamera; - -public enum InactiveUpdateMode -{ - Always, - Never -} - -public abstract class PhantomCamera -{ - protected readonly GodotObject Node; - - public delegate void BecameActiveEventHandler(); - public delegate void BecameInactiveEventHandler(); - public delegate void FollowTargetChangedEventHandler(); - public delegate void DeadZoneChangedEventHandler(); - public delegate void TweenStartedEventHandler(); - public delegate void IsTweeningEventHandler(); - public delegate void TweenCompletedEventHandler(); - - public event BecameActiveEventHandler? BecameActive; - public event BecameInactiveEventHandler? BecameInactive; - public event FollowTargetChangedEventHandler? FollowTargetChanged; - public event DeadZoneChangedEventHandler? DeadZoneChanged; - public event TweenStartedEventHandler? TweenStarted; - public event IsTweeningEventHandler? IsTweening; - public event TweenCompletedEventHandler? TweenCompleted; - - public int Priority - { - get => (int)Node.Call(MethodName.GetPriority); - set => Node.Call(MethodName.SetPriority, value); - } - - public bool IsActive => (bool)Node.Call(MethodName.IsActive); - - public bool FollowDamping - { - get => (bool)Node.Call(MethodName.GetFollowDamping); - set => Node.Call(MethodName.SetFollowDamping, value); - } - - public bool IsFollowing => (bool)Node.Call(PhantomCamera.MethodName.IsFollowing); - - public float DeadZoneWidth - { - get => (float)Node.Get(PropertyName.DeadZoneWidth); - set => Node.Set(PropertyName.DeadZoneWidth, value); - } - - public float DeadZoneHeight - { - get => (float)Node.Get(PropertyName.DeadZoneHeight); - set => Node.Set(PropertyName.DeadZoneHeight, value); - } - - public PhantomCameraTween TweenResource - { - get => new((Resource)Node.Call(MethodName.GetTweenResource)); - set => Node.Call(MethodName.SetTweenResource, (GodotObject)value.Resource); - } - - public bool TweenSkip - { - get => (bool)Node.Call(MethodName.GetTweenSkip); - set => Node.Call(MethodName.SetTweenSkip, value); - } - - public float TweenDuration - { - get => (float)Node.Call(MethodName.GetTweenDuration); - set => Node.Call(MethodName.SetTweenDuration, value); - } - - public TransitionType TweenTransition - { - get => (TransitionType)(int)Node.Call(MethodName.GetTweenTransition); - set => Node.Call(MethodName.SetTweenTransition, (int)value); - } - - public EaseType TweenEase - { - get => (EaseType)(int)Node.Call(MethodName.GetTweenEase); - set => Node.Call(MethodName.SetTweenEase, (int)value); - } - - public bool TweenOnLoad - { - get => (bool)Node.Call(MethodName.GetTweenOnLoad); - set => Node.Call(MethodName.SetTweenOnLoad, value); - } - - public InactiveUpdateMode InactiveUpdateMode - { - get => (InactiveUpdateMode)(int)Node.Call(MethodName.GetInactiveUpdateMode); - set => Node.Call(MethodName.SetInactiveUpdateMode, (int)value); - } - - public int HostLayers - { - get => (int)Node.Call(MethodName.GetHostLayers); - set => Node.Call(MethodName.SetHostLayers, value); - } - - public int NoiseEmitterLayer - { - get => (int)Node.Call(MethodName.GetNoiseEmitterLayer); - set => Node.Call(MethodName.SetNoiseEmitterLayer, value); - } - - public void TeleportPosition() - { - Node.Call(MethodName.TeleportPosition); - } - - public void SetHostLayersValue(int layer, bool enabled) - { - Node.Call(MethodName.SetHostLayersValue, layer, enabled); - } - - protected PhantomCamera(GodotObject phantomCameraNode) - { - Node = phantomCameraNode; - - var callableBecameActive = Callable.From(() => BecameActive?.Invoke()); - var callableBecameInactive = Callable.From(() => BecameInactive?.Invoke()); - var callableFollowTargetChanged = Callable.From(() => FollowTargetChanged?.Invoke()); - var callableDeadZoneChanged = Callable.From(() => DeadZoneChanged?.Invoke()); - var callableTweenStarted = Callable.From(() => TweenStarted?.Invoke()); - var callableIsTweening = Callable.From(() => IsTweening?.Invoke()); - var callableTweenCompleted = Callable.From(() => TweenCompleted?.Invoke()); - - Node.Connect(SignalName.BecameActive, callableBecameActive); - Node.Connect(SignalName.BecameInactive, callableBecameInactive); - Node.Connect(SignalName.FollowTargetChanged, callableFollowTargetChanged); - Node.Connect(SignalName.DeadZoneChanged, callableDeadZoneChanged); - Node.Connect(SignalName.TweenStarted, callableTweenStarted); - Node.Connect(SignalName.IsTweening, callableIsTweening); - Node.Connect(SignalName.TweenCompleted, callableTweenCompleted); - } - - public static class MethodName - { - public static readonly StringName GetFollowMode = new("get_follow_mode"); - public static readonly StringName IsActive = new("is_active"); - - public static readonly StringName GetPriority = new("get_priority"); - public static readonly StringName SetPriority = new("set_priority"); - - public static readonly StringName IsFollowing = new("is_following"); - - public static readonly StringName GetFollowTarget = new("get_follow_target"); - public static readonly StringName SetFollowTarget = new("set_follow_target"); - - public static readonly StringName GetFollowTargets = new("get_follow_targets"); - public static readonly StringName SetFollowTargets = new("set_follow_targets"); - - public static readonly StringName TeleportPosition = new("teleport_position"); - - public static readonly StringName AppendFollowTargets = new("append_follow_targets"); - public static readonly StringName AppendFollowTargetsArray = new("append_follow_targets_array"); - public static readonly StringName EraseFollowTargets = new("erase_follow_targets"); - - public static readonly StringName GetFollowPath = new("get_follow_path"); - public static readonly StringName SetFollowPath = new("set_follow_path"); - - public static readonly StringName GetFollowOffset = new("get_follow_offset"); - public static readonly StringName SetFollowOffset = new("set_follow_offset"); - - public static readonly StringName GetFollowDamping = new("get_follow_damping"); - public static readonly StringName SetFollowDamping = new("set_follow_damping"); - - public static readonly StringName GetFollowDampingValue = new("get_follow_damping_value"); - public static readonly StringName SetFollowDampingValue = new("set_follow_damping_value"); - - public static readonly StringName GetFollowAxisLock = new("get_follow_axis_lock"); - public static readonly StringName SetFollowAxisLock = new("set_follow_axis_lock"); - - public static readonly StringName GetTweenResource = new("get_tween_resource"); - public static readonly StringName SetTweenResource = new("set_tween_resource"); - - public static readonly StringName GetTweenSkip = new("get_tween_skip"); - public static readonly StringName SetTweenSkip = new("set_tween_skip"); - - public static readonly StringName GetTweenDuration = new("get_tween_duration"); - public static readonly StringName SetTweenDuration = new("set_tween_duration"); - - public static readonly StringName GetTweenTransition = new("get_tween_transition"); - public static readonly StringName SetTweenTransition = new("set_tween_transition"); - - public static readonly StringName GetTweenEase = new("get_tween_ease"); - public static readonly StringName SetTweenEase = new("set_tween_ease"); - - public static readonly StringName GetTweenOnLoad = new("get_tween_on_load"); - public static readonly StringName SetTweenOnLoad = new("set_tween_on_load"); - - public static readonly StringName GetInactiveUpdateMode = new("get_inactive_update_mode"); - public static readonly StringName SetInactiveUpdateMode = new("set_inactive_update_mode"); - - public static readonly StringName GetHostLayers = new("get_host_layers"); - public static readonly StringName SetHostLayers = new("set_host_layers"); - public static readonly StringName SetHostLayersValue = new("set_host_layers_value"); - - public static readonly StringName GetNoiseEmitterLayer = new("get_noise_emitter_layer"); - public static readonly StringName SetNoiseEmitterLayer = new("set_noise_emitter_layer"); - - public static readonly StringName EmitNoise = new("emit_noise"); - } - - public static class PropertyName - { - public static readonly StringName DeadZoneWidth = new("dead_zone_width"); - public static readonly StringName DeadZoneHeight = new("dead_zone_height"); - } - - public static class SignalName - { - public static readonly StringName BecameActive = new("became_active"); - public static readonly StringName BecameInactive = new("became_inactive"); - public static readonly StringName FollowTargetChanged = new("follow_target_changed"); - public static readonly StringName DeadZoneChanged = new("dead_zone_changed"); - public static readonly StringName DeadZoneReached = new("dead_zone_reached"); - public static readonly StringName TweenStarted = new("tween_started"); - public static readonly StringName IsTweening = new("is_tweening"); - public static readonly StringName TweenCompleted = new("tween_completed"); - public static readonly StringName TweenInterrupted = new("tween_interrupted"); - public static readonly StringName NoiseEmitted = new("noise_emitted"); - } -} diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera.cs.uid b/addons/phantom_camera/scripts/phantom_camera/PhantomCamera.cs.uid deleted file mode 100644 index 856fbdb39a..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://d3wh0457i0i3 diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera2D.cs b/addons/phantom_camera/scripts/phantom_camera/PhantomCamera2D.cs deleted file mode 100644 index 4f1fe70813..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera2D.cs +++ /dev/null @@ -1,380 +0,0 @@ -using System.Linq; -using Godot; -using Godot.Collections; -using PhantomCamera.Noise; - -#nullable enable - -namespace PhantomCamera; - -public enum FollowMode2D -{ - None, - Glued, - Simple, - Group, - Path, - Framed -} - -public enum FollowLockAxis2D -{ - None, - X, - Y, - Xy -} - -public static class PhantomCamera2DExtensions -{ - public static PhantomCamera2D AsPhantomCamera2D(this Node2D node2D) - { - return new PhantomCamera2D(node2D); - } - - public static PhantomCameraNoiseEmitter2D AsPhantomCameraNoiseEmitter2D(this Node2D node2D) - { - return new PhantomCameraNoiseEmitter2D(node2D); - } - - public static PhantomCameraNoise2D AsPhantomCameraNoise2D(this Resource resource) - { - return new PhantomCameraNoise2D(resource); - } -} - -public class PhantomCamera2D : PhantomCamera -{ - public Node2D Node2D => (Node2D)Node; - - public delegate void TweenInterruptedEventHandler(Node2D pCam); - public delegate void DeadZoneReachedEventHandler(Vector2 side); - public delegate void NoiseEmittedEventHandler(Transform2D output); - - public event TweenInterruptedEventHandler? TweenInterrupted; - public event DeadZoneReachedEventHandler? DeadZoneReached; - public event NoiseEmittedEventHandler? NoiseEmitted; - - public Node2D FollowTarget - { - get => (Node2D)Node2D.Call(PhantomCamera.MethodName.GetFollowTarget); - set => Node2D.Call(PhantomCamera.MethodName.SetFollowTarget, value); - } - - public Node2D[] FollowTargets - { - get => Node2D.Call(PhantomCamera.MethodName.GetFollowTargets).AsGodotArray().ToArray(); - set => Node2D.Call(PhantomCamera.MethodName.SetFollowTargets, new Array(value)); - } - - public void AppendFollowTargets(Node2D target) => Node2D.Call(PhantomCamera.MethodName.AppendFollowTargets, target); - public void AppendFollowTargetsArray(Node2D[] targets) => Node2D.Call(PhantomCamera.MethodName.AppendFollowTargetsArray, targets); - public void EraseFollowTargets(Node2D target) => Node2D.Call(PhantomCamera.MethodName.EraseFollowTargets, target); - - public FollowMode2D FollowMode => (FollowMode2D)(int)Node.Call(PhantomCamera.MethodName.GetFollowMode); - - public Path2D FollowPath - { - get => (Path2D)Node2D.Call(PhantomCamera.MethodName.GetFollowPath); - set => Node2D.Call(PhantomCamera.MethodName.SetFollowPath, value); - } - - public Vector2 FollowOffset - { - get => (Vector2)Node2D.Call(PhantomCamera.MethodName.GetFollowOffset); - set => Node2D.Call(PhantomCamera.MethodName.SetFollowOffset, value); - } - - public Vector2 FollowDampingValue - { - get => (Vector2)Node2D.Call(PhantomCamera.MethodName.GetFollowDampingValue); - set => Node2D.Call(PhantomCamera.MethodName.SetFollowDampingValue, value); - } - - public FollowLockAxis2D FollowAxisLock - { - get => (FollowLockAxis2D)(int)Node2D.Call(PhantomCamera.MethodName.GetFollowAxisLock); - set => Node2D.Call(PhantomCamera.MethodName.SetFollowAxisLock, (int)value); - } - - public Vector2 Zoom - { - get => (Vector2)Node2D.Call(MethodName.GetZoom); - set => Node2D.Call(MethodName.SetZoom, value); - } - - public bool SnapToPixel - { - get => (bool)Node2D.Call(MethodName.GetSnapToPixel); - set => Node2D.Call(MethodName.SetSnapToPixel, value); - } - - public bool RotateWithTarget - { - get => (bool)Node2D.Call(MethodName.GetRotateWithTarget); - set => Node2D.Call(MethodName.SetRotateWithTarget, value); - } - - public float RotationOffset - { - get => (float)Node2D.Call(MethodName.GetRotationOffset); - set => Node2D.Call(MethodName.SetRotationOffset, value); - } - - public bool RotationDamping - { - get => (bool)Node2D.Call(MethodName.GetRotationDamping); - set => Node2D.Call(MethodName.SetRotationDamping, value); - } - - public float RotationDampingValue - { - get => (float)Node2D.Call(MethodName.GetRotationDampingValue); - set => Node2D.Call(MethodName.SetRotationDampingValue, value); - } - - public int LimitLeft - { - get => (int)Node2D.Call(MethodName.GetLimitLeft); - set => Node2D.Call(MethodName.SetLimitLeft, value); - } - - public int LimitTop - { - get => (int)Node2D.Call(MethodName.GetLimitTop); - set => Node2D.Call(MethodName.SetLimitTop, value); - } - - public int LimitRight - { - get => (int)Node2D.Call(MethodName.GetLimitRight); - set => Node2D.Call(MethodName.SetLimitRight, value); - } - - public int LimitBottom - { - get => (int)Node2D.Call(MethodName.GetLimitBottom); - set => Node2D.Call(MethodName.SetLimitBottom, value); - } - - public Vector4I LimitMargin - { - get => (Vector4I)Node2D.Call(MethodName.GetLimitMargin); - set => Node2D.Call(MethodName.SetLimitMargin, value); - } - - public bool AutoZoom - { - get => (bool)Node2D.Call(MethodName.GetAutoZoom); - set => Node2D.Call(MethodName.SetAutoZoom, value); - } - - public float AutoZoomMin - { - get => (float)Node2D.Call(MethodName.GetAutoZoomMin); - set => Node2D.Call(MethodName.SetAutoZoomMin, value); - } - - public float AutoZoomMax - { - get => (float)Node2D.Call(MethodName.GetAutoZoomMax); - set => Node2D.Call(MethodName.SetAutoZoomMax, value); - } - - public Vector4 AutoZoomMargin - { - get => (Vector4)Node2D.Call(MethodName.GetAutoZoomMargin); - set => Node2D.Call(MethodName.SetAutoZoomMargin, value); - } - - public bool Lookahead - { - get => (bool)Node2D.Call(MethodName.GetLookahead); - set => Node2D.Call(MethodName.SetLookahead, value); - } - - public Vector2 LookaheadTime - { - get => (Vector2)Node2D.Call(MethodName.GetLookaheadTime); - set => Node2D.Call(MethodName.SetLookaheadTime, value); - } - - public float LookaheadAcceleration - { - get => (float)Node2D.Call(MethodName.GetLookaheadAcceleration); - set => Node2D.Call(MethodName.SetLookaheadAcceleration, value); - } - - public float LookaheadDeceleration - { - get => (float)Node2D.Call(MethodName.GetLookaheadDeceleration); - set => Node2D.Call(MethodName.SetLookaheadDeceleration, value); - } - - public bool LookaheadMax - { - get => (bool)Node2D.Call(MethodName.GetLookaheadMax); - set => Node2D.Call(MethodName.SetLookaheadMax, value); - } - - public Vector2 LookaheadMaxValue - { - get => (Vector2)Node2D.Call(MethodName.GetLookaheadMaxValue); - set => Node2D.Call(MethodName.SetLookaheadMaxValue, value); - } - - public bool DrawLimits - { - get => (bool)Node2D.Get(PropertyName.DrawLimits); - set => Node2D.Set(PropertyName.DrawLimits, value); - } - - public PhantomCameraNoise2D Noise - { - get => new((Resource)Node2D.Call(MethodName.GetNoise)); - set => Node2D.Call(MethodName.SetNoise, (GodotObject)value.Resource); - } - - public void EmitNoise(Transform2D transform) => Node2D.Call(PhantomCamera.MethodName.EmitNoise, transform); - - public NodePath LimitTarget - { - get => (NodePath)Node2D.Call(MethodName.GetLimitTarget); - set => Node2D.Call(MethodName.SetLimitTarget, value); - } - - public PhantomCamera2D(GodotObject phantomCameraNode) : base(phantomCameraNode) - { - var callableTweenInterrupted = Callable.From(pCam => TweenInterrupted?.Invoke(pCam)); - var callableDeadZoneReached = Callable.From((Vector2 side) => DeadZoneReached?.Invoke(side)); - var callableNoiseEmitted = Callable.From((Transform2D output) => NoiseEmitted?.Invoke(output)); - - Node2D.Connect(SignalName.TweenInterrupted, callableTweenInterrupted); - Node2D.Connect(SignalName.DeadZoneReached, callableDeadZoneReached); - Node2D.Connect(SignalName.NoiseEmitted, callableNoiseEmitted); - } - - public void SetLimitTarget(TileMapLayer tileMapLayer) - { - Node2D.Call(MethodName.SetLimitTarget, tileMapLayer.GetPath()); - } - - public void SetLimitTarget(CollisionShape2D shape2D) - { - Node2D.Call(MethodName.SetLimitTarget, shape2D.GetPath()); - } - - public LimitTargetQueryResult? GetLimitTarget() - { - var result = (NodePath)Node2D.Call(MethodName.GetLimitTarget); - return result.IsEmpty ? null : new LimitTargetQueryResult(Node2D.GetNode(result)); - } - - public void SetLimit(Side side, int value) - { - Node2D.Call(MethodName.SetLimit, (int)side, value); - } - - public int GetLimit(Side side) - { - return (int)Node2D.Call(MethodName.GetLimit, (int)side); - } - - public new static class MethodName - { - public static readonly StringName GetZoom = new("get_zoom"); - public static readonly StringName SetZoom = new("set_zoom"); - - public static readonly StringName GetSnapToPixel = new("get_snap_to_pixel"); - public static readonly StringName SetSnapToPixel = new("set_snap_to_pixel"); - - public static readonly StringName GetRotateWithTarget = new("get_rotate_with_target"); - public static readonly StringName SetRotateWithTarget = new("set_rotate_with_target"); - - public static readonly StringName GetRotationOffset = new("get_rotation_offset"); - public static readonly StringName SetRotationOffset = new("set_rotation_offset"); - - public static readonly StringName GetRotationDamping = new("get_rotation_damping"); - public static readonly StringName SetRotationDamping = new("set_rotation_damping"); - - public static readonly StringName GetRotationDampingValue = new("get_rotation_damping_value"); - public static readonly StringName SetRotationDampingValue = new("set_rotation_damping_value"); - - public static readonly StringName GetLookahead = new("get_lookahead"); - public static readonly StringName SetLookahead = new("set_lookahead"); - - public static readonly StringName GetLookaheadTime = new("get_lookahead_time"); - public static readonly StringName SetLookaheadTime = new("set_lookahead_time"); - - public static readonly StringName GetLookaheadAcceleration = new("get_lookahead_acceleration"); - public static readonly StringName SetLookaheadAcceleration = new("set_lookahead_acceleration"); - - public static readonly StringName GetLookaheadDeceleration = new("get_lookahead_deceleration"); - public static readonly StringName SetLookaheadDeceleration = new("set_lookahead_deceleration"); - - public static readonly StringName GetLookaheadMax = new("get_lookahead_max"); - public static readonly StringName SetLookaheadMax = new("set_lookahead_max"); - - public static readonly StringName GetLookaheadMaxValue = new("get_lookahead_max_value"); - public static readonly StringName SetLookaheadMaxValue = new("set_lookahead_max_value"); - - public static readonly StringName GetLimit = new("get_limit"); - public static readonly StringName SetLimit = new("set_limit"); - - public static readonly StringName GetLimitLeft = new("get_limit_left"); - public static readonly StringName SetLimitLeft = new("set_limit_left"); - - public static readonly StringName GetLimitTop = new("get_limit_top"); - public static readonly StringName SetLimitTop = new("set_limit_top"); - - public static readonly StringName GetLimitRight = new("get_limit_right"); - public static readonly StringName SetLimitRight = new("set_limit_right"); - - public static readonly StringName GetLimitBottom = new("get_limit_bottom"); - public static readonly StringName SetLimitBottom = new("set_limit_bottom"); - - public static readonly StringName GetLimitTarget = new("get_limit_target"); - public static readonly StringName SetLimitTarget = new("set_limit_target"); - - public static readonly StringName GetLimitMargin = new("get_limit_margin"); - public static readonly StringName SetLimitMargin = new("set_limit_margin"); - - public static readonly StringName GetAutoZoom = new("get_auto_zoom"); - public static readonly StringName SetAutoZoom = new("set_auto_zoom"); - - public static readonly StringName GetAutoZoomMin = new("get_auto_zoom_min"); - public static readonly StringName SetAutoZoomMin = new("set_auto_zoom_min"); - - public static readonly StringName GetAutoZoomMax = new("get_auto_zoom_max"); - public static readonly StringName SetAutoZoomMax = new("set_auto_zoom_max"); - - public static readonly StringName GetAutoZoomMargin = new("get_auto_zoom_margin"); - public static readonly StringName SetAutoZoomMargin = new("set_auto_zoom_margin"); - - public static readonly StringName GetNoise = new("get_noise"); - public static readonly StringName SetNoise = new("set_noise"); - } - - public new static class PropertyName - { - public static readonly StringName DrawLimits = new("draw_limits"); - } -} - -public class LimitTargetQueryResult(GodotObject godotObject) -{ - public bool IsTileMapLayer => godotObject.IsClass("TileMapLayer"); - - public bool IsCollisionShape2D => godotObject.IsClass("CollisionShape2D"); - - - public TileMapLayer? AsTileMapLayer() - { - return IsTileMapLayer ? (TileMapLayer)godotObject : null; - } - - public CollisionShape2D? AsCollisionShape2D() - { - return IsCollisionShape2D ? (CollisionShape2D)godotObject : null; - } -} diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera2D.cs.uid b/addons/phantom_camera/scripts/phantom_camera/PhantomCamera2D.cs.uid deleted file mode 100644 index 8cc93f02f0..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera2D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c38e5qhsf3fk3 diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera3D.cs b/addons/phantom_camera/scripts/phantom_camera/PhantomCamera3D.cs deleted file mode 100644 index ca93d3d30d..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera3D.cs +++ /dev/null @@ -1,483 +0,0 @@ -using System.Linq; -using Godot; -using Environment = Godot.Environment; -using Godot.Collections; -using PhantomCamera.Noise; - -#nullable enable - -namespace PhantomCamera; - -public enum LookAtMode -{ - None, - Mimic, - Simple, - Group -} - -public enum FollowMode3D -{ - None, - Glued, - Simple, - Group, - Path, - Framed, - ThirdPerson -} - -public enum FollowLockAxis3D -{ - None, - X, - Y, - Z, - XY, - XZ, - YZ, - XYZ -} - -public static class PhantomCamera3DExtensions -{ - public static PhantomCamera3D AsPhantomCamera3D(this Node3D node3D) - { - return new PhantomCamera3D(node3D); - } - - public static PhantomCameraNoiseEmitter3D AsPhantomCameraNoiseEmitter3D(this Node3D node3D) - { - return new PhantomCameraNoiseEmitter3D(node3D); - } - - public static PhantomCameraNoise3D AsPhantomCameraNoise3D(this Resource resource) - { - return new PhantomCameraNoise3D(resource); - } - - public static Camera3DResource AsCamera3DResource(this Resource resource) - { - return new Camera3DResource(resource); - } - - public static Vector3 GetThirdPersonRotation(this PhantomCamera3D pCam3D) => - (Vector3)pCam3D.Node3D.Call(PhantomCamera3D.MethodName.GetThirdPersonRotation); - - public static void SetThirdPersonRotation(this PhantomCamera3D pCam3D, Vector3 rotation) => - pCam3D.Node3D.Call(PhantomCamera3D.MethodName.SetThirdPersonRotation, rotation); - - public static Vector3 GetThirdPersonRotationDegrees(this PhantomCamera3D pCam3D) => - (Vector3)pCam3D.Node3D.Call(PhantomCamera3D.MethodName.GetThirdPersonRotationDegrees); - - public static void SetThirdPersonRotationDegrees(this PhantomCamera3D pCam3D, Vector3 rotation) => - pCam3D.Node3D.Call(PhantomCamera3D.MethodName.SetThirdPersonRotationDegrees, rotation); - - public static Quaternion GetThirdPersonQuaternion(this PhantomCamera3D pCam3D) => - (Quaternion)pCam3D.Node3D.Call(PhantomCamera3D.MethodName.GetThirdPersonQuaternion); - - public static void SetThirdPersonQuaternion(this PhantomCamera3D pCam3D, Quaternion quaternion) => - pCam3D.Node3D.Call(PhantomCamera3D.MethodName.SetThirdPersonQuaternion, quaternion); - -} - -public class PhantomCamera3D : PhantomCamera -{ - public Node3D Node3D => (Node3D)Node; - - public delegate void LookAtTargetChangedEventHandler(); - public delegate void DeadZoneReachedEventHandler(); - public delegate void Camera3DResourceChangedEventHandler(); - public delegate void Camera3DResourcePropertyChangedEventHandler(StringName property, Variant value); - public delegate void TweenInterruptedEventHandler(Node3D pCam); - public delegate void NoiseEmittedEventHandler(Transform3D output); - - public event LookAtTargetChangedEventHandler? LookAtTargetChanged; - public event DeadZoneReachedEventHandler? DeadZoneReached; - public event Camera3DResourceChangedEventHandler? Camera3DResourceChanged; - public event Camera3DResourcePropertyChangedEventHandler? Camera3DResourcePropertyChanged; - public event TweenInterruptedEventHandler? TweenInterrupted; - public event NoiseEmittedEventHandler? NoiseEmitted; - - public Node3D FollowTarget - { - get => (Node3D)Node3D.Call(PhantomCamera.MethodName.GetFollowTarget); - set => Node3D.Call(PhantomCamera.MethodName.SetFollowTarget, value); - } - - public Node3D[] FollowTargets - { - get => Node3D.Call(PhantomCamera.MethodName.GetFollowTargets).AsGodotArray().ToArray(); - set => Node3D.Call(PhantomCamera.MethodName.SetFollowTargets, new Array(value)); - } - - public void AppendFollowTarget(Node3D target) => Node3D.Call(PhantomCamera.MethodName.AppendFollowTargets, target); - public void AppendFollowTargetArray(Node3D[] targets) => Node3D.Call(PhantomCamera.MethodName.AppendFollowTargetsArray, targets); - public void EraseFollowTarget(Node3D target) => Node3D.Call(PhantomCamera.MethodName.EraseFollowTargets, target); - - public FollowMode3D FollowMode => (FollowMode3D)(int)Node.Call(PhantomCamera.MethodName.GetFollowMode); - - public Path3D FollowPath - { - get => (Path3D)Node3D.Call(PhantomCamera.MethodName.GetFollowPath); - set => Node3D.Call(PhantomCamera.MethodName.SetFollowPath, value); - } - - public Vector3 FollowOffset - { - get => (Vector3)Node3D.Call(PhantomCamera.MethodName.GetFollowOffset); - set => Node3D.Call(PhantomCamera.MethodName.SetFollowOffset, value); - } - - public Vector3 FollowDampingValue - { - get => (Vector3)Node3D.Call(PhantomCamera.MethodName.GetFollowDampingValue); - set => Node3D.Call(PhantomCamera.MethodName.SetFollowDampingValue, value); - } - - public FollowLockAxis3D FollowAxisLock - { - get => (FollowLockAxis3D)(int)Node3D.Call(PhantomCamera.MethodName.GetFollowAxisLock); - set => Node3D.Call(PhantomCamera.MethodName.SetFollowAxisLock, (int)value); - } - - public LookAtMode LookAtMode => (LookAtMode)(int)Node3D.Call(MethodName.GetLookAtMode); - - public Camera3DResource Camera3DResource - { - get => new((Resource)Node3D.Call(MethodName.GetCamera3DResource)); - set => Node3D.Call(MethodName.SetCamera3DResource, value.Resource); - } - - public float SpringLength - { - get => (float)Node3D.Call(MethodName.GetSpringLength); - set => Node3D.Call(MethodName.SetSpringLength, value); - } - - public float VerticalRotationOffset - { - get => (float)Node3D.Call(MethodName.GetVerticalRotationOffset); - set => Node3D.Call(MethodName.SetVerticalRotationOffset, value); - } - - public float HorizontalRotationOffset - { - get => (float)Node3D.Call(MethodName.GetHorizontalRotationOffset); - set => Node3D.Call(MethodName.SetHorizontalRotationOffset, value); - } - - public float FollowDistance - { - get => (float)Node3D.Call(MethodName.GetFollowDistance); - set => Node3D.Call(MethodName.SetFollowDistance, value); - } - - public bool AutoFollowDistance - { - get => (bool)Node3D.Call(MethodName.GetAutoFollowDistance); - set => Node3D.Call(MethodName.SetAutoFollowDistance, value); - } - - public float AutoFollowDistanceMin - { - get => (float)Node3D.Call(MethodName.GetAutoFollowDistanceMin); - set => Node3D.Call(MethodName.SetAutoFollowDistanceMin, value); - } - - public float AutoFollowDistanceMax - { - get => (float)Node3D.Call(MethodName.GetAutoFollowDistanceMax); - set => Node3D.Call(MethodName.SetAutoFollowDistanceMax, value); - } - - public float AutoFollowDistanceDivisor - { - get => (float)Node3D.Call(MethodName.GetAutoFollowDistanceDivisor); - set => Node3D.Call(MethodName.SetAutoFollowDistanceDivisor, value); - } - - public Node3D LookAtTarget - { - get => (Node3D)Node3D.Call(MethodName.GetLookAtTarget); - set => Node3D.Call(MethodName.SetLookAtTarget, value); - } - - public Node3D[] LookAtTargets - { - get => Node3D.Call(MethodName.GetLookAtTargets).AsGodotArray().ToArray(); - set => Node3D.Call(MethodName.SetLookAtTargets, new Array(value)); - } - - public bool IsLooking => (bool)Node3D.Call(MethodName.IsLooking); - - public int CollisionMask - { - get => (int)Node3D.Call(MethodName.GetCollisionMask); - set => Node3D.Call(MethodName.SetCollisionMask, value); - } - - public void SetCollisionMaskValue(int maskLayer, bool enable) => - Node3D.Call(MethodName.SetCollisionMaskValue, maskLayer, enable); - - public Shape3D Shape - { - get => (Shape3D)Node3D.Call(MethodName.GetShape); - set => Node3D.Call(MethodName.SetShape, value); - } - - public float Margin - { - get => (float)Node3D.Call(MethodName.GetMargin); - set => Node3D.Call(MethodName.SetMargin, value); - } - - public Vector3 LookAtOffset - { - get => (Vector3)Node3D.Call(MethodName.GetLookAtOffset); - set => Node3D.Call(MethodName.SetLookAtOffset, value); - } - - public bool LookAtDamping - { - get => (bool)Node3D.Call(MethodName.GetLookAtDamping); - set => Node3D.Call(MethodName.SetLookAtDamping, value); - } - - public float LookAtDampingValue - { - get => (float)Node3D.Call(MethodName.GetLookAtDampingValue); - set => Node3D.Call(MethodName.SetLookAtDampingValue, value); - } - - public Vector3 Up - { - get => (Vector3)Node3D.Call(MethodName.GetUp); - set => Node3D.Call(MethodName.SetUp, value); - } - - public Node3D UpTarget - { - get => (Node3D)Node3D.Call(MethodName.GetUpTarget); - set => Node3D.Call(MethodName.SetUpTarget, value); - } - - public int KeepAspect - { - get => (int)Node3D.Call(MethodName.GetKeepAspect); - set => Node3D.Call(MethodName.SetKeepAspect, value); - } - - public int CullMask - { - get => (int)Node3D.Call(MethodName.GetCullMask); - set => Node3D.Call(MethodName.SetCullMask, value); - } - - public float HOffset - { - get => (float)Node3D.Call(MethodName.GetHOffset); - set => Node3D.Call(MethodName.SetHOffset, value); - } - - public float VOffset - { - get => (float)Node3D.Call(MethodName.GetVOffset); - set => Node3D.Call(MethodName.SetVOffset, value); - } - - public ProjectionType Projection - { - get => (ProjectionType)(int)Node3D.Call(MethodName.GetProjection); - set => Node3D.Call(MethodName.SetProjection, (int)value); - } - - public float Fov - { - get => (float)Node3D.Call(MethodName.GetFov); - set => Node3D.Call(MethodName.SetFov, value); - } - - public float Size - { - get => (float)Node3D.Call(MethodName.GetSize); - set => Node3D.Call(MethodName.SetSize, value); - } - - public Vector2 FrustumOffset - { - get => (Vector2)Node3D.Call(MethodName.GetFrustumOffset); - set => Node3D.Call(MethodName.SetFrustumOffset, value); - } - - public float Far - { - get => (float)Node3D.Call(MethodName.GetFar); - set => Node3D.Call(MethodName.SetFar, value); - } - - public float Near - { - get => (float)Node3D.Call(MethodName.GetNear); - set => Node3D.Call(MethodName.SetNear, value); - } - - public Environment Environment - { - get => (Environment)Node3D.Call(MethodName.GetEnvironment); - set => Node3D.Call(MethodName.SetEnvironment, value); - } - - public CameraAttributes Attributes - { - get => (CameraAttributes)Node3D.Call(MethodName.GetAttributes); - set => Node3D.Call(MethodName.SetAttributes, value); - } - - public PhantomCameraNoise3D Noise - { - get => new((Resource)Node3D.Call(MethodName.GetNoise)); - set => Node3D.Call(MethodName.SetNoise, (GodotObject)value.Resource); - } - - public void EmitNoise(Transform3D transform) => Node3D.Call(PhantomCamera.MethodName.EmitNoise, transform); - - public PhantomCamera3D(GodotObject phantomCamera3DNode) : base(phantomCamera3DNode) - { - var callableLookAtTargetChanged = Callable.From(() => LookAtTargetChanged?.Invoke()); - var callableDeadZoneReached = Callable.From(() => DeadZoneReached?.Invoke()); - var callableCamera3DResourceChanged = Callable.From(() => Camera3DResourceChanged?.Invoke()); - var callableCamera3DResourcePropertyChanged = Callable.From((StringName property, Variant value) => - Camera3DResourcePropertyChanged?.Invoke(property, value)); - var callableTweenInterrupted = Callable.From(pCam => TweenInterrupted?.Invoke(pCam)); - var callableNoiseEmitted = Callable.From((Transform3D output) => NoiseEmitted?.Invoke(output)); - - Node3D.Connect(SignalName.LookAtTargetChanged, callableLookAtTargetChanged); - Node3D.Connect(PhantomCamera.SignalName.DeadZoneReached, callableDeadZoneReached); - Node3D.Connect(SignalName.Camera3DResourceChanged, callableCamera3DResourceChanged); - Node3D.Connect(SignalName.Camera3DResourcePropertyChanged, callableCamera3DResourcePropertyChanged); - Node3D.Connect(PhantomCamera.SignalName.TweenInterrupted, callableTweenInterrupted); - Node3D.Connect(PhantomCamera.SignalName.NoiseEmitted, callableNoiseEmitted); - } - - public new static class MethodName - { - public static readonly StringName GetLookAtMode = new("get_look_at_mode"); - - public static readonly StringName GetCamera3DResource = new("get_camera_3d_resource"); - public static readonly StringName SetCamera3DResource = new("set_camera_3d_resource"); - - public static readonly StringName GetThirdPersonRotation = new("get_third_person_rotation"); - public static readonly StringName SetThirdPersonRotation = new("set_third_person_rotation"); - - public static readonly StringName GetThirdPersonRotationDegrees = new("get_third_person_rotation_degrees"); - public static readonly StringName SetThirdPersonRotationDegrees = new("set_third_person_rotation_degrees"); - - public static readonly StringName GetThirdPersonQuaternion = new("get_third_person_quaternion"); - public static readonly StringName SetThirdPersonQuaternion = new("set_third_person_quaternion"); - - public static readonly StringName GetVerticalRotationOffset = new("get_vertical_rotation_offset"); - public static readonly StringName SetVerticalRotationOffset = new("set_vertical_rotation_offset"); - - public static readonly StringName GetHorizontalRotationOffset = new("get_horizontal_rotation_offset"); - public static readonly StringName SetHorizontalRotationOffset = new("set_horizontal_rotation_offset"); - - public static readonly StringName GetSpringLength = new("get_spring_length"); - public static readonly StringName SetSpringLength = new("set_spring_length"); - - public static readonly StringName GetFollowDistance = new("get_follow_distance"); - public static readonly StringName SetFollowDistance = new("set_follow_distance"); - - public static readonly StringName GetAutoFollowDistance = new("get_auto_follow_distance"); - public static readonly StringName SetAutoFollowDistance = new("set_auto_follow_distance"); - - public static readonly StringName GetAutoFollowDistanceMin = new("get_auto_follow_distance_min"); - public static readonly StringName SetAutoFollowDistanceMin = new("set_auto_follow_distance_min"); - - public static readonly StringName GetAutoFollowDistanceMax = new("get_auto_follow_distance_max"); - public static readonly StringName SetAutoFollowDistanceMax = new("set_auto_follow_distance_max"); - - public static readonly StringName GetAutoFollowDistanceDivisor = new("get_auto_follow_distance_divisor"); - public static readonly StringName SetAutoFollowDistanceDivisor = new("set_auto_follow_distance_divisor"); - - public static readonly StringName GetLookAtTarget = new("get_look_at_target"); - public static readonly StringName SetLookAtTarget = new("set_look_at_target"); - - public static readonly StringName GetLookAtTargets = new("get_look_at_targets"); - public static readonly StringName SetLookAtTargets = new("set_look_at_targets"); - - public static readonly StringName IsLooking = new("is_looking"); - - public static readonly StringName GetUp = new("get_up"); - public static readonly StringName SetUp = new("set_up"); - - public static readonly StringName GetUpTarget = new("get_up_target"); - public static readonly StringName SetUpTarget = new("set_up_target"); - - public static readonly StringName GetCollisionMask = new("get_collision_mask"); - public static readonly StringName SetCollisionMask = new("set_collision_mask"); - - public static readonly StringName SetCollisionMaskValue = new("set_collision_mask_value"); - - public static readonly StringName GetShape = new("get_shape"); - public static readonly StringName SetShape = new("set_shape"); - - public static readonly StringName GetMargin = new("get_margin"); - public static readonly StringName SetMargin = new("set_margin"); - - public static readonly StringName GetLookAtOffset = new("get_look_at_offset"); - public static readonly StringName SetLookAtOffset = new("set_look_at_offset"); - - public static readonly StringName GetLookAtDamping = new("get_look_at_damping"); - public static readonly StringName SetLookAtDamping = new("set_look_at_damping"); - - public static readonly StringName GetLookAtDampingValue = new("get_look_at_damping_value"); - public static readonly StringName SetLookAtDampingValue = new("set_look_at_damping_value"); - - public static readonly StringName GetKeepAspect = new("get_keep_aspect"); - public static readonly StringName SetKeepAspect = new("set_keep_aspect"); - - public static readonly StringName GetCullMask = new("get_cull_mask"); - public static readonly StringName SetCullMask = new("set_cull_mask"); - - public static readonly StringName GetHOffset = new("get_h_offset"); - public static readonly StringName SetHOffset = new("set_h_offset"); - - public static readonly StringName GetVOffset = new("get_v_offset"); - public static readonly StringName SetVOffset = new("set_v_offset"); - - public static readonly StringName GetProjection = new("get_projection"); - public static readonly StringName SetProjection = new("set_projection"); - - public static readonly StringName GetFov = new("get_fov"); - public static readonly StringName SetFov = new("set_fov"); - - public static readonly StringName GetSize = new("get_size"); - public static readonly StringName SetSize = new("set_size"); - - public static readonly StringName GetFrustumOffset = new("get_frustum_offset"); - public static readonly StringName SetFrustumOffset = new("set_frustum_offset"); - - public static readonly StringName GetFar = new("get_far"); - public static readonly StringName SetFar = new("set_far"); - - public static readonly StringName GetNear = new("get_near"); - public static readonly StringName SetNear = new("set_near"); - - public static readonly StringName GetEnvironment = new("get_environment"); - public static readonly StringName SetEnvironment = new("set_environment"); - - public static readonly StringName GetAttributes = new("get_attributes"); - public static readonly StringName SetAttributes = new("set_attributes"); - - public static readonly StringName GetNoise = new("get_noise"); - public static readonly StringName SetNoise = new("set_noise"); - } - - public new static class SignalName - { - public static readonly StringName LookAtTargetChanged = new("look_at_target_changed"); - public static readonly StringName Camera3DResourceChanged = new("camera_3d_resource_changed"); - public static readonly StringName Camera3DResourcePropertyChanged = new("camera_3d_resource_property_changed"); - } -} diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera3D.cs.uid b/addons/phantom_camera/scripts/phantom_camera/PhantomCamera3D.cs.uid deleted file mode 100644 index c1f08017f4..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCamera3D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bx3g7jxtwhi04 diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter2D.cs b/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter2D.cs deleted file mode 100644 index 4444dadc9b..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter2D.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Godot; - -namespace PhantomCamera.Noise; - -public class PhantomCameraNoiseEmitter2D(GodotObject node) -{ - public Node2D Node2D = (Node2D)node; - - public PhantomCameraNoise2D Noise - { - get => new((Resource)Node2D.Call(MethodName.GetNoise)); - set => Node2D.Call(MethodName.SetNoise, (GodotObject)value.Resource); - } - - public bool Continuous - { - get => (bool)Node2D.Call(MethodName.GetContinuous); - set => Node2D.Call(MethodName.SetContinuous, value); - } - - public float GrowthTime - { - get => (float)Node2D.Call(MethodName.GetGrowthTime); - set => Node2D.Call(MethodName.SetGrowthTime, value); - } - - public float Duration - { - get => (float)Node2D.Call(MethodName.GetDuration); - set => Node2D.Call(MethodName.SetDuration, value); - } - - public float DecayTime - { - get => (float)Node2D.Call(MethodName.GetDecayTime); - set => Node2D.Call(MethodName.SetDecayTime, value); - } - - public int NoiseEmitterLayer - { - get => (int)Node2D.Call(MethodName.GetNoiseEmitterLayer); - set => Node2D.Call(MethodName.SetNoiseEmitterLayer, value); - } - - public void SetNoiseEmitterLayerValue(int layer, bool value) => - Node2D.Call(MethodName.SetNoiseEmitterLayerValue, layer, value); - - public void Emit() => Node2D.Call(MethodName.Emit); - - public bool IsEmitting() => (bool)Node2D.Call(MethodName.IsEmitting); - - public void Stop() => Node2D.Call(MethodName.Stop); - - public void Toggle() => Node2D.Call(MethodName.Toggle); - - public static class MethodName - { - public static readonly StringName GetNoise = new("get_noise"); - public static readonly StringName SetNoise = new("set_noise"); - - public static readonly StringName GetContinuous = new("get_continuous"); - public static readonly StringName SetContinuous = new("set_continuous"); - - public static readonly StringName GetGrowthTime = new("get_growth_time"); - public static readonly StringName SetGrowthTime = new("set_growth_time"); - - public static readonly StringName GetDuration = new("get_duration"); - public static readonly StringName SetDuration = new("set_duration"); - - public static readonly StringName GetDecayTime = new("get_decay_time"); - public static readonly StringName SetDecayTime = new("set_decay_time"); - - public static readonly StringName GetNoiseEmitterLayer = new("get_noise_emitter_layer"); - public static readonly StringName SetNoiseEmitterLayer = new("set_noise_emitter_layer"); - - public static readonly StringName SetNoiseEmitterLayerValue = new("set_noise_emitter_layer_value"); - - public static readonly StringName Emit = new("emit"); - public static readonly StringName IsEmitting = new("is_emitting"); - public static readonly StringName Stop = new("stop"); - public static readonly StringName Toggle = new("toggle"); - } -} diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter2D.cs.uid b/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter2D.cs.uid deleted file mode 100644 index 4f35145d8a..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter2D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://btom8l3wlkn2j diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter3D.cs b/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter3D.cs deleted file mode 100644 index 2821f1fcb7..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter3D.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Godot; - -namespace PhantomCamera.Noise; - -public class PhantomCameraNoiseEmitter3D(GodotObject node) -{ - public Node3D Node3D = (Node3D)node; - - public PhantomCameraNoise3D Noise - { - get => new((Resource)Node3D.Call(MethodName.GetNoise)); - set => Node3D.Call(MethodName.SetNoise, (GodotObject)value.Resource); - } - - public bool Continuous - { - get => (bool)Node3D.Call(MethodName.GetContinuous); - set => Node3D.Call(MethodName.SetContinuous, value); - } - - public float GrowthTime - { - get => (float)Node3D.Call(MethodName.GetGrowthTime); - set => Node3D.Call(MethodName.SetGrowthTime, value); - } - - public float Duration - { - get => (float)Node3D.Call(MethodName.GetDuration); - set => Node3D.Call(MethodName.SetDuration, value); - } - - public float DecayTime - { - get => (float)Node3D.Call(MethodName.GetDecayTime); - set => Node3D.Call(MethodName.SetDecayTime, value); - } - - public int NoiseEmitterLayer - { - get => (int)Node3D.Call(MethodName.GetNoiseEmitterLayer); - set => Node3D.Call(MethodName.SetNoiseEmitterLayer, value); - } - - public void SetNoiseEmitterLayerValue(int layer, bool value) => - Node3D.Call(MethodName.SetNoiseEmitterLayerValue, layer, value); - - public void Emit() => Node3D.Call(MethodName.Emit); - - public bool IsEmitting() => (bool)Node3D.Call(MethodName.IsEmitting); - - public void Stop() => Node3D.Call(MethodName.Stop); - - public void Toggle() => Node3D.Call(MethodName.Toggle); - - public static class MethodName - { - public static readonly StringName GetNoise = new("get_noise"); - public static readonly StringName SetNoise = new("set_noise"); - - public static readonly StringName GetContinuous = new("get_continuous"); - public static readonly StringName SetContinuous = new("set_continuous"); - - public static readonly StringName GetGrowthTime = new("get_growth_time"); - public static readonly StringName SetGrowthTime = new("set_growth_time"); - - public static readonly StringName GetDuration = new("get_duration"); - public static readonly StringName SetDuration = new("set_duration"); - - public static readonly StringName GetDecayTime = new("get_decay_time"); - public static readonly StringName SetDecayTime = new("set_decay_time"); - - public static readonly StringName GetNoiseEmitterLayer = new("get_noise_emitter_layer"); - public static readonly StringName SetNoiseEmitterLayer = new("set_noise_emitter_layer"); - - public static readonly StringName SetNoiseEmitterLayerValue = new("set_noise_emitter_layer_value"); - - public static readonly StringName Emit = new("emit"); - public static readonly StringName IsEmitting = new("is_emitting"); - public static readonly StringName Stop = new("stop"); - public static readonly StringName Toggle = new("toggle"); - } -} diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter3D.cs.uid b/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter3D.cs.uid deleted file mode 100644 index bf32a5b860..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraNoiseEmitter3D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://buvda14filkjx diff --git a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraTweenDirector.cs b/addons/phantom_camera/scripts/phantom_camera/PhantomCameraTweenDirector.cs deleted file mode 100644 index 5bed9ce080..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera/PhantomCameraTweenDirector.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Godot; - -namespace PhantomCamera.TweenDirector; - -public class PhantomCameraTweenDirector(GodotObject node) -{ - public Node Node = (Node)node; - - public TweenDirectorResource TweenDirector - { - get => new((Resource)Node.Call(MethodName.GetTweenDirector)); - set => Node.Call(MethodName.SetTweenDirector, (GodotObject)value.Resource); - } - - public static class MethodName - { - public static readonly StringName SetTweenDirector = new("set_tween_director"); - public static readonly StringName GetTweenDirector = new("get_tween_director"); - } -} diff --git a/addons/phantom_camera/scripts/phantom_camera_host/PhantomCameraHost.cs b/addons/phantom_camera/scripts/phantom_camera_host/PhantomCameraHost.cs deleted file mode 100644 index 62c3ab2396..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera_host/PhantomCameraHost.cs +++ /dev/null @@ -1,111 +0,0 @@ -using Godot; - -#nullable enable - -namespace PhantomCamera; - -public enum InterpolationMode -{ - Auto, - Idle, - Physics, - Manual, -} - -public static class PhantomCameraHostExtensions -{ - public static PhantomCameraHost AsPhantomCameraHost(this Node node) - { - return new PhantomCameraHost(node); - } -} - -public class PhantomCameraHost() -{ - public Node Node { get; } = null!; - - public PhantomCameraHost(GodotObject node) : this() - { - Node = node as Node; - - var callablePCamBecameActive = Callable.From(pCam => PCamBecameActive?.Invoke(pCam)); - var callablePCamBecameInactive = Callable.From(pCam => PCamBecameInactive?.Invoke(pCam)); - - Node.Connect(SignalName.PCamBecameActive, callablePCamBecameActive); - Node.Connect(SignalName.PCamBecameInactive, callablePCamBecameInactive); - } - - public delegate void PCamBecameActiveEventHandler(Node pCam); - public delegate void PCamBecameInactiveEventHandler(Node pCam); - - public event PCamBecameActiveEventHandler? PCamBecameActive; - public event PCamBecameInactiveEventHandler? PCamBecameInactive; - - - private readonly Callable _callablePCamBecameActive; - private readonly Callable _callablePCamBecameInactive; - - public int HostLayers - { - get => (int)Node.Call(PhantomCamera.MethodName.GetHostLayers); - set => Node.Call(PhantomCamera.MethodName.SetHostLayers, value); - } - - public void SetHostLayersValue(int layer, bool value) => Node.Call(MethodName.SetHostLayersValue, layer, value); - - public Camera2D? Camera2D => (Camera2D?)Node.Get(PropertyName.Camera2D); - - public Camera3D? Camera3D => (Camera3D?)Node.Get(PropertyName.Camera3D); - - public InterpolationMode InterpolationMode - { - get => (InterpolationMode)(int)Node.Call(MethodName.GetInterpolationMode); - set => Node.Call(MethodName.SetInterpolationMode, (int)value); - } - - public bool TriggerPhantomCameraTween => (bool)Node.Call(MethodName.GetTriggerPhantomCameraTween); - - public void Process() => Node.Call(MethodName.Process); - - public PhantomCamera? GetActivePhantomCamera() - { - var result = Node.Call(MethodName.GetActivePhantomCamera); - - if (result.Obj is Node2D node2D) - { - return new PhantomCamera2D(node2D); - } - - if (result.Obj is Node3D node3D) - { - return new PhantomCamera3D(node3D); - } - - return null; - } - - public static class PropertyName - { - public static readonly StringName Camera2D = new("camera_2d"); - public static readonly StringName Camera3D = new("camera_3d"); - } - - public static class MethodName - { - public static readonly StringName GetActivePhantomCamera = new("get_active_pcam"); - public static readonly StringName GetTriggerPhantomCameraTween = new("get_trigger_pcam_tween"); - - public static readonly StringName GetInterpolationMode = new("get_interpolation_mode"); - public static readonly StringName SetInterpolationMode = new("set_interpolation_mode"); - - public static readonly StringName SetHostLayersValue = new("set_host_layers_value"); - - public static readonly StringName Process = new("process"); - } - - public static class SignalName - { - public static readonly StringName PCamBecameActive = new("pcam_became_active"); - public static readonly StringName PCamBecameInactive = new("pcam_became_inactive"); - } -} diff --git a/addons/phantom_camera/scripts/phantom_camera_host/PhantomCameraHost.cs.uid b/addons/phantom_camera/scripts/phantom_camera_host/PhantomCameraHost.cs.uid deleted file mode 100644 index ad4b4f5413..0000000000 --- a/addons/phantom_camera/scripts/phantom_camera_host/PhantomCameraHost.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cr8brwrls2nn3 diff --git a/addons/phantom_camera/scripts/resources/Camera3DResource.cs b/addons/phantom_camera/scripts/resources/Camera3DResource.cs deleted file mode 100644 index 54ad098891..0000000000 --- a/addons/phantom_camera/scripts/resources/Camera3DResource.cs +++ /dev/null @@ -1,116 +0,0 @@ -using Godot; - -namespace PhantomCamera; - -public enum KeepAspect -{ - KeepWidth, - KeepHeight -} - -public enum ProjectionType -{ - Perspective, - Orthogonal, - Frustum -} - -public class Camera3DResource(Resource resource) -{ - public readonly Resource Resource = resource; - - public KeepAspect KeepAspect - { - get => (KeepAspect)(int)Resource.Get(PropertyName.KeepAspect); - set => Resource.Set(PropertyName.KeepAspect, (int)value); - } - - public int CullMask - { - get => (int)Resource.Get(PropertyName.CullMask); - set => Resource.Set(PropertyName.CullMask, value); - } - - - public float HOffset - { - get => (float)Resource.Get(PropertyName.HOffset); - set => Resource.Set(PropertyName.HOffset, value); - } - - public float VOffset - { - get => (float)Resource.Get(PropertyName.VOffset); - set => Resource.Set(PropertyName.VOffset, value); - } - - public ProjectionType Projection - { - get => (ProjectionType)(int)Resource.Get(PropertyName.Projection); - set => Resource.Set(PropertyName.Projection, (int)value); - } - - public float Fov - { - get => (float)Resource.Get(PropertyName.Fov); - set => Resource.Set(PropertyName.Fov, Mathf.Clamp(value, 1, 179)); - } - - public float Size - { - get => (float)Resource.Get(PropertyName.Size); - set => Resource.Set(PropertyName.Size, Mathf.Clamp(value, 0.001f, float.PositiveInfinity)); - } - - public Vector2 FrustumOffset - { - get => (Vector2)Resource.Get(PropertyName.FrustumOffset); - set => Resource.Set(PropertyName.FrustumOffset, value); - } - - public float Near - { - get => (float)Resource.Get(PropertyName.Near); - set => Resource.Set(PropertyName.Near, Mathf.Clamp(value, 0.001f, float.PositiveInfinity)); - } - - public float Far - { - get => (float)Resource.Get(PropertyName.Far); - set => Resource.Set(PropertyName.Far, Mathf.Clamp(value, 0.01f, float.PositiveInfinity)); - } - - public static Camera3DResource New() - { - Resource resource = new(); -#if GODOT4_4_OR_GREATER - resource.SetScript(GD.Load("uid://b8hhnqsugykly")); -#else - resource.SetScript(GD.Load("res://addons/phantom_camera/scripts/resources/camera_3d_resource.gd")); -#endif - return new Camera3DResource(resource); - } - - public static class PropertyName - { - public static readonly StringName KeepAspect = new("keep_aspect"); - - public static readonly StringName CullMask = new("cull_mask"); - - public static readonly StringName HOffset = new("h_offset"); - - public static readonly StringName VOffset = new("v_offset"); - - public static readonly StringName Projection = new("projection"); - - public static readonly StringName Fov = new("fov"); - - public static readonly StringName Size = new("size"); - - public static readonly StringName FrustumOffset = new("frustum_offset"); - - public static readonly StringName Near = new("near"); - - public static readonly StringName Far = new("far"); - } -} diff --git a/addons/phantom_camera/scripts/resources/Camera3DResource.cs.uid b/addons/phantom_camera/scripts/resources/Camera3DResource.cs.uid deleted file mode 100644 index d66b43eac6..0000000000 --- a/addons/phantom_camera/scripts/resources/Camera3DResource.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://jedyxlihuwbj diff --git a/addons/phantom_camera/scripts/resources/PhantomCameraNoise2D.cs b/addons/phantom_camera/scripts/resources/PhantomCameraNoise2D.cs deleted file mode 100644 index f19d445004..0000000000 --- a/addons/phantom_camera/scripts/resources/PhantomCameraNoise2D.cs +++ /dev/null @@ -1,103 +0,0 @@ -using Godot; - -namespace PhantomCamera.Noise; - -public class PhantomCameraNoise2D(Resource resource) -{ - public readonly Resource Resource = resource; - - public float Amplitude - { - get => (float)Resource.Call(MethodName.GetAmplitude); - set => Resource.Call(MethodName.SetAmplitude, value); - } - - public float Frequency - { - get => (float)Resource.Call(MethodName.GetFrequency); - set => Resource.Call(MethodName.SetFrequency, value); - } - - public bool RandomizeNoiseSeed - { - get => (bool)Resource.Call(MethodName.GetRandomizeNoiseSeed); - set => Resource.Call(MethodName.SetRandomizeNoiseSeed, value); - } - - public int NoiseSeed - { - get => (int)Resource.Call(MethodName.GetNoiseSeed); - set => Resource.Call(MethodName.SetNoiseSeed, value); - } - - public bool RotationalNoise - { - get => (bool)Resource.Call(MethodName.GetRotationalNoise); - set => Resource.Call(MethodName.SetRotationalNoise, value); - } - - public bool PositionalNoise - { - get => (bool)Resource.Call(MethodName.GetPositionalNoise); - set => Resource.Call(MethodName.SetPositionalNoise, value); - } - - public float RotationalMultiplier - { - get => (float)Resource.Call(MethodName.GetRotationalMultiplier); - set => Resource.Call(MethodName.SetRotationalMultiplier, value); - } - - public float PositionalMultiplierX - { - get => (float)Resource.Call(MethodName.GetPositionalMultiplierX); - set => Resource.Call(MethodName.SetPositionalMultiplierX, value); - } - - public float PositionalMultiplierY - { - get => (float)Resource.Call(MethodName.GetPositionalMultiplierY); - set => Resource.Call(MethodName.SetPositionalMultiplierY, value); - } - - public static PhantomCameraNoise2D New() - { - Resource resource = new(); -#if GODOT4_4_OR_GREATER - resource.SetScript(GD.Load("uid://dimvdouy8g0sv")); -#else - resource.SetScript(GD.Load("res://addons/phantom_camera/scripts/resources/phantom_camera_noise_2d.gd")); -#endif - return new PhantomCameraNoise2D(resource); - } - - public static class MethodName - { - public static readonly StringName GetAmplitude = new("get_amplitude"); - public static readonly StringName SetAmplitude = new("set_amplitude"); - - public static readonly StringName GetFrequency = new("get_frequency"); - public static readonly StringName SetFrequency = new("set_frequency"); - - public static readonly StringName GetRandomizeNoiseSeed = new("get_randomize_noise_seed"); - public static readonly StringName SetRandomizeNoiseSeed = new("set_randomize_noise_seed"); - - public static readonly StringName GetNoiseSeed = new("get_noise_seed"); - public static readonly StringName SetNoiseSeed = new("set_noise_seed"); - - public static readonly StringName GetRotationalNoise = new("get_rotational_noise"); - public static readonly StringName SetRotationalNoise = new("set_rotational_noise"); - - public static readonly StringName GetPositionalNoise = new("get_positional_noise"); - public static readonly StringName SetPositionalNoise = new("set_positional_noise"); - - public static readonly StringName GetRotationalMultiplier = new("get_rotational_multiplier"); - public static readonly StringName SetRotationalMultiplier = new("set_rotational_multiplier"); - - public static readonly StringName GetPositionalMultiplierX = new("get_positional_multiplier_x"); - public static readonly StringName SetPositionalMultiplierX = new("set_positional_multiplier_x"); - - public static readonly StringName GetPositionalMultiplierY = new("get_positional_multiplier_y"); - public static readonly StringName SetPositionalMultiplierY = new("set_positional_multiplier_y"); - } -} diff --git a/addons/phantom_camera/scripts/resources/PhantomCameraNoise2D.cs.uid b/addons/phantom_camera/scripts/resources/PhantomCameraNoise2D.cs.uid deleted file mode 100644 index 16ddb84cef..0000000000 --- a/addons/phantom_camera/scripts/resources/PhantomCameraNoise2D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://capjdoxs6gs6r diff --git a/addons/phantom_camera/scripts/resources/PhantomCameraNoise3D.cs b/addons/phantom_camera/scripts/resources/PhantomCameraNoise3D.cs deleted file mode 100644 index 0c1a3cecad..0000000000 --- a/addons/phantom_camera/scripts/resources/PhantomCameraNoise3D.cs +++ /dev/null @@ -1,130 +0,0 @@ -using Godot; - -namespace PhantomCamera.Noise; - -public class PhantomCameraNoise3D(Resource resource) -{ - public readonly Resource Resource = resource; - - public float Amplitude - { - get => (float)Resource.Call(MethodName.GetAmplitude); - set => Resource.Call(MethodName.SetAmplitude, value); - } - - public float Frequency - { - get => (float)Resource.Call(MethodName.GetFrequency); - set => Resource.Call(MethodName.SetFrequency, value); - } - - public bool RandomizeNoiseSeed - { - get => (bool)Resource.Call(MethodName.GetRandomizeNoiseSeed); - set => Resource.Call(MethodName.SetRandomizeNoiseSeed, value); - } - - public int NoiseSeed - { - get => (int)Resource.Call(MethodName.GetNoiseSeed); - set => Resource.Call(MethodName.SetNoiseSeed, value); - } - - public bool RotationalNoise - { - get => (bool)Resource.Call(MethodName.GetRotationalNoise); - set => Resource.Call(MethodName.SetRotationalNoise, value); - } - - public bool PositionalNoise - { - get => (bool)Resource.Call(MethodName.GetPositionalNoise); - set => Resource.Call(MethodName.SetPositionalNoise, value); - } - - public float RotationalMultiplierX - { - get => (float)Resource.Call(MethodName.GetRotationalMultiplierX); - set => Resource.Call(MethodName.SetRotationalMultiplierX, value); - } - - public float RotationalMultiplierY - { - get => (float)Resource.Call(MethodName.GetRotationalMultiplierY); - set => Resource.Call(MethodName.SetRotationalMultiplierY, value); - } - - public float RotationalMultiplierZ - { - get => (float)Resource.Call(MethodName.GetRotationalMultiplierZ); - set => Resource.Call(MethodName.SetRotationalMultiplierZ, value); - } - - public float PositionalMultiplierX - { - get => (float)Resource.Call(MethodName.GetPositionalMultiplierX); - set => Resource.Call(MethodName.SetPositionalMultiplierX, value); - } - - public float PositionalMultiplierY - { - get => (float)Resource.Call(MethodName.GetPositionalMultiplierY); - set => Resource.Call(MethodName.SetPositionalMultiplierY, value); - } - - public float PositionalMultiplierZ - { - get => (float)Resource.Call(MethodName.GetPositionalMultiplierZ); - set => Resource.Call(MethodName.SetPositionalMultiplierZ, value); - } - - public static PhantomCameraNoise3D New() - { - Resource resource = new(); -#if GODOT4_4_OR_GREATER - resource.SetScript(GD.Load("uid://cuffvge5ad4aa")); -#else - resource.SetScript(GD.Load("res://addons/phantom_camera/scripts/resources/phantom_camera_noise_3d.gd")); -#endif - return new PhantomCameraNoise3D(resource); - } - - public static class MethodName - { - public static readonly StringName GetAmplitude = new("get_amplitude"); - public static readonly StringName SetAmplitude = new("set_amplitude"); - - public static readonly StringName GetFrequency = new("get_frequency"); - public static readonly StringName SetFrequency = new("set_frequency"); - - public static readonly StringName GetRandomizeNoiseSeed = new("get_randomize_noise_seed"); - public static readonly StringName SetRandomizeNoiseSeed = new("set_randomize_noise_seed"); - - public static readonly StringName GetNoiseSeed = new("get_noise_seed"); - public static readonly StringName SetNoiseSeed = new("set_noise_seed"); - - public static readonly StringName GetRotationalNoise = new("get_rotational_noise"); - public static readonly StringName SetRotationalNoise = new("set_rotational_noise"); - - public static readonly StringName GetPositionalNoise = new("get_positional_noise"); - public static readonly StringName SetPositionalNoise = new("set_positional_noise"); - - public static readonly StringName GetRotationalMultiplierX = new("get_rotational_multiplier_x"); - public static readonly StringName SetRotationalMultiplierX = new("set_rotational_multiplier_x"); - - public static readonly StringName GetRotationalMultiplierY = new("get_rotational_multiplier_y"); - public static readonly StringName SetRotationalMultiplierY = new("set_rotational_multiplier_y"); - - public static readonly StringName GetRotationalMultiplierZ = new("get_rotational_multiplier_z"); - public static readonly StringName SetRotationalMultiplierZ = new("set_rotational_multiplier_z"); - - public static readonly StringName GetPositionalMultiplierX = new("get_positional_multiplier_x"); - public static readonly StringName SetPositionalMultiplierX = new("set_positional_multiplier_x"); - - public static readonly StringName GetPositionalMultiplierY = new("get_positional_multiplier_y"); - public static readonly StringName SetPositionalMultiplierY = new("set_positional_multiplier_y"); - - public static readonly StringName GetPositionalMultiplierZ = new("get_positional_multiplier_z"); - public static readonly StringName SetPositionalMultiplierZ = new("set_positional_multiplier_z"); - } -} diff --git a/addons/phantom_camera/scripts/resources/PhantomCameraNoise3D.cs.uid b/addons/phantom_camera/scripts/resources/PhantomCameraNoise3D.cs.uid deleted file mode 100644 index 53d184f46c..0000000000 --- a/addons/phantom_camera/scripts/resources/PhantomCameraNoise3D.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://chk7643ynhe4f diff --git a/addons/phantom_camera/scripts/resources/PhantomCameraTween.cs b/addons/phantom_camera/scripts/resources/PhantomCameraTween.cs deleted file mode 100644 index 500e1656ff..0000000000 --- a/addons/phantom_camera/scripts/resources/PhantomCameraTween.cs +++ /dev/null @@ -1,75 +0,0 @@ -using Godot; - -namespace PhantomCamera; - -public enum TransitionType -{ - Linear, - Sine, - Quint, - Quart, - Quad, - Expo, - Elastic, - Cubic, - Circ, - Bounce, - Back -} - -public enum EaseType -{ - EaseIn, - EaseOut, - EaseInOut, - EaseOutIn -} - -public static class PhantomCameraTweenExtensions -{ - public static PhantomCameraTween AsPhantomCameraTween(this Resource resource) - { - return new PhantomCameraTween(resource); - } -} - -public class PhantomCameraTween(Resource tweenResource) -{ - public Resource Resource { get; } = tweenResource; - - public float Duration - { - get => (float)Resource.Get(PropertyName.Duration); - set => Resource.Set(PropertyName.Duration, value); - } - - public TransitionType Transition - { - get => (TransitionType)(int)Resource.Get(PropertyName.Transition); - set => Resource.Set(PropertyName.Transition, (int)value); - } - - public EaseType Ease - { - get => (EaseType)(int)Resource.Get(PropertyName.Ease); - set => Resource.Set(PropertyName.Ease, (int)value); - } - - public static PhantomCameraTween New() - { - Resource resource = new(); -#if GODOT4_4_OR_GREATER - resource.SetScript(GD.Load("uid://8umksf8e80fw")); -#else - resource.SetScript(GD.Load("res://addons/phantom_camera/scripts/resources/tween_resource.gd")); -#endif - return new PhantomCameraTween(resource); - } - - public static class PropertyName - { - public static readonly StringName Duration = new("duration"); - public static readonly StringName Transition = new("transition"); - public static readonly StringName Ease = new("ease"); - } -} diff --git a/addons/phantom_camera/scripts/resources/PhantomCameraTween.cs.uid b/addons/phantom_camera/scripts/resources/PhantomCameraTween.cs.uid deleted file mode 100644 index dd50ead96b..0000000000 --- a/addons/phantom_camera/scripts/resources/PhantomCameraTween.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ybr5c2s0tfvx diff --git a/addons/phantom_camera/scripts/resources/TweenDirectorResource.cs b/addons/phantom_camera/scripts/resources/TweenDirectorResource.cs deleted file mode 100644 index d0852bb60a..0000000000 --- a/addons/phantom_camera/scripts/resources/TweenDirectorResource.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Linq; -using Godot; -using Godot.Collections; - -namespace PhantomCamera.TweenDirector; - -public enum Type { - PhantomCameras = 0, - TweenResources = 1, - Any = 2, -} - -public class TweenDirectorResource(Resource resource) -{ - public readonly Resource Resource = resource; - - public PhantomCameraTween TweenResource - { - get => new((Resource)Resource.Call(MethodName.GetTweenResource)); - set => Resource.Call(MethodName.SetTweenResource, (GodotObject)value.Resource); - } - - public Type FromType - { - get => (Type)(int)Resource.Call(MethodName.GetFromType); - set => Resource.Call(MethodName.SetFromType, (int)value); - } - - public NodePath[] FromPhantomCameras - { - get => Resource.Call(MethodName.GetFromPhantomCameras).AsGodotArray().ToArray(); - set => Resource.Call(MethodName.SetFromPhantomCameras, new Array(value)); - } - - public Resource[] FromTweenResources - { - get => Resource.Call(MethodName.GetFromTweenResources).AsGodotArray().ToArray(); - set => Resource.Call(MethodName.SetFromTweenResources, new Array(value)); - } - - public Type ToType - { - get => (Type)(int)Resource.Call(MethodName.GetToType); - set => Resource.Call(MethodName.SetToType, (int)value); - } - - public NodePath[] ToPhantomCameras - { - get => (NodePath[])Resource.Call(MethodName.GetToPhantomCameras); - set => Resource.Call(MethodName.SetToPhantomCameras, value); - } - - public Resource[] ToTweenResources - { - get => Resource.Call(MethodName.GetToTweenResources).AsGodotArray().ToArray(); - set => Resource.Call(MethodName.SetToTweenResources, new Array(value)); - } - - public static TweenDirectorResource New() - { - Resource resource = new(); - resource.SetScript(GD.Load("uid://2au3qse3jc5t")); - return new TweenDirectorResource(resource); - } - - public static class MethodName - { - public static readonly StringName GetTweenResource = new("get_tween_resource"); - public static readonly StringName SetTweenResource = new("set_tween_resource"); - - public static readonly StringName GetFromType = new("get_from_type"); - public static readonly StringName SetFromType = new("set_from_type"); - - public static readonly StringName GetFromPhantomCameras = new("get_from_phantom_cameras"); - public static readonly StringName SetFromPhantomCameras = new("set_from_phantom_cameras"); - - public static readonly StringName GetFromTweenResources = new("get_from_tween_resources"); - public static readonly StringName SetFromTweenResources = new("set_from_tween_resources"); - - public static readonly StringName GetToType = new("get_to_type"); - public static readonly StringName SetToType = new("set_to_type"); - - public static readonly StringName GetToPhantomCameras = new("get_to_phantom_cameras"); - public static readonly StringName SetToPhantomCameras = new("set_to_phantom_cameras"); - - public static readonly StringName GetToTweenResources = new("get_to_tween_resources"); - public static readonly StringName SetToTweenResources = new("set_to_tween_resources"); - } -}