Compare commits

...

2 Commits

17 changed files with 214 additions and 43 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c88ltenh4ghit"
path="res://.godot/imported/hut_tier_1.png-95c994b0565c43d199344569cb1a91ab.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Mods/Tiers/Huts/hut_tier_1.png"
dest_files=["res://.godot/imported/hut_tier_1.png-95c994b0565c43d199344569cb1a91ab.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cgoigfok3s0fc"
path="res://.godot/imported/hut_tier_2.png-7e373825ef1bbf63f359ae57d709b394.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Mods/Tiers/Huts/hut_tier_2.png"
dest_files=["res://.godot/imported/hut_tier_2.png-7e373825ef1bbf63f359ae57d709b394.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bxlaf72h3pftt"
path="res://.godot/imported/hut_tier_1.png-4ce775c649cfe5f92a10187bc1930a9b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Mods/Tiers/hut_tier_1.png"
dest_files=["res://.godot/imported/hut_tier_1.png-4ce775c649cfe5f92a10187bc1930a9b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cj7bgonxgavdf"
path="res://.godot/imported/hut_tier_2.png-70fb7df6fa976626a267fd1e203d6a0e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Mods/Tiers/hut_tier_2.png"
dest_files=["res://.godot/imported/hut_tier_2.png-70fb7df6fa976626a267fd1e203d6a0e.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -3,17 +3,14 @@
{ {
"tierEnum": "Tier1", "tierEnum": "Tier1",
"threshold": 150, "threshold": 150,
"scenePath": "res://Scenes/Huts/hut_tier_1.tscn" "imagePath": "user://Mods/Tiers/Huts/hut_tier_1.png",
"scale": {"x": 0.01, "y": 0.01}
}, },
{ {
"tierEnum": "Tier2", "tierEnum": "Tier2",
"threshold": 750, "threshold": 750,
"scenePath": "res://Scenes/Huts/hut_tier_2.tscn" "imagePath": "user://Mods/Tiers/Huts/hut_tier_2.png",
}, "scale": {"x": 0.01, "y": 0.01}
{
"tierEnum": "Tier3",
"threshold": 2000,
"scenePath": "res://Scenes/Huts/hut_tier_3.tscn"
} }
] ]
} }

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=20 format=3 uid="uid://bfil8sd154327"] [gd_scene load_steps=21 format=3 uid="uid://bfil8sd154327"]
[ext_resource type="Script" uid="uid://t71ewkpa5uqs" path="res://Scenes/Main/Main.cs" id="1_p8rbg"] [ext_resource type="Script" uid="uid://t71ewkpa5uqs" path="res://Scenes/Main/Main.cs" id="1_p8rbg"]
[ext_resource type="Script" uid="uid://b77vh831r1e3c" path="res://Scenes/Main/MiraclePanel.cs" id="2_hcu3t"] [ext_resource type="Script" uid="uid://b77vh831r1e3c" path="res://Scenes/Main/MiraclePanel.cs" id="2_hcu3t"]
@@ -16,6 +16,7 @@
[ext_resource type="PackedScene" uid="uid://8w7tvsgkev1y" path="res://Scenes/tree.tscn" id="8_hcu3t"] [ext_resource type="PackedScene" uid="uid://8w7tvsgkev1y" path="res://Scenes/tree.tscn" id="8_hcu3t"]
[ext_resource type="Shader" uid="uid://bf8nk145fjkgh" path="res://Shaders/corruption_shader.gdshader" id="9_wgovn"] [ext_resource type="Shader" uid="uid://bf8nk145fjkgh" path="res://Shaders/corruption_shader.gdshader" id="9_wgovn"]
[ext_resource type="PackedScene" uid="uid://cqkye7yykakns" path="res://Scenes/Followers/FollowerMarker.tscn" id="11_5ci8a"] [ext_resource type="PackedScene" uid="uid://cqkye7yykakns" path="res://Scenes/Followers/FollowerMarker.tscn" id="11_5ci8a"]
[ext_resource type="PackedScene" uid="uid://xk2xirjd1sma" path="res://Scenes/moddable_visual.tscn" id="17_qdkat"]
[ext_resource type="Script" uid="uid://furbvcmw31bx" path="res://Scripts/Components/ForestVisualizer.cs" id="18_qdkat"] [ext_resource type="Script" uid="uid://furbvcmw31bx" path="res://Scripts/Components/ForestVisualizer.cs" id="18_qdkat"]
[ext_resource type="Script" uid="uid://cw8gpeaq3yfjn" path="res://Scripts/Components/RoadManager.cs" id="19_qdkat"] [ext_resource type="Script" uid="uid://cw8gpeaq3yfjn" path="res://Scripts/Components/RoadManager.cs" id="19_qdkat"]
@@ -5549,6 +5550,7 @@ position = Vector2(243.12, -124.88)
script = ExtResource("8_cv8e0") script = ExtResource("8_cv8e0")
_markersContainer = NodePath("../Followers Markers") _markersContainer = NodePath("../Followers Markers")
_unitsPerMarker = 1 _unitsPerMarker = 1
_moddableVisualScene = ExtResource("17_qdkat")
metadata/_custom_type_script = "uid://dj2wyrq07gfp2" metadata/_custom_type_script = "uid://dj2wyrq07gfp2"
[node name="HutPopulationVisualizer" type="Node" parent="." node_paths=PackedStringArray("_markersContainer")] [node name="HutPopulationVisualizer" type="Node" parent="." node_paths=PackedStringArray("_markersContainer")]
@@ -5556,6 +5558,7 @@ script = ExtResource("8_cv8e0")
_markersContainer = NodePath("../Hut Markers") _markersContainer = NodePath("../Hut Markers")
_unitsPerMarker = 1 _unitsPerMarker = 1
Category = 1 Category = 1
_moddableVisualScene = ExtResource("17_qdkat")
metadata/_custom_type_script = "uid://dj2wyrq07gfp2" metadata/_custom_type_script = "uid://dj2wyrq07gfp2"
[node name="ForestVisualizer" type="Node" parent="." node_paths=PackedStringArray("_treesContainer")] [node name="ForestVisualizer" type="Node" parent="." node_paths=PackedStringArray("_treesContainer")]

View File

@@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://xk2xirjd1sma"]
[ext_resource type="Script" uid="uid://dpfcbaqgq3l6d" path="res://Scripts/Components/ModdableVisual.cs" id="1_5b1dg"]
[node name="ModdableVisual" type="Node2D" node_paths=PackedStringArray("_sprite")]
script = ExtResource("1_5b1dg")
_sprite = NodePath("Sprite")
[node name="Sprite" type="Sprite2D" parent="."]

View File

@@ -0,0 +1,28 @@
using Godot;
namespace ParasiticGod.Scripts.Components;
[GlobalClass]
public partial class ModdableVisual : Node2D
{
[Export] private Sprite2D _sprite;
public Follower.FollowerTier Tier { get; private set; }
public override void _ExitTree()
{
if (_sprite != null)
{
_sprite.Texture = null;
}
}
public void Initialize(Follower.FollowerTier tier, Texture2D texture, Vector2 scale)
{
Tier = tier;
if (_sprite != null && texture != null)
{
_sprite.Texture = texture;
_sprite.Scale = scale;
}
}
}

View File

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

View File

@@ -14,6 +14,7 @@ public partial class PopulationVisualizer : Node
[Export] private Node2D _markersContainer; [Export] private Node2D _markersContainer;
[Export] private int _unitsPerMarker = 5; [Export] private int _unitsPerMarker = 5;
[Export] public VisualCategory Category { get; private set; } [Export] public VisualCategory Category { get; private set; }
[Export] private PackedScene _moddableVisualScene;
private List<TierDefinition> _tiers; private List<TierDefinition> _tiers;
private readonly List<FollowerMarker> _markers = []; private readonly List<FollowerMarker> _markers = [];
@@ -105,19 +106,23 @@ public partial class PopulationVisualizer : Node
if (i < followersToShow) if (i < followersToShow)
{ {
if (!marker.IsOccupied || _lastKnownTierIndex != newTierIndex) var currentVisual = marker.GetChildOrNull<ModdableVisual>(0);
if (currentVisual == null || currentVisual.Tier != currentTier.TierEnum)
{ {
if (marker.IsOccupied) marker.RemoveFollower(); if (marker.GetChildCount() > 0) marker.GetChild(0).QueueFree();
var followerInstance = currentTier.Scene.Instantiate<Follower>();
marker.PlaceFollower(followerInstance); var visualInstance = _moddableVisualScene.Instantiate<ModdableVisual>();
visualInstance.Initialize(currentTier.TierEnum, currentTier.Texture, currentTier.Scale);
marker.AddChild(visualInstance);
needsChange = true; needsChange = true;
} }
} }
else else
{ {
if (marker.IsOccupied) if (marker.GetChildCount() > 0)
{ {
marker.RemoveFollower(); marker.GetChild(0).QueueFree();
needsChange = true; needsChange = true;
} }
} }

View File

@@ -45,15 +45,16 @@ public partial class RoadManager : Node2D
_roadNetwork.ClearPoints(); _roadNetwork.ClearPoints();
var activeMarkers = _markersContainer.GetChildren() var activeMarkers = _markersContainer.GetChildren()
.OfType<FollowerMarker>() .OfType<Marker2D>() // We can just look for any Marker2D
.Where(m => m.IsOccupied && m.FollowerInstance != null && .Select(m => new { Marker = m, Visual = m.GetChildOrNull<ModdableVisual>(0) })
m.FollowerInstance.Tier >= _minimumTierForRoads) .Where(mv => mv.Visual != null && mv.Visual.Tier >= _minimumTierForRoads)
.Select(mv => mv.Marker)
.ToList(); .ToList();
if (activeMarkers.Count < 2) return; if (activeMarkers.Count < 2) return;
var treeNodes = new HashSet<FollowerMarker>(); var treeNodes = new HashSet<Node2D>();
var remainingNodes = new List<FollowerMarker>(activeMarkers); var remainingNodes = new List<Node2D>(activeMarkers);
var edges = new List<(Vector2, Vector2)>(); var edges = new List<(Vector2, Vector2)>();
var startNode = remainingNodes[0]; var startNode = remainingNodes[0];
@@ -62,8 +63,8 @@ public partial class RoadManager : Node2D
while (remainingNodes.Any()) while (remainingNodes.Any())
{ {
FollowerMarker bestSource = null; Node2D bestSource = null;
FollowerMarker bestDest = null; Node2D bestDest = null;
var minDistanceSq = float.MaxValue; var minDistanceSq = float.MaxValue;
foreach (var source in treeNodes) foreach (var source in treeNodes)

View File

@@ -5,7 +5,8 @@ namespace ParasiticGod.Scripts.Core;
[GlobalClass] [GlobalClass]
public partial class TierDefinition : Resource public partial class TierDefinition : Resource
{ {
[Export] public PackedScene Scene { get; set; } [Export] public Texture2D Texture { get; set; }
[Export] public long Threshold { get; set; } [Export] public long Threshold { get; set; }
[Export] public Follower.FollowerTier TierEnum { get; set; } [Export] public Follower.FollowerTier TierEnum { get; set; }
[Export] public Vector2 Scale { get; set; } = Vector2.One;
} }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics;
namespace ParasiticGod.Scripts.Core; namespace ParasiticGod.Scripts.Core;
@@ -6,7 +7,8 @@ public class TierDto
{ {
public Follower.FollowerTier TierEnum { get; set; } public Follower.FollowerTier TierEnum { get; set; }
public long Threshold { get; set; } public long Threshold { get; set; }
public string ScenePath { get; set; } public string ImagePath { get; set; }
public Vector2 Scale { get; set; } = Vector2.One;
} }
public class TierListDto public class TierListDto

View File

@@ -27,11 +27,18 @@ public static class TierLoader
foreach (var dto in tierListDto.Tiers) foreach (var dto in tierListDto.Tiers)
{ {
var image = Image.LoadFromFile(dto.ImagePath);
if (image == null)
{
GD.PushError($"Failed to load image at path: {dto.ImagePath}");
continue;
}
var tierDef = new TierDefinition var tierDef = new TierDefinition
{ {
Threshold = dto.Threshold, Threshold = dto.Threshold,
TierEnum = dto.TierEnum, TierEnum = dto.TierEnum,
Scene = GD.Load<PackedScene>(dto.ScenePath) Texture = ImageTexture.CreateFromImage(image),
Scale = new Vector2(dto.Scale.X, dto.Scale.Y)
}; };
loadedTiers.Add(tierDef); loadedTiers.Add(tierDef);
} }

View File

@@ -5,23 +5,4 @@ namespace ParasiticGod.Scripts;
[GlobalClass] [GlobalClass]
public partial class FollowerMarker : Marker2D public partial class FollowerMarker : Marker2D
{ {
public bool IsOccupied { get; private set; }
public Follower FollowerInstance { get; private set; }
public void PlaceFollower(Follower followerInstance)
{
if (IsOccupied) return;
AddChild(followerInstance);
followerInstance.Position = Vector2.Zero;
IsOccupied = true;
FollowerInstance = followerInstance;
}
public void RemoveFollower()
{
if (!IsOccupied) return;
FollowerInstance.QueueFree();
FollowerInstance = null;
IsOccupied = false;
}
} }