energy and stuff

This commit is contained in:
2026-06-18 21:43:37 +02:00
parent 7d7c225700
commit 6c1406c0bb
19 changed files with 222 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.6.3"> <Project Sdk="Godot.NET.Sdk/4.7.0">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net10.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework> <TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ds1idectpqbnh"
path="res://.godot/imported/energy_storage_nodule.png-8b9cceae16c6a594bcabd40d923a5bda.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/energy_storage_nodule.png"
dest_files=["res://.godot/imported/energy_storage_nodule.png-8b9cceae16c6a594bcabd40d923a5bda.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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

Before

Width:  |  Height:  |  Size: 603 B

After

Width:  |  Height:  |  Size: 603 B

View File

@@ -3,15 +3,15 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://cecg47efx7gw8" uid="uid://cecg47efx7gw8"
path="res://.godot/imported/Sprite-0001.png-301f2c522e57282b7df856433eb0ee72.ctex" path="res://.godot/imported/simple_nodule.png-25c9af6e4b92938e989dd529efe4fd03.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://assets/Sprite-0001.png" source_file="res://assets/simple_nodule.png"
dest_files=["res://.godot/imported/Sprite-0001.png-301f2c522e57282b7df856433eb0ee72.ctex"] dest_files=["res://.godot/imported/simple_nodule.png-25c9af6e4b92938e989dd529efe4fd03.ctex"]
[params] [params]

View File

@@ -12,7 +12,7 @@ config_version=5
config/name="Slimepire" config/name="Slimepire"
run/main_scene="uid://drxbsnqoi4wmw" run/main_scene="uid://drxbsnqoi4wmw"
config/features=PackedStringArray("4.6", "C#", "Forward Plus") config/features=PackedStringArray("4.7", "C#", "Forward Plus")
config/icon="res://assets/icon.svg" config/icon="res://assets/icon.svg"
[audio] [audio]
@@ -73,4 +73,8 @@ cam_down={
[rendering] [rendering]
textures/canvas_textures/default_texture_filter=0
rendering_device/driver.windows="d3d12" rendering_device/driver.windows="d3d12"
textures/default_filters/use_nearest_mipmap_filter=true
textures/decals/filter=2
textures/light_projectors/filter=2

View File

@@ -0,0 +1,6 @@
using Godot;
namespace Slimepire.Core;
[ResourceTree("/src/Data")]
public static partial class GameResources;

View File

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

View File

@@ -0,0 +1,41 @@
[gd_resource type="Resource" script_class="NoduleResource" format=3 uid="uid://0d8vif4ejtp1"]
[ext_resource type="Texture2D" uid="uid://ds1idectpqbnh" path="res://assets/energy_storage_nodule.png" id="1_237jx"]
[ext_resource type="Script" uid="uid://bnf6qmk64i2wj" path="res://src/Data/NoduleResource.cs" id="2_dusyu"]
[sub_resource type="AtlasTexture" id="AtlasTexture_dusyu"]
atlas = ExtResource("1_237jx")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_rmsh8"]
atlas = ExtResource("1_237jx")
region = Rect2(32, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_lmxtc"]
atlas = ExtResource("1_237jx")
region = Rect2(64, 0, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_j6wbi"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_dusyu")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_rmsh8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lmxtc")
}],
"loop": 1,
"name": &"default",
"speed": 5.0
}]
[resource]
script = ExtResource("2_dusyu")
SpriteFrames = SubResource("SpriteFrames_j6wbi")
Color = Color(0.60033447, 0.5019659, 0.0981792, 1)
NoduleName = "Energy Nodule"
MaxEnergy = 100.0
metadata/_custom_type_script = "uid://bnf6qmk64i2wj"

View File

@@ -0,0 +1,22 @@
using Godot;
namespace Slimepire.Data;
[GlobalClass]
public partial class NoduleResource : Resource
{
[Export]
public SpriteFrames SpriteFrames;
[Export]
public Color Color;
[Export]
public string NoduleName = "Nodule";
[Export]
public float MaxEnergy;
[Export]
public float EnergyRegenRate;
}

View File

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

View File

@@ -0,0 +1,42 @@
[gd_resource type="Resource" script_class="NoduleResource" format=3 uid="uid://5gk0giodp6g"]
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="1_j6wbi"]
[ext_resource type="Script" uid="uid://bnf6qmk64i2wj" path="res://src/Data/NoduleResource.cs" id="1_otepm"]
[sub_resource type="AtlasTexture" id="AtlasTexture_j6wbi"]
atlas = ExtResource("1_j6wbi")
region = Rect2(0, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_q8pab"]
atlas = ExtResource("1_j6wbi")
region = Rect2(64, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_dh8qd"]
atlas = ExtResource("1_j6wbi")
region = Rect2(32, 0, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_x44k2"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_j6wbi")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_q8pab")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dh8qd")
}],
"loop": 1,
"name": &"default",
"speed": 3.0
}]
[resource]
script = ExtResource("1_otepm")
SpriteFrames = SubResource("SpriteFrames_x44k2")
Color = Color(0.2642648, 0.46582836, 0.36528692, 1)
NoduleName = "Simple Nodule"
MaxEnergy = 2.0
EnergyRegenRate = 0.1
metadata/_custom_type_script = "uid://bnf6qmk64i2wj"

View File

@@ -1,4 +1,6 @@
using Godot; using Godot;
using Slimepire.Core;
using Slimepire.Data;
using Slimepire.Gameplay.Nodules; using Slimepire.Gameplay.Nodules;
namespace Slimepire.Gameplay; namespace Slimepire.Gameplay;
@@ -80,6 +82,10 @@ public partial class BuildGhost : Node2D
var nodule = Instantiator.Instantiate<Nodule>(); var nodule = Instantiator.Instantiate<Nodule>();
nodule.Position = Position; nodule.Position = Position;
nodule.NoduleResource = GD.Load<NoduleResource>(
GameResources.SimpleNoduleTres.ResourcePath
);
GetParent()?.AddChild(nodule); GetParent()?.AddChild(nodule);
foreach (var (_, tube) in _connectedTubes) foreach (var (_, tube) in _connectedTubes)

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://c3n70a52kk34f"] [gd_scene format=3 uid="uid://c3n70a52kk34f"]
[ext_resource type="Script" uid="uid://ck5yw760bu8sb" path="res://src/Gameplay/BuildGhost.cs" id="1_ahcoi"] [ext_resource type="Script" uid="uid://ck5yw760bu8sb" path="res://src/Gameplay/BuildGhost.cs" id="1_ahcoi"]
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/Sprite-0001.png" id="2_uo42j"] [ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_uo42j"]
[ext_resource type="AudioStream" uid="uid://mj8wvuwfc6o7" path="res://assets/sfx/tube_disconnect.wav" id="3_nxaxp"] [ext_resource type="AudioStream" uid="uid://mj8wvuwfc6o7" path="res://assets/sfx/tube_disconnect.wav" id="3_nxaxp"]
[ext_resource type="AudioStream" uid="uid://bxxi7grsubvgm" path="res://assets/sfx/tube_connect.wav" id="3_quiac"] [ext_resource type="AudioStream" uid="uid://bxxi7grsubvgm" path="res://assets/sfx/tube_connect.wav" id="3_quiac"]

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,7 @@
using System.Diagnostics;
using Godot; using Godot;
using Slimepire.Core;
using Slimepire.Data;
namespace Slimepire.Gameplay.Nodules; namespace Slimepire.Gameplay.Nodules;
@@ -10,11 +13,19 @@ public partial class Nodule : Node2D
public readonly List<Nodule> Connections = []; public readonly List<Nodule> Connections = [];
[Export]
public required NoduleResource NoduleResource;
private float energy = 0;
// todo remove? // todo remove?
private bool _isExpanding; private bool _isExpanding;
public override void _Ready() public override void _Ready()
{ {
Gfx.SpriteFrames = NoduleResource.SpriteFrames;
Gfx.SelfModulate = NoduleResource.Color;
ClickArea.MouseEntered += ClickAreaOnMouseEntered; ClickArea.MouseEntered += ClickAreaOnMouseEntered;
ClickArea.MouseExited += ClickAreaOnMouseExited; ClickArea.MouseExited += ClickAreaOnMouseExited;
@@ -24,6 +35,16 @@ public partial class Nodule : Node2D
NoduleManager.Instance.RegisterNodule(this); NoduleManager.Instance.RegisterNodule(this);
} }
public override void _Process(double delta)
{
if (energy < NoduleResource.MaxEnergy)
{
energy += NoduleResource.EnergyRegenRate * (float)delta;
}
EnergyLabel.Text = energy.ToString("F2");
}
private void TubeConnectionAreaOnAreaEntered(Area2D area) private void TubeConnectionAreaOnAreaEntered(Area2D area)
{ {
if (area.GetParent() is Nodule nodule) if (area.GetParent() is Nodule nodule)
@@ -75,7 +96,6 @@ public partial class Nodule : Node2D
var ghost = Instantiator.Instantiate<BuildGhost>(); var ghost = Instantiator.Instantiate<BuildGhost>();
ghost.Position = Position; ghost.Position = Position;
// ghost.OnBuild += OnBuildComplete;
GetParent()?.AddChild(ghost); GetParent()?.AddChild(ghost);
} }

View File

@@ -1,7 +1,7 @@
[gd_scene format=3 uid="uid://cnl6t8o4mh0j3"] [gd_scene format=3 uid="uid://cnl6t8o4mh0j3"]
[ext_resource type="Script" uid="uid://cmpl0if164dba" path="res://src/Gameplay/Nodules/Nodule.cs" id="1_yembh"] [ext_resource type="Script" uid="uid://cmpl0if164dba" path="res://src/Gameplay/Nodules/Nodule.cs" id="1_yembh"]
[ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/Sprite-0001.png" id="2_7qt20"] [ext_resource type="Texture2D" uid="uid://cecg47efx7gw8" path="res://assets/simple_nodule.png" id="2_7qt20"]
[ext_resource type="PackedScene" uid="uid://c11xdoiv2ch3w" path="res://src/Gameplay/Nodules/Mitochondria.tscn" id="3_x44k2"] [ext_resource type="PackedScene" uid="uid://c11xdoiv2ch3w" path="res://src/Gameplay/Nodules/Mitochondria.tscn" id="3_x44k2"]
[sub_resource type="CircleShape2D" id="CircleShape2D_7qt20"] [sub_resource type="CircleShape2D" id="CircleShape2D_7qt20"]
@@ -31,7 +31,7 @@ animations = [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_inlcu") "texture": SubResource("AtlasTexture_inlcu")
}], }],
"loop": true, "loop": 1,
"name": &"default", "name": &"default",
"speed": 2.0 "speed": 2.0
}] }]
@@ -39,6 +39,13 @@ animations = [{
[sub_resource type="CircleShape2D" id="CircleShape2D_x44k2"] [sub_resource type="CircleShape2D" id="CircleShape2D_x44k2"]
radius = 96.38 radius = 96.38
[sub_resource type="LabelSettings" id="LabelSettings_x44k2"]
font_size = 12
outline_size = 3
outline_color = Color(0, 0, 0, 1)
shadow_size = 3
shadow_color = Color(0, 0, 0, 1)
[node name="Nodule" type="Node2D" unique_id=1637542829] [node name="Nodule" type="Node2D" unique_id=1637542829]
z_index = 1 z_index = 1
script = ExtResource("1_yembh") script = ExtResource("1_yembh")
@@ -49,8 +56,8 @@ unique_name_in_owner = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="ClickArea" unique_id=2005066434] [node name="CollisionShape2D" type="CollisionShape2D" parent="ClickArea" unique_id=2005066434]
shape = SubResource("CircleShape2D_7qt20") shape = SubResource("CircleShape2D_7qt20")
[node name="Blob" type="AnimatedSprite2D" parent="." unique_id=190397869] [node name="Gfx" type="AnimatedSprite2D" parent="." unique_id=190397869]
modulate = Color(0.34855, 0.6165254, 0.5102762, 1) unique_name_in_owner = true
texture_filter = 1 texture_filter = 1
sprite_frames = SubResource("SpriteFrames_xyjsl") sprite_frames = SubResource("SpriteFrames_xyjsl")
autoplay = "default" autoplay = "default"
@@ -67,3 +74,20 @@ shape = SubResource("CircleShape2D_x44k2")
debug_color = Color(0.38922516, 0.6054754, 0.25354394, 0.41960785) debug_color = Color(0.38922516, 0.6054754, 0.25354394, 0.41960785)
[node name="Mitochondria" parent="." unique_id=954228490 instance=ExtResource("3_x44k2")] [node name="Mitochondria" parent="." unique_id=954228490 instance=ExtResource("3_x44k2")]
process_mode = 4
visible = false
[node name="EnergyLabel" type="Label" parent="." unique_id=466024399]
unique_name_in_owner = true
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -20.0
offset_top = 14.0
offset_right = 20.0
offset_bottom = 31.0
grow_horizontal = 2
text = "5"
label_settings = SubResource("LabelSettings_x44k2")
horizontal_alignment = 1
vertical_alignment = 1

View File

@@ -3,6 +3,7 @@
[ext_resource type="Script" uid="uid://c8l12dlpexosv" path="res://src/Levels/DemoLevel.cs" id="1_l2cn0"] [ext_resource type="Script" uid="uid://c8l12dlpexosv" path="res://src/Levels/DemoLevel.cs" id="1_l2cn0"]
[ext_resource type="Script" uid="uid://cdgi3y0sm3rt1" path="res://src/Gameplay/Camera.cs" id="2_mxa1b"] [ext_resource type="Script" uid="uid://cdgi3y0sm3rt1" path="res://src/Gameplay/Camera.cs" id="2_mxa1b"]
[ext_resource type="PackedScene" uid="uid://cnl6t8o4mh0j3" path="res://src/Gameplay/Nodules/Nodule.tscn" id="3_qhkhc"] [ext_resource type="PackedScene" uid="uid://cnl6t8o4mh0j3" path="res://src/Gameplay/Nodules/Nodule.tscn" id="3_qhkhc"]
[ext_resource type="Resource" uid="uid://0d8vif4ejtp1" path="res://src/Data/EnergyStorageNodule.tres" id="4_yyao7"]
[sub_resource type="LabelSettings" id="LabelSettings_l2cn0"] [sub_resource type="LabelSettings" id="LabelSettings_l2cn0"]
font_size = 107 font_size = 107
@@ -29,4 +30,4 @@ text = "DEMO LEVEL"
label_settings = SubResource("LabelSettings_l2cn0") label_settings = SubResource("LabelSettings_l2cn0")
[node name="Nodule" parent="." unique_id=1637542829 instance=ExtResource("3_qhkhc")] [node name="Nodule" parent="." unique_id=1637542829 instance=ExtResource("3_qhkhc")]
IsRoot = true NoduleResource = ExtResource("4_yyao7")