Add NotificationManager and NotificationLabel for age advancement notifications; refactor scripts into Components directory

This commit is contained in:
2025-08-23 04:54:45 +02:00
parent 5719c3f920
commit 9cf707945b
26 changed files with 96 additions and 68 deletions

View File

@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using Godot;
using ParasiticGod.Scripts.Core;
using ParasiticGod.Scripts;
using ParasiticGod.Scripts.Core.Effects;
using ParasiticGod.Scripts.Singletons;
namespace ParasiticGod.Scripts;
namespace ParasiticGod.Scripts.Components;
[GlobalClass]
public partial class ActiveBuffsManager : Node

View File

@@ -5,7 +5,7 @@ using Godot;
using ParasiticGod.Scripts.Core;
using ParasiticGod.Scripts.Singletons;
namespace ParasiticGod.Scripts;
namespace ParasiticGod.Scripts.Components;
[GlobalClass]
public partial class ForestVisualizer : Node

View File

@@ -0,0 +1,31 @@
using Godot;
using ParasiticGod.Scripts;
using ParasiticGod.Scripts.Singletons;
namespace ParasiticGod.Scripts.Components;
[GlobalClass]
public partial class NotificationManager : CanvasLayer
{
[Export] private PackedScene _notificationLabelScene;
public override void _Ready()
{
GameBus.Instance.AgeAdvanced += OnAgeAdvanced;
}
public override void _ExitTree()
{
if (GameBus.Instance != null)
{
GameBus.Instance.AgeAdvanced -= OnAgeAdvanced;
}
}
private void OnAgeAdvanced(string ageName)
{
var notification = _notificationLabelScene.Instantiate<NotificationLabel>();
AddChild(notification);
notification.ShowNotification($"You have entered\n{ageName}!");
}
}

View File

@@ -0,0 +1 @@
uid://c6uh5h3sdlg7n

View File

@@ -4,7 +4,7 @@ using Godot.Collections;
using ParasiticGod.Scripts.Core;
using ParasiticGod.Scripts.Singletons;
namespace ParasiticGod.Scripts;
namespace ParasiticGod.Scripts.Components;
[GlobalClass]
public partial class PopulationVisualizer : Node

View File

@@ -0,0 +1 @@
uid://m3qqshwpk16h

View File

@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Godot;
using ParasiticGod.Scripts.Core;
using ParasiticGod.Scripts.Singletons;
namespace ParasiticGod.Scripts;
namespace ParasiticGod.Scripts.Components;
[GlobalClass]
public partial class RoadManager : Node2D

View File

@@ -14,6 +14,7 @@ public partial class MiracleDefinition : Resource
[Export] public double FaithCost { get; set; }
[Export] public long FollowersRequired { get; set; }
[Export] public double ProductionRequired { get; set; }
public string AdvancesToAge { get; set; }
[Export] public Array<Effect> Effects { get; set; }
}

View File

@@ -6,6 +6,7 @@ namespace ParasiticGod.Scripts.Core;
public class EffectDto
{
public string Type { get; set; }
// --- For "AddResource" Effect ---
public Stat TargetResource { get; set; }
public double Value { get; set; }
@@ -19,11 +20,11 @@ public class EffectDto
public double FromAmount { get; set; }
public Stat ToResource { get; set; }
public double ToAmount { get; set; }
// --- For "ModifyStat" Effect ---
public Stat TargetStat { get; set; }
public ModifyStatEffect.Operation Op { get; set; }
public List<string> MiraclesToUnlock { get; set; }
}
@@ -34,5 +35,6 @@ public class MiracleDto
public long FollowersRequired { get; set; }
public double ProductionRequired { get; set; }
public bool UnlockedByDefault { get; set; }
public string AdvancesToAge { get; set; }
public List<EffectDto> Effects { get; set; }
}

View File

@@ -70,6 +70,7 @@ public static class MiracleLoader
FaithCost = miracleDto.FaithCost,
FollowersRequired = miracleDto.FollowersRequired,
ProductionRequired = miracleDto.ProductionRequired,
AdvancesToAge = miracleDto.AdvancesToAge,
Effects = []
};

View File

@@ -0,0 +1,20 @@
using Godot;
namespace ParasiticGod.Scripts;
[GlobalClass]
public partial class NotificationLabel : Label
{
public void ShowNotification(string text)
{
Text = text;
PivotOffset = Size / 2;
GlobalPosition = GetViewportRect().Size / 2;
var tween = CreateTween();
tween.TweenProperty(this, "modulate:a", 1.0f, 0.5f).From(0.0f);
tween.TweenInterval(2.5f);
tween.TweenProperty(this, "modulate:a", 0.0f, 1.0f);
tween.Finished += QueueFree;
}
}

View File

@@ -0,0 +1 @@
uid://drx8lqcjq5khj

View File

@@ -21,6 +21,7 @@ public partial class GameBus : Node
public event Action<Buff> BuffAdded;
public event Action<Buff> BuffRemoved;
public event Action PopulationVisualsUpdated;
public event Action<string> AgeAdvanced;
public override void _EnterTree()
{
@@ -74,6 +75,11 @@ public partial class GameBus : Node
{
MiraclesUnlocked?.Invoke(miraclesToUnlock);
}
if (!string.IsNullOrEmpty(miracle.AdvancesToAge))
{
AgeAdvanced?.Invoke(miracle.AdvancesToAge);
}
}
}