From 150a21aabcd232bc9f1a342733eff6c9a7699563 Mon Sep 17 00:00:00 2001 From: Zenny Date: Thu, 4 Jun 2026 12:24:58 -0700 Subject: [PATCH] Basic implementation for acquiring affinity sigil from Sarco --- .../Item/RescuedItemDatabase.cs | 5 ++ .../Quest/QuestData.cs | 2 +- .../Quest/SarcoData.cs | 11 +++ Zennysoft.Game.Ma/project.godot | 2 +- .../src/game/DialogueController.cs | 13 +-- Zennysoft.Game.Ma/src/game/Game.cs | 8 ++ Zennysoft.Game.Ma/src/game/GameData.cs | 3 + Zennysoft.Game.Ma/src/game/IGame.cs | 2 + Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs | 87 +++++++++++++++++++ .../src/map/Placeables/Sarco.cs.uid | 1 + .../src/map/Placeables/Sarco.tscn | 72 ++++++++++++++- .../src/map/Placeables/sarco.dialogue | 11 +++ .../src/map/Placeables/sarco.dialogue.import | 16 ++++ .../floors/Special Floors/Overworld.tscn | 19 ++-- Zennysoft.Game.Ma/src/player/Player.cs | 2 + .../src/ui/inventory_menu/InventoryMenu.cs | 3 + 16 files changed, 242 insertions(+), 15 deletions(-) create mode 100644 Zennysoft.Game.Ma.Implementation/Quest/SarcoData.cs create mode 100644 Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs create mode 100644 Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs.uid create mode 100644 Zennysoft.Game.Ma/src/map/Placeables/sarco.dialogue create mode 100644 Zennysoft.Game.Ma/src/map/Placeables/sarco.dialogue.import diff --git a/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs b/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs index 6e360af1..bb0b7d81 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs @@ -8,6 +8,11 @@ public class RescuedItemDatabase private List _items { get; init; } private int _maxSize { get; init; } = 20; + public RescuedItemDatabase() + { + _items = []; + } + public RescuedItemDatabase(int maxSize) { _items = []; diff --git a/Zennysoft.Game.Ma.Implementation/Quest/QuestData.cs b/Zennysoft.Game.Ma.Implementation/Quest/QuestData.cs index a09d2165..2ffd4271 100644 --- a/Zennysoft.Game.Ma.Implementation/Quest/QuestData.cs +++ b/Zennysoft.Game.Ma.Implementation/Quest/QuestData.cs @@ -11,4 +11,4 @@ public partial record QuestData [Save("quest_data_1")] public bool QuestMarker1 { get; set; } = false; -} +} \ No newline at end of file diff --git a/Zennysoft.Game.Ma.Implementation/Quest/SarcoData.cs b/Zennysoft.Game.Ma.Implementation/Quest/SarcoData.cs new file mode 100644 index 00000000..cba3f2bc --- /dev/null +++ b/Zennysoft.Game.Ma.Implementation/Quest/SarcoData.cs @@ -0,0 +1,11 @@ +using Chickensoft.Introspection; +using Chickensoft.Serialization; + +namespace Zennysoft.Ma.Adapter; + +[Meta, Id("sarco_data")] +public partial record SarcoData +{ + [Save("igneous_sarco")] + public bool IgneousSarcoAcquired { get; set; } = false; +} diff --git a/Zennysoft.Game.Ma/project.godot b/Zennysoft.Game.Ma/project.godot index 35365dfc..fd958958 100644 --- a/Zennysoft.Game.Ma/project.godot +++ b/Zennysoft.Game.Ma/project.godot @@ -284,7 +284,7 @@ EnemyViewerWalk={ [internationalization] -locale/translations_pot_files=PackedStringArray("res://src/dialog/Dialogue.dialogue", "res://src/npc/Ran/ran.dialogue", "res://src/npc/Rat/ratdialogue.dialogue", "res://src/dialog/Altar.dialogue", "res://stone.dialogue", "res://src/npc/Proscenium/JumpScare.dialogue") +locale/translations_pot_files=PackedStringArray("res://src/dialog/Dialogue.dialogue", "res://src/npc/Ran/ran.dialogue", "res://src/npc/Rat/ratdialogue.dialogue", "res://src/dialog/Altar.dialogue", "res://stone.dialogue", "res://src/npc/Proscenium/JumpScare.dialogue", "res://src/map/Placeables/sarco.dialogue") [layer_names] diff --git a/Zennysoft.Game.Ma/src/game/DialogueController.cs b/Zennysoft.Game.Ma/src/game/DialogueController.cs index aead9b3d..93f96db9 100644 --- a/Zennysoft.Game.Ma/src/game/DialogueController.cs +++ b/Zennysoft.Game.Ma/src/game/DialogueController.cs @@ -1,5 +1,6 @@ using DialogueManagerRuntime; using Godot; +using Godot.Collections; namespace Zennysoft.Game.Ma; @@ -13,18 +14,18 @@ public partial class DialogueController : Node public override void _Ready() { - DialogueBalloon = GD.Load("res://src/ui/dialogue/DialogueBalloon.tscn"); + DialogueBalloon = GD.Load("res://src/ui/dialogue/DialogueBalloon.tscn"); } - public static void ShowDialogue(Resource dialogueResource, string dialogueTitle) + public static void ShowDialogue(Resource dialogueResource, string dialogueTitle, Array extraGameStates = null) { - Interrupt(); - _currentlyActiveDialogue = DialogueManager.ShowDialogueBalloonScene(DialogueBalloon, dialogueResource, dialogueTitle); + Interrupt(); + _currentlyActiveDialogue = DialogueManager.ShowDialogueBalloonScene(DialogueBalloon, dialogueResource, dialogueTitle, extraGameStates); } public static void Interrupt() { - if (IsInstanceValid(_currentlyActiveDialogue)) - _currentlyActiveDialogue.QueueFree(); + if (IsInstanceValid(_currentlyActiveDialogue)) + _currentlyActiveDialogue.QueueFree(); } } diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 29574a36..93a5e262 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -70,6 +70,8 @@ public partial class Game : Node3D, IGame public QuestData QuestData { get; private set; } + public SarcoData SarcoData { get; private set; } + public ItemRescueMenu ItemRescueMenu { get => InGameUI.ItemRescueMenu; } private EffectService _effectService; @@ -97,6 +99,7 @@ public partial class Game : Node3D, IGame QuestData = new QuestData(); RescuedItems = new RescuedItemDatabase(20); + SarcoData = new SarcoData(); ItemDatabase = ItemDatabase.Instance; GameChunk = new SaveChunk( @@ -109,6 +112,10 @@ public partial class Game : Node3D, IGame { DeathCount = QuestData.DeathCount, QuestMarker1 = QuestData.QuestMarker1 + }, + SarcoData = new SarcoData() + { + IgneousSarcoAcquired = SarcoData.IgneousSarcoAcquired, } }; return gameData; @@ -118,6 +125,7 @@ public partial class Game : Node3D, IGame { RescuedItems = data.RescuedItems; QuestData = data.QuestData; + SarcoData = data.SarcoData; } ); diff --git a/Zennysoft.Game.Ma/src/game/GameData.cs b/Zennysoft.Game.Ma/src/game/GameData.cs index 4f10ac21..0a42177b 100644 --- a/Zennysoft.Game.Ma/src/game/GameData.cs +++ b/Zennysoft.Game.Ma/src/game/GameData.cs @@ -11,5 +11,8 @@ public partial record GameData [Save("quest_data")] public required QuestData QuestData { get; init; } + + [Save("sarco_data")] + public required SarcoData SarcoData { get; init; } } diff --git a/Zennysoft.Game.Ma/src/game/IGame.cs b/Zennysoft.Game.Ma/src/game/IGame.cs index aac4773f..a8b7b603 100644 --- a/Zennysoft.Game.Ma/src/game/IGame.cs +++ b/Zennysoft.Game.Ma/src/game/IGame.cs @@ -46,6 +46,8 @@ public interface IGame : IProvide, IProvide, IProvide public QuestData QuestData { get; } + public SarcoData SarcoData { get; } + public event Action GameExitRequested; public event Action GameLoaded; diff --git a/Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs b/Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs new file mode 100644 index 00000000..11a059d3 --- /dev/null +++ b/Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs @@ -0,0 +1,87 @@ +using Chickensoft.AutoInject; +using Chickensoft.Introspection; +using DialogueManagerRuntime; +using Godot; +using System.Linq; +using System.Threading.Tasks; +using Zennysoft.Game.Ma; +using Zennysoft.Ma.Adapter; + +[Meta(typeof(IAutoNode))] +public partial class Sarco : Node3D +{ + public override void _Notification(int what) => this.Notify(what); + + [Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType().Single()); + + [Dependency] public IGame _game => this.DependOn(); + + [Dependency] private IGameRepo _gameRepo => this.DependOn(); + + [Export] + public ElementType Affinity { get; set; } + + [Export] + public Resource Dialogue { get; set; } + + [Node] public AnimationPlayer AnimationPlayer { get; set; } + + [Node] public Area3D InteractZone { get; set; } + + private bool _isInInteractZone = false; + + private bool _interactionComplete = false; + + public string AffinityString => Affinity.ToString(); + + public void OnReady() + { + SetPhysicsProcess(true); + InteractZone.BodyEntered += InteractZone_BodyEntered; + InteractZone.BodyExited += InteractZone_BodyExited; + } + + public void OnResolved() + { + _interactionComplete = _game.SarcoData.IgneousSarcoAcquired; + if (_interactionComplete) + ShowFlower(); + } + + public override void _Input(InputEvent @event) + { + if (Dialogue != null && @event.IsActionPressed(GameInputs.Interact) && _isInInteractZone && !_interactionComplete) + { + GetTree().Paused = true; + DialogueController.ShowDialogue(Dialogue, "general", [this]); + } + } + + public async Task EquipAffinity() + { + _player.SetSigil(new Sigil() { ElementType = Affinity }); + } + + public async Task ShowFlower() + { + AnimationPlayer.Play("fade_in"); + } + + public async Task Finish() + { + GetTree().Paused = false; + _interactionComplete = true; + _game.SarcoData.IgneousSarcoAcquired = true; + await _game.Save(); + } + + private void InteractZone_BodyEntered(Node3D body) + { + _isInInteractZone = true; + } + + private void InteractZone_BodyExited(Node3D body) + { + _isInInteractZone = false; + } +} diff --git a/Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs.uid b/Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs.uid new file mode 100644 index 00000000..d5be83ef --- /dev/null +++ b/Zennysoft.Game.Ma/src/map/Placeables/Sarco.cs.uid @@ -0,0 +1 @@ +uid://cn27rfw6olqaf diff --git a/Zennysoft.Game.Ma/src/map/Placeables/Sarco.tscn b/Zennysoft.Game.Ma/src/map/Placeables/Sarco.tscn index c30613e0..d8e26a39 100644 --- a/Zennysoft.Game.Ma/src/map/Placeables/Sarco.tscn +++ b/Zennysoft.Game.Ma/src/map/Placeables/Sarco.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://dqjovmlt1y4tb"] +[gd_scene load_steps=11 format=3 uid="uid://dqjovmlt1y4tb"] [ext_resource type="PackedScene" uid="uid://bfvy34lj7lns" path="res://src/map/assets/Sarcophagus/sarco altar.glb" id="1_35fk8"] +[ext_resource type="Script" uid="uid://cn27rfw6olqaf" path="res://src/map/Placeables/Sarco.cs" id="1_bw4xo"] +[ext_resource type="Resource" uid="uid://d2s0mmg453n5f" path="res://src/map/Placeables/sarco.dialogue" id="2_21qtc"] [ext_resource type="PackedScene" uid="uid://d2rje5p3a0xdg" path="res://src/map/assets/Sarcophagus/sarco.glb" id="2_c6ny3"] [ext_resource type="Texture2D" uid="uid://cqcjbeoghy70" path="res://src/items/special/textures/Flower.png" id="3_c6ny3"] @@ -8,8 +10,50 @@ height = 10.272 radius = 2.56201 +[sub_resource type="Animation" id="Animation_c6ny3"] +resource_name = "fade_in" +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("FLOWER:transparency") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [1.0, 0.0] +} + +[sub_resource type="Animation" id="Animation_bw4xo"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("FLOWER:transparency") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [1.0] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_21qtc"] +_data = { +&"RESET": SubResource("Animation_bw4xo"), +&"fade_in": SubResource("Animation_c6ny3") +} + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_21qtc"] +height = 20.9375 +radius = 5.50684 + [node name="Sarco" type="Node3D"] transform = Transform3D(0.595, 0, 0, 0, 0.595, 0, 0, 0, 0.595, 0, 0, 0) +script = ExtResource("1_bw4xo") +Dialogue = ExtResource("2_21qtc") [node name="sarco altar" parent="." instance=ExtResource("1_35fk8")] @@ -23,6 +67,30 @@ shape = SubResource("CylinderShape3D_bw4xo") [node name="FLOWER" type="Sprite3D" parent="."] transform = Transform3D(0.299972, -0.253855, 0.309151, -0.212973, 0.225749, 0.39202, -0.338614, -0.366872, 0.0273082, 2.43807, 2.21512, 0.0190778) -visible = false +transparency = 1.0 shaded = true texture = ExtResource("3_c6ny3") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +unique_name_in_owner = true +libraries = { +&"": SubResource("AnimationLibrary_21qtc") +} + +[node name="InteractZone" type="Area3D" parent="."] +unique_name_in_owner = true +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.273779, 0, 0) +collision_layer = 2 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractZone"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00627998, 1.69336, -0.00723076) +shape = SubResource("CylinderShape3D_21qtc") + +[node name="Prompt" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/Zennysoft.Game.Ma/src/map/Placeables/sarco.dialogue b/Zennysoft.Game.Ma/src/map/Placeables/sarco.dialogue new file mode 100644 index 00000000..fc9761d9 --- /dev/null +++ b/Zennysoft.Game.Ma/src/map/Placeables/sarco.dialogue @@ -0,0 +1,11 @@ +~ general +Acquired {{AffinityString}} sigil. +do ShowFlower() +- Equip now. + do EquipAffinity() + {{AffinityString}} sigil equipped. + do Finish() + => END +- Do not equip. + do Finish() + => END diff --git a/Zennysoft.Game.Ma/src/map/Placeables/sarco.dialogue.import b/Zennysoft.Game.Ma/src/map/Placeables/sarco.dialogue.import new file mode 100644 index 00000000..5bc83f6c --- /dev/null +++ b/Zennysoft.Game.Ma/src/map/Placeables/sarco.dialogue.import @@ -0,0 +1,16 @@ +[remap] + +importer="dialogue_manager" +importer_version=15 +type="Resource" +uid="uid://d2s0mmg453n5f" +path="res://.godot/imported/sarco.dialogue-b3046780591777465058b493c5c5a670.tres" + +[deps] + +source_file="res://src/map/Placeables/sarco.dialogue" +dest_files=["res://.godot/imported/sarco.dialogue-b3046780591777465058b493c5c5a670.tres"] + +[params] + +defaults=true diff --git a/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/Overworld.tscn b/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/Overworld.tscn index ffda69dc..e4b31b2f 100644 --- a/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/Overworld.tscn +++ b/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/Overworld.tscn @@ -35,11 +35,11 @@ [ext_resource type="Texture2D" uid="uid://co3s2s5tswuj4" path="res://src/map/overworld/Overworld Fixes Models/Overworld Reexport Fixes_MOSAIC.png" id="30_6gklp"] [ext_resource type="Texture2D" uid="uid://pu4o1pwi6hnf" path="res://src/map/overworld/Overworld Fixes Models/Overworld Reexport Fixes_rock_outside_colored_CORRECTED1.png" id="31_kdqo4"] [ext_resource type="PackedScene" uid="uid://r5d74jsx8tq6" path="res://src/map/Placeables/Stele B.tscn" id="32_xqf5a"] -[ext_resource type="AudioStream" uid="uid://60hn13ryqn88" path="res://src/audio/amb/amb_perlin.ogg" id="49_xqf5a"] -[ext_resource type="AudioStream" uid="uid://db0e4p4b11tyf" path="res://src/audio/amb/amb_beach.ogg" id="51_v60tm"] -[ext_resource type="AudioStream" uid="uid://b7g0tnn43an8" path="res://src/audio/amb/amb_white_noise.ogg" id="52_o5pdk"] -[ext_resource type="AudioStream" uid="uid://b5vhghigr263m" path="res://src/audio/amb/amb_ATMOSTPHERE.ogg" id="53_v60tm"] -[ext_resource type="AudioStream" uid="uid://d3uj87dsngy22" path="res://src/audio/amb/amb_water_lapping2.ogg" id="53_xqf5a"] +[ext_resource type="AudioStream" uid="uid://60hn13ryqn88" path="res://src/audio/AMB/amb_perlin.ogg" id="49_xqf5a"] +[ext_resource type="AudioStream" uid="uid://db0e4p4b11tyf" path="res://src/audio/AMB/amb_beach.ogg" id="51_v60tm"] +[ext_resource type="AudioStream" uid="uid://b7g0tnn43an8" path="res://src/audio/AMB/amb_white_noise.ogg" id="52_o5pdk"] +[ext_resource type="AudioStream" uid="uid://b5vhghigr263m" path="res://src/audio/AMB/amb_ATMOSTPHERE.ogg" id="53_v60tm"] +[ext_resource type="AudioStream" uid="uid://d3uj87dsngy22" path="res://src/audio/AMB/amb_water_lapping2.ogg" id="53_xqf5a"] [ext_resource type="PackedScene" uid="uid://dqjovmlt1y4tb" path="res://src/map/Placeables/Sarco.tscn" id="59_mic3u"] [ext_resource type="PackedScene" uid="uid://doncarj3f8iua" path="res://src/vfx/Torch.tscn" id="60_xqf5a"] [ext_resource type="PackedScene" uid="uid://b3owhc620qisb" path="res://src/map/Placeables/Stele A.tscn" id="61_v60tm"] @@ -2749,6 +2749,7 @@ parameters/looping = true script = ExtResource("66_q7hpd") [node name="Water Lapping" type="AudioStreamPlayer3D" parent="Audio/DimmableAudio"] +process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -101.693, 4.56576, 0.425669) stream = ExtResource("53_xqf5a") volume_db = -7.143 @@ -2760,6 +2761,7 @@ bus = &"AMBIENT" parameters/looping = true [node name="Water Lapping2" type="AudioStreamPlayer3D" parent="Audio/DimmableAudio"] +process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -109.458, 4.56576, -39.2783) stream = ExtResource("53_xqf5a") volume_db = -7.143 @@ -2771,11 +2773,14 @@ bus = &"AMBIENT" parameters/looping = true [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="Audio/DimmableAudio"] +process_mode = 3 stream = ExtResource("53_v60tm") autoplay = true +bus = &"AMBIENT" parameters/looping = true [node name="Ocean4" type="AudioStreamPlayer" parent="Audio/DimmableAudio"] +process_mode = 3 stream = ExtResource("51_v60tm") volume_db = -19.067 autoplay = true @@ -3012,6 +3017,10 @@ transform = Transform3D(0.921192, 0.0644309, 0.329915, -0.635509, 0.0745904, 0.4 mesh = SubResource("ArrayMesh_pxsmp") skeleton = NodePath("") +[node name="Sarco2" parent="." instance=ExtResource("59_mic3u")] +transform = Transform3D(-0.561658, 0, -0.196382, 0, 0.595, 0, 0.196382, 0, -0.561658, -328.661, 2.6811, 27.9079) +Affinity = 4 + [editable path="Node3D/Overworld Re-Scaled (Missing Distance Objects)"] [editable path="Actors/Rat"] [editable path="Actors/Clalo"] diff --git a/Zennysoft.Game.Ma/src/player/Player.cs b/Zennysoft.Game.Ma/src/player/Player.cs index 9572cfa4..4edd4038 100644 --- a/Zennysoft.Game.Ma/src/player/Player.cs +++ b/Zennysoft.Game.Ma/src/player/Player.cs @@ -344,6 +344,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide if (AutoRevive) return; + SetSigil(new Sigil() { ElementType = ElementType.None }); + HealthTimer.WaitTime = _healthTimerWaitTime; HealthTimer.Timeout -= OnHealthTimerTimeout; SetProcessInput(false); diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs index 853a87d2..3edd1326 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs @@ -85,6 +85,9 @@ public partial class InventoryMenu : Control, IInventoryMenu public override void _Input(InputEvent @event) { + if (!Visible) + return; + if (_blocking) { GetViewport().SetInputAsHandled();