Save when talking to stele and record their ID in the save file
This commit is contained in:
@@ -27,3 +27,10 @@ public partial record SarcoData
|
|||||||
[Save("shura_sarco")]
|
[Save("shura_sarco")]
|
||||||
public bool ShuraSarcoAcquired { get; set; } = false;
|
public bool ShuraSarcoAcquired { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Meta, Id("npc_data")]
|
||||||
|
public partial record NpcData
|
||||||
|
{
|
||||||
|
[Save("stele_list")]
|
||||||
|
public required List<int> SteleDiscovered { get; set; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ public partial class Game : Node3D, IGame
|
|||||||
|
|
||||||
public SarcoData SarcoData { get; private set; }
|
public SarcoData SarcoData { get; private set; }
|
||||||
|
|
||||||
|
public NpcData NpcData { get; private set; }
|
||||||
|
|
||||||
public ItemRescueMenu ItemRescueMenu { get => InGameUI.ItemRescueMenu; }
|
public ItemRescueMenu ItemRescueMenu { get => InGameUI.ItemRescueMenu; }
|
||||||
|
|
||||||
private EffectService _effectService;
|
private EffectService _effectService;
|
||||||
@@ -100,6 +102,7 @@ public partial class Game : Node3D, IGame
|
|||||||
QuestData = new QuestData();
|
QuestData = new QuestData();
|
||||||
RescuedItems = new RescuedItemDatabase(20);
|
RescuedItems = new RescuedItemDatabase(20);
|
||||||
SarcoData = new SarcoData();
|
SarcoData = new SarcoData();
|
||||||
|
NpcData = new NpcData() { SteleDiscovered = [] };
|
||||||
ItemDatabase = ItemDatabase.Instance;
|
ItemDatabase = ItemDatabase.Instance;
|
||||||
|
|
||||||
GameChunk = new SaveChunk<GameData>(
|
GameChunk = new SaveChunk<GameData>(
|
||||||
@@ -122,6 +125,10 @@ public partial class Game : Node3D, IGame
|
|||||||
FerrumSarcoAcquired = SarcoData.FerrumSarcoAcquired,
|
FerrumSarcoAcquired = SarcoData.FerrumSarcoAcquired,
|
||||||
SanktaSarcoAcquired = SarcoData.SanktaSarcoAcquired,
|
SanktaSarcoAcquired = SarcoData.SanktaSarcoAcquired,
|
||||||
ShuraSarcoAcquired = SarcoData.ShuraSarcoAcquired,
|
ShuraSarcoAcquired = SarcoData.ShuraSarcoAcquired,
|
||||||
|
},
|
||||||
|
NpcData = new NpcData()
|
||||||
|
{
|
||||||
|
SteleDiscovered = NpcData.SteleDiscovered
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return gameData;
|
return gameData;
|
||||||
@@ -129,9 +136,10 @@ public partial class Game : Node3D, IGame
|
|||||||
onLoad:
|
onLoad:
|
||||||
(chunk, data) =>
|
(chunk, data) =>
|
||||||
{
|
{
|
||||||
RescuedItems = data.RescuedItems;
|
RescuedItems = data.RescuedItems ?? new RescuedItemDatabase();
|
||||||
QuestData = data.QuestData;
|
QuestData = data.QuestData ?? new QuestData();
|
||||||
SarcoData = data.SarcoData;
|
SarcoData = data.SarcoData ?? new SarcoData();
|
||||||
|
NpcData = data.NpcData ?? new NpcData() { SteleDiscovered = [] };
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -14,5 +14,8 @@ public partial record GameData
|
|||||||
|
|
||||||
[Save("sarco_data")]
|
[Save("sarco_data")]
|
||||||
public required SarcoData SarcoData { get; init; }
|
public required SarcoData SarcoData { get; init; }
|
||||||
|
|
||||||
|
[Save("npc_data")]
|
||||||
|
public required NpcData NpcData { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ public interface IGame : IProvide<IGame>, IProvide<IGameRepo>, IProvide<IPlayer>
|
|||||||
|
|
||||||
public SarcoData SarcoData { get; }
|
public SarcoData SarcoData { get; }
|
||||||
|
|
||||||
|
public NpcData NpcData { get; }
|
||||||
|
|
||||||
public event Action GameExitRequested;
|
public event Action GameExitRequested;
|
||||||
|
|
||||||
public event Action GameLoaded;
|
public event Action GameLoaded;
|
||||||
|
|||||||
@@ -40,10 +40,6 @@ public partial class Sarco : Node3D
|
|||||||
SetPhysicsProcess(true);
|
SetPhysicsProcess(true);
|
||||||
InteractZone.BodyEntered += InteractZone_BodyEntered;
|
InteractZone.BodyEntered += InteractZone_BodyEntered;
|
||||||
InteractZone.BodyExited += InteractZone_BodyExited;
|
InteractZone.BodyExited += InteractZone_BodyExited;
|
||||||
}
|
|
||||||
|
|
||||||
public void OnResolved()
|
|
||||||
{
|
|
||||||
_interactionComplete = GetSaveDataByAffinity();
|
_interactionComplete = GetSaveDataByAffinity();
|
||||||
if (_interactionComplete)
|
if (_interactionComplete)
|
||||||
ShowFlower();
|
ShowFlower();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=237 format=4 uid="uid://dvnc26rebk6o0"]
|
[gd_scene load_steps=238 format=4 uid="uid://dvnc26rebk6o0"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cuhfkyh3d7noa" path="res://src/map/dungeon/code/Overworld.cs" id="1_5hmt3"]
|
[ext_resource type="Script" uid="uid://cuhfkyh3d7noa" path="res://src/map/dungeon/code/Overworld.cs" id="1_5hmt3"]
|
||||||
[ext_resource type="Texture2D" uid="uid://co6h8vyi11sl2" path="res://src/map/overworld/Models/Overworld_CLOUD_RINGS_INNER_63.png" id="2_g6b7b"]
|
[ext_resource type="Texture2D" uid="uid://co6h8vyi11sl2" path="res://src/map/overworld/Models/Overworld_CLOUD_RINGS_INNER_63.png" id="2_g6b7b"]
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
[ext_resource type="AudioStream" uid="uid://b5vhghigr263m" path="res://src/audio/AMB/amb_ATMOSTPHERE.ogg" id="53_v60tm"]
|
[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://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://dqjovmlt1y4tb" path="res://src/map/Placeables/Sarco.tscn" id="59_mic3u"]
|
||||||
|
[ext_resource type="Resource" uid="uid://8wf6jvs78ncf" path="res://stone.dialogue" id="60_1b363"]
|
||||||
[ext_resource type="PackedScene" uid="uid://doncarj3f8iua" path="res://src/vfx/Torch.tscn" id="60_xqf5a"]
|
[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"]
|
[ext_resource type="PackedScene" uid="uid://b3owhc620qisb" path="res://src/map/Placeables/Stele A.tscn" id="61_v60tm"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cn13lho2so7sr" path="res://src/map/Placeables/Stele E.tscn" id="62_o5pdk"]
|
[ext_resource type="PackedScene" uid="uid://cn13lho2so7sr" path="res://src/map/Placeables/Stele E.tscn" id="62_o5pdk"]
|
||||||
@@ -2793,9 +2794,11 @@ transform = Transform3D(-0.267765, 0, 0.351913, 0, 0.4422, 0, -0.351913, 0, -0.2
|
|||||||
|
|
||||||
[node name="Rat" parent="Actors" instance=ExtResource("75_322om")]
|
[node name="Rat" parent="Actors" instance=ExtResource("75_322om")]
|
||||||
transform = Transform3D(1, 0, 1.19209e-07, 0, 1, 0, -1.19209e-07, 0, 1, -36.8943, 3.78707, 44.3599)
|
transform = Transform3D(1, 0, 1.19209e-07, 0, 1, 0, -1.19209e-07, 0, 1, -36.8943, 3.78707, 44.3599)
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="Clalo" parent="Actors" instance=ExtResource("76_nfcfh")]
|
[node name="Clalo" parent="Actors" instance=ExtResource("76_nfcfh")]
|
||||||
transform = Transform3D(-1.15777, 0, -1.52161, 0, 1.912, 0, 1.52161, 0, -1.15777, -244.949, 1.16958, 117.235)
|
transform = Transform3D(-1.15777, 0, -1.52161, 0, 1.912, 0, 1.52161, 0, -1.15777, -244.949, 1.16958, 117.235)
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="AnimatedSprite3D" parent="Actors/Clalo" index="0"]
|
[node name="AnimatedSprite3D" parent="Actors/Clalo" index="0"]
|
||||||
transform = Transform3D(1.11, 0, 0, 0, 1.11, 0, 0, 0, 1.11, 0, 0.179583, 0)
|
transform = Transform3D(1.11, 0, 0, 0, 1.11, 0, 0, 0, 1.11, 0, 0.179583, 0)
|
||||||
@@ -2803,6 +2806,7 @@ frame_progress = 0.120696
|
|||||||
|
|
||||||
[node name="Caretaker of Saints" parent="Actors" instance=ExtResource("80_8isf0")]
|
[node name="Caretaker of Saints" parent="Actors" instance=ExtResource("80_8isf0")]
|
||||||
transform = Transform3D(-1.42252, 0, -3.28851, 0, 3.583, 0, 3.28851, 0, -1.42252, -245.674, 3.22781, 272.252)
|
transform = Transform3D(-1.42252, 0, -3.28851, 0, 3.583, 0, 3.28851, 0, -1.42252, -245.674, 3.22781, 272.252)
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="AnimatedSprite3D" parent="Actors/Caretaker of Saints" index="0"]
|
[node name="AnimatedSprite3D" parent="Actors/Caretaker of Saints" index="0"]
|
||||||
texture_filter = 0
|
texture_filter = 0
|
||||||
@@ -2818,21 +2822,29 @@ surface_material_override/0 = SubResource("StandardMaterial3D_gdgdy")
|
|||||||
|
|
||||||
[node name="SteleA" parent="Actors" instance=ExtResource("61_v60tm")]
|
[node name="SteleA" parent="Actors" instance=ExtResource("61_v60tm")]
|
||||||
transform = Transform3D(-2.02763, 0, -1.00137, 0, 2.26142, 0, 1.00137, 0, -2.02763, -269.604, -2.12242, 368.855)
|
transform = Transform3D(-2.02763, 0, -1.00137, 0, 2.26142, 0, 1.00137, 0, -2.02763, -269.604, -2.12242, 368.855)
|
||||||
|
Dialogue = ExtResource("60_1b363")
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="SteleA2" parent="Actors" instance=ExtResource("61_v60tm")]
|
[node name="SteleA2" parent="Actors" instance=ExtResource("61_v60tm")]
|
||||||
transform = Transform3D(-1.0882, 0, 1.98238, 0, 2.26142, 0, -1.98238, 0, -1.0882, 109.541, -2.96568, -125.703)
|
transform = Transform3D(-1.0882, 0, 1.98238, 0, 2.26142, 0, -1.98238, 0, -1.0882, 109.541, -2.96568, -125.703)
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="SteleB" parent="Actors" instance=ExtResource("32_xqf5a")]
|
[node name="Stele B Test" parent="Actors" instance=ExtResource("32_xqf5a")]
|
||||||
transform = Transform3D(1.76809, 0, -1.40993, 0, 2.26142, 0, 1.40993, 0, 1.76809, -221.316, -2.14605, 87.2701)
|
transform = Transform3D(1.76809, 0, -1.40993, 0, 2.26142, 0, 1.40993, 0, 1.76809, -221.316, -2.14605, 87.2701)
|
||||||
|
Dialogue = ExtResource("60_1b363")
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="SteleA3" parent="Actors" instance=ExtResource("61_v60tm")]
|
[node name="SteleA3" parent="Actors" instance=ExtResource("61_v60tm")]
|
||||||
transform = Transform3D(-1.36936, 0, -1.79969, 0, 2.26142, 0, 1.79969, 0, -1.36936, -152.306, -2.54626, 264.978)
|
transform = Transform3D(-1.36936, 0, -1.79969, 0, 2.26142, 0, 1.79969, 0, -1.36936, -152.306, -2.54626, 264.978)
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="SteleE" parent="Actors" instance=ExtResource("62_o5pdk")]
|
[node name="SteleE" parent="Actors" instance=ExtResource("62_o5pdk")]
|
||||||
transform = Transform3D(0.868668, 0, -0.723823, 0, 1.13071, 0, 0.723823, 0, 0.868668, -301.766, -2.71211, 324.165)
|
transform = Transform3D(0.868668, 0, -0.723823, 0, 1.13071, 0, 0.723823, 0, 0.868668, -301.766, -2.71211, 324.165)
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="SteleA4" parent="Actors" instance=ExtResource("61_v60tm")]
|
[node name="SteleA4" parent="Actors" instance=ExtResource("61_v60tm")]
|
||||||
transform = Transform3D(2.24285, 0, 0.289188, 0, 2.26142, 0, -0.289188, 0, 2.24285, -158.475, -2.35288, 110.031)
|
transform = Transform3D(2.24285, 0, 0.289188, 0, 2.26142, 0, -0.289188, 0, 2.24285, -158.475, -2.35288, 110.031)
|
||||||
|
ID = null
|
||||||
|
|
||||||
[node name="Lighting And Environment" type="Node3D" parent="."]
|
[node name="Lighting And Environment" type="Node3D" parent="."]
|
||||||
transform = Transform3D(0.66, 0, 0, 0, 0.66, 0, 0, 0, 0.66, -293.644, -2.57557, 69.8565)
|
transform = Transform3D(0.66, 0, 0, 0, 0.66, 0, 0, 0, 0.66, -293.644, -2.57557, 69.8565)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Chickensoft.AutoInject;
|
using Chickensoft.AutoInject;
|
||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Zennysoft.Game.Ma;
|
namespace Zennysoft.Game.Ma;
|
||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
@@ -8,6 +9,8 @@ public partial class Npc : Node3D
|
|||||||
{
|
{
|
||||||
public override void _Notification(int what) => this.Notify(what);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
|
[Dependency] public IGame _game => this.DependOn<IGame>();
|
||||||
|
|
||||||
[Node] public Area3D DialogueZone { get; set; } = default!;
|
[Node] public Area3D DialogueZone { get; set; } = default!;
|
||||||
|
|
||||||
[Node] public Area3D DialogueExitZone { get; set; } = default!;
|
[Node] public Area3D DialogueExitZone { get; set; } = default!;
|
||||||
@@ -20,6 +23,8 @@ public partial class Npc : Node3D
|
|||||||
private bool _isInDialogueZone = false;
|
private bool _isInDialogueZone = false;
|
||||||
private bool _isIntroductionComplete = false;
|
private bool _isIntroductionComplete = false;
|
||||||
|
|
||||||
|
public int ID { get; private set; } = 0;
|
||||||
|
|
||||||
public void OnReady()
|
public void OnReady()
|
||||||
{
|
{
|
||||||
SetPhysicsProcess(true);
|
SetPhysicsProcess(true);
|
||||||
@@ -27,6 +32,7 @@ public partial class Npc : Node3D
|
|||||||
DialogueZone.BodyExited += DialogueZone_BodyExited;
|
DialogueZone.BodyExited += DialogueZone_BodyExited;
|
||||||
DialogueExitZone.BodyExited += DialogueExitZone_BodyExited;
|
DialogueExitZone.BodyExited += DialogueExitZone_BodyExited;
|
||||||
Hitbox.AreaEntered += Hitbox_AreaEntered;
|
Hitbox.AreaEntered += Hitbox_AreaEntered;
|
||||||
|
ID = GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Hitbox_AreaEntered(Area3D area)
|
private void Hitbox_AreaEntered(Area3D area)
|
||||||
@@ -57,7 +63,16 @@ public partial class Npc : Node3D
|
|||||||
{
|
{
|
||||||
if (Dialogue != null && @event.IsActionPressed(GameInputs.Interact) && _isInDialogueZone)
|
if (Dialogue != null && @event.IsActionPressed(GameInputs.Interact) && _isInDialogueZone)
|
||||||
{
|
{
|
||||||
DialogueController.ShowDialogue(Dialogue, "general");
|
DialogueController.ShowDialogue(Dialogue, "general", [this]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task EndDialogue()
|
||||||
|
{
|
||||||
|
if (!_game.NpcData.SteleDiscovered.Contains(ID))
|
||||||
|
{
|
||||||
|
_game.NpcData.SteleDiscovered.Add(ID);
|
||||||
|
await _game.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,4 +83,6 @@ public partial class Npc : Node3D
|
|||||||
DialogueExitZone.BodyExited -= DialogueExitZone_BodyExited;
|
DialogueExitZone.BodyExited -= DialogueExitZone_BodyExited;
|
||||||
Hitbox.AreaEntered -= Hitbox_AreaEntered;
|
Hitbox.AreaEntered -= Hitbox_AreaEntered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode() => GetPath().GetHashCode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
~ general
|
~ general
|
||||||
|
ID is {{ID}}
|
||||||
|
do EndDialogue()
|
||||||
=> END
|
=> END
|
||||||
Reference in New Issue
Block a user