Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save and load player inventory #31

Merged
merged 71 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
ec266db
Start loading files into editor
snipercup Nov 21, 2023
e9f5cc4
Add navigation from main menu
snipercup Nov 22, 2023
b2df2a1
Now able to create a new json file
snipercup Nov 22, 2023
b24fd03
More work on loading mapfiles
snipercup Nov 23, 2023
50f510d
Can now save and load maps in editor
snipercup Nov 23, 2023
cf5743a
Load custom levels into main menu
snipercup Nov 23, 2023
0676fe3
Fix scaling issue
snipercup Nov 23, 2023
4d92eea
Fix no scroll bug
snipercup Nov 24, 2023
94de13f
Added terraintile editor
snipercup Nov 24, 2023
a869594
Tile saving and loading works
snipercup Nov 25, 2023
5d62db0
Improved tile editor
snipercup Nov 25, 2023
cb77aed
Contenteditor adjusted sizing, tab control
snipercup Nov 26, 2023
306b9f8
Added categories to map editor
snipercup Nov 27, 2023
af4e1f2
Polishing
snipercup Nov 28, 2023
eebe6d3
Remove comments
snipercup Nov 28, 2023
9b7c849
Starting POC
snipercup Nov 28, 2023
d5836a2
Infinite panning now possible
snipercup Nov 29, 2023
16d4ad9
Now it's seamless
snipercup Nov 30, 2023
32e402a
Cleanup overmap script
snipercup Nov 30, 2023
9c1cfa0
Refactor file names json function
snipercup Dec 2, 2023
8e2f9d1
Switch level from overmap
snipercup Dec 3, 2023
866b2c4
Can switch levels in-game
snipercup Dec 3, 2023
a6e0691
Add gui elements to overmap
snipercup Dec 3, 2023
c513d77
Create gamedata singleton
snipercup Dec 3, 2023
2b11e38
Refactor some json loading
snipercup Dec 3, 2023
adf11f5
overmap is consistent
snipercup Dec 5, 2023
6ae5f43
Initial version of save load
snipercup Dec 5, 2023
3c6e92d
remove editor complaints
snipercup Dec 6, 2023
e2f8601
Added the selectable sprite custom widget
snipercup Dec 8, 2023
a459a66
Add mobeditor, refactor contentlist
snipercup Dec 10, 2023
01105d6
layout, bugfix
snipercup Dec 10, 2023
eb98a0a
small refactor of adding json items
snipercup Dec 10, 2023
143a3ba
Initial version of mob editor
snipercup Dec 10, 2023
e5632c0
fix map editor bug when creating new map
snipercup Dec 10, 2023
1f37269
Refactor editor data management
snipercup Dec 13, 2023
1592220
Update tiles.json to use sprite name
snipercup Dec 14, 2023
4d917aa
reintroduce slopes
snipercup Dec 15, 2023
f6925bb
Update markdownlabel
snipercup Dec 16, 2023
9bb4615
Limit input rect on tilegrid
snipercup Dec 16, 2023
cc6c8fb
Limit painting only to when drawing
snipercup Dec 16, 2023
e092de2
Add icons to replace text
snipercup Dec 17, 2023
f299775
Add brush preview
snipercup Dec 17, 2023
ae0cab2
Add rotation to mapeditor
snipercup Dec 17, 2023
5101f44
Tiles rotate in game
snipercup Dec 22, 2023
d7efa12
Add folder colors
snipercup Dec 22, 2023
667dfbc
Make another scripts folder green
snipercup Dec 22, 2023
89f1d20
Move sprites and scenes to defaults
snipercup Dec 23, 2023
fc8c2cb
remove extra scenes and sprites
snipercup Dec 23, 2023
2370da9
Moved the enemy corpse to defaults
snipercup Dec 23, 2023
3a90db2
Adjusted scenes to new paths
snipercup Dec 23, 2023
5bc423d
Remove extra tiles
snipercup Dec 23, 2023
35729f4
Remove extra sprites too
snipercup Dec 23, 2023
2c30049
Mapeditor allow mob painting
snipercup Dec 23, 2023
1eceb0f
Update scrapwalker64.png
snipercup Dec 23, 2023
f165150
Mob spawns on the block
snipercup Jan 2, 2024
e8f0c0b
Mob now has transparancy
snipercup Jan 4, 2024
d894cbf
remove commented code
snipercup Jan 4, 2024
4e49632
fix block save load
snipercup Jan 7, 2024
cd36a24
rename enemy to mob
snipercup Jan 7, 2024
6c7b0b7
Save and load mob and block rotation
snipercup Jan 7, 2024
9e84a84
Fix save initialization
snipercup Jan 8, 2024
653c517
Fix overmap coordinates
snipercup Jan 8, 2024
f337849
Rename level select to load game
snipercup Jan 9, 2024
c68672d
Change the load maps function
snipercup Jan 9, 2024
b745a2e
Add load game function
snipercup Jan 9, 2024
faab876
Initial load game implementation
snipercup Jan 9, 2024
517e484
Save the overmap too
snipercup Jan 9, 2024
b17d361
Properly save overmap
snipercup Jan 10, 2024
b107e5f
Return load game function
snipercup Jan 10, 2024
e89e5d5
Preserve player inventory between maps
snipercup Jan 12, 2024
f0ba3d5
Preserve player inventory across saves
snipercup Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions Blocks/Stairs_to_E001.tscn

This file was deleted.

20 changes: 0 additions & 20 deletions Blocks/Stairs_to_S001.tscn

This file was deleted.

20 changes: 0 additions & 20 deletions Blocks/Stairs_to_W001.tscn

This file was deleted.

18 changes: 0 additions & 18 deletions Blocks/concrete_wall001.tscn

This file was deleted.

18 changes: 0 additions & 18 deletions Blocks/concrete_wall002.tscn

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://buj4ukj1oh4pq"]

[ext_resource type="Texture2D" uid="uid://bu00lw1luehxr" path="res://Textures/Tiles/Actual textures/1.png" id="1_a2cuf"]
[ext_resource type="Texture2D" uid="uid://bu00lw1luehxr" path="res://Defaults/Sprites/1.png" id="1_a2cuf"]

[resource]
albedo_texture = ExtResource("1_a2cuf")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://pdqqtb1s8g6n"]

[ext_resource type="Texture2D" uid="uid://cyy4j5vso6khu" path="res://Textures/Tiles/Actual textures/4.png" id="1_rgn6b"]
[ext_resource type="Texture2D" uid="uid://cyy4j5vso6khu" path="res://Defaults/Sprites/4.png" id="1_rgn6b"]

[resource]
shading_mode = 0
Expand Down
4 changes: 4 additions & 0 deletions Blocks/grass_001.gd → Defaults/Blocks/default_block.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
extends StaticBody3D

var id: String = ""

func update_texture(material: BaseMaterial3D) -> void:
$MeshInstance3D.mesh = BoxMesh.new()
$MeshInstance3D.mesh.surface_set_material(0, material)

func get_texture_string() -> String:
return $MeshInstance3D.mesh.material.albedo_texture.resource_path
9 changes: 5 additions & 4 deletions Blocks/grass_001.tscn → Defaults/Blocks/default_block.tscn
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
[gd_scene load_steps=5 format=3 uid="uid://cpaa3ui52a23c"]

[ext_resource type="Material" uid="uid://buj4ukj1oh4pq" path="res://Materials/floor1.tres" id="1_tldl5"]
[ext_resource type="Script" path="res://Blocks/grass_001.gd" id="1_yge5h"]
[ext_resource type="Script" path="res://Defaults/Blocks/default_block.gd" id="1_s3i5a"]
[ext_resource type="Material" uid="uid://buj4ukj1oh4pq" path="res://Defaults/Blocks/Materials/floor1.tres" id="2_ukdu8"]

[sub_resource type="BoxMesh" id="BoxMesh_j05ve"]
material = ExtResource("1_tldl5")
material = ExtResource("2_ukdu8")

[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_gyg2o"]
points = PackedVector3Array(0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5)

[node name="Grass001" type="StaticBody3D" groups=["navigation_mesh_source_group"]]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0)
disable_mode = 1
script = ExtResource("1_yge5h")
script = ExtResource("1_s3i5a")

[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("BoxMesh_j05ve")
Expand Down
10 changes: 10 additions & 0 deletions Defaults/Blocks/default_slope.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends StaticBody3D

var id: String = ""

func update_texture(material: BaseMaterial3D) -> void:
$MeshInstance3D.mesh = BoxMesh.new()
$MeshInstance3D.mesh.surface_set_material(0, material)

func get_texture_string() -> String:
return $MeshInstance3D.mesh.material.albedo_texture.resource_path
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://dnsl5rk6de7na"]
[gd_scene load_steps=5 format=3 uid="uid://dnsl5rk6de7na"]

[ext_resource type="Material" uid="uid://pdqqtb1s8g6n" path="res://Materials/stairs1.tres" id="1_r8jiw"]
[ext_resource type="Script" path="res://Defaults/Blocks/default_slope.gd" id="1_x2ar8"]
[ext_resource type="Material" uid="uid://pdqqtb1s8g6n" path="res://Defaults/Blocks/Materials/stairs1.tres" id="2_qnimx"]

[sub_resource type="PrismMesh" id="PrismMesh_7xabc"]
material = ExtResource("1_r8jiw")
material = ExtResource("2_qnimx")
left_to_right = 1.0

[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_7isgt"]
Expand All @@ -12,8 +13,10 @@ points = PackedVector3Array(0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5,
[node name="StairsToN001" type="StaticBody3D" groups=["navigation_mesh_source_group"]]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0)
disable_mode = 1
script = ExtResource("1_x2ar8")

[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0)
mesh = SubResource("PrismMesh_7xabc")

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
Expand Down
90 changes: 45 additions & 45 deletions enemy.tscn → Defaults/Mobs/mob.tscn
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[gd_scene load_steps=15 format=3 uid="uid://b2r6nh12wv41k"]

[ext_resource type="Script" path="res://Scripts/Enemy.gd" id="1_eb130"]
[ext_resource type="PackedScene" uid="uid://mu6nbyuq02o5" path="res://enemy_corpse.tscn" id="2_vyld4"]
[ext_resource type="Script" path="res://Scripts/StateMachine.gd" id="3_68hce"]
[ext_resource type="Script" path="res://Scripts/EnemyAttack.gd" id="4_mt4kh"]
[ext_resource type="Script" path="res://Scripts/EnemyIdle.gd" id="5_bvewq"]
[ext_resource type="Script" path="res://Scripts/EnemyFollow.gd" id="6_0jpem"]
[ext_resource type="Script" path="res://Scripts/EnemyStats.gd" id="7_p4tru"]
[ext_resource type="Texture2D" uid="uid://cy56wx4qynp3m" path="res://Textures/enemy.png" id="8_wgh4n"]
[ext_resource type="Script" path="res://Scripts/Detection.gd" id="9_fj2x0"]
[ext_resource type="Shader" path="res://transparent_lighting.gdshader" id="10_c1y3v"]
[ext_resource type="Script" path="res://Scripts/Mob.gd" id="1_ajqy0"]
[ext_resource type="PackedScene" uid="uid://mu6nbyuq02o5" path="res://Defaults/Mobs/mob_corpse.tscn" id="2_eldwl"]
[ext_resource type="Script" path="res://Scripts/StateMachine.gd" id="3_qfjv5"]
[ext_resource type="Script" path="res://Scripts/MobAttack.gd" id="4_fqxd2"]
[ext_resource type="Script" path="res://Scripts/MobIdle.gd" id="5_qf6ud"]
[ext_resource type="Script" path="res://Scripts/MobFollow.gd" id="6_va33k"]
[ext_resource type="Script" path="res://Scripts/MobStats.gd" id="7_a31ax"]
[ext_resource type="Script" path="res://Scripts/Detection.gd" id="8_ugi6q"]
[ext_resource type="Texture2D" uid="uid://cy56wx4qynp3m" path="res://Textures/enemy.png" id="9_vd6sy"]
[ext_resource type="Shader" path="res://transparent_lighting.gdshader" id="10_qbt4f"]

[sub_resource type="SphereShape3D" id="SphereShape3D_uyii8"]
radius = 0.357674
Expand All @@ -19,25 +19,25 @@ size = Vector3(0.35, 0.35, 0.35)

[sub_resource type="ShaderMaterial" id="ShaderMaterial_vr552"]
render_priority = 0
shader = ExtResource("10_c1y3v")
shader = ExtResource("10_qbt4f")
shader_parameter/color = Color(1, 0.266667, 0.0509804, 1)
shader_parameter/energy = 1.0
shader_parameter/tex = ExtResource("8_wgh4n")
shader_parameter/tex = ExtResource("9_vd6sy")

[sub_resource type="QuadMesh" id="QuadMesh_bbnvr"]
lightmap_size_hint = Vector2i(7, 7)
material = SubResource("ShaderMaterial_vr552")
size = Vector2(0.5, 0.5)
orientation = 1

[node name="Enemy" type="CharacterBody3D" groups=["Enemies"]]
[node name="Mob" type="CharacterBody3D" groups=["Enemies"]]
collision_layer = 2
collision_mask = 15
wall_min_slide_angle = 0.0
floor_constant_speed = true
script = ExtResource("1_eb130")
stats = NodePath("EnemyStats")
corpse_scene = ExtResource("2_vyld4")
script = ExtResource("1_ajqy0")
stats = NodePath("MobStats")
corpse_scene = ExtResource("2_eldwl")

[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
path_desired_distance = 0.5
Expand All @@ -47,42 +47,42 @@ avoidance_enabled = true
debug_enabled = true

[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("initial_state")]
script = ExtResource("3_68hce")
initial_state = NodePath("EnemyIdle")
script = ExtResource("3_qfjv5")
initial_state = NodePath("MobIdle")

[node name="EnemyAttack" type="Node3D" parent="StateMachine" node_paths=PackedStringArray("attack_timer")]
script = ExtResource("4_mt4kh")
stats = NodePath("../../EnemyStats")
[node name="MobAttack" type="Node3D" parent="StateMachine" node_paths=PackedStringArray("attack_timer")]
script = ExtResource("4_fqxd2")
stats = NodePath("../../MobStats")
attack_timer = NodePath("AttackCooldown")
enemy = NodePath("../..")
mob = NodePath("../..")

[node name="AttackCooldown" type="Timer" parent="StateMachine/EnemyAttack"]
[node name="AttackCooldown" type="Timer" parent="StateMachine/MobAttack"]

[node name="EnemyIdle" type="Node3D" parent="StateMachine" node_paths=PackedStringArray("nav_agent", "moving_timer")]
script = ExtResource("5_bvewq")
[node name="MobIdle" type="Node3D" parent="StateMachine" node_paths=PackedStringArray("nav_agent", "moving_timer")]
script = ExtResource("5_qf6ud")
nav_agent = NodePath("../../NavigationAgent3D")
stats = NodePath("../../EnemyStats")
enemy = NodePath("../..")
stats = NodePath("../../MobStats")
mob = NodePath("../..")
move_distance = 50.0
moving_timer = NodePath("MovingCooldown")

[node name="MovingCooldown" type="Timer" parent="StateMachine/EnemyIdle"]
[node name="MovingCooldown" type="Timer" parent="StateMachine/MobIdle"]
wait_time = 4.0

[node name="EnemyFollow" type="Node3D" parent="StateMachine" node_paths=PackedStringArray("nav_agent", "enemy", "pathfinding_timer")]
script = ExtResource("6_0jpem")
[node name="MobFollow" type="Node3D" parent="StateMachine" node_paths=PackedStringArray("nav_agent", "mob", "pathfinding_timer")]
script = ExtResource("6_va33k")
nav_agent = NodePath("../../NavigationAgent3D")
enemy = NodePath("../..")
enemyCol = NodePath("../../CollisionShape3D")
stats = NodePath("../../EnemyStats")
mob = NodePath("../..")
mobCol = NodePath("../../CollisionShape3D")
stats = NodePath("../../MobStats")
pathfinding_timer = NodePath("Timer")

[node name="Timer" type="Timer" parent="StateMachine/EnemyFollow"]
[node name="Timer" type="Timer" parent="StateMachine/MobFollow"]
wait_time = 0.2
autostart = true

[node name="EnemyStats" type="Node" parent="."]
script = ExtResource("7_p4tru")
[node name="MobStats" type="Node" parent="."]
script = ExtResource("7_a31ax")
melee_damage = 20.0
melee_range = 1.5
health = 100.0
Expand All @@ -93,8 +93,8 @@ senseRange = 50.0
hearingRange = 1000.0

[node name="Detection" type="Node3D" parent="."]
script = ExtResource("9_fj2x0")
stats = NodePath("../EnemyStats")
script = ExtResource("8_ugi6q")
stats = NodePath("../MobStats")

[node name="Sprite3D" type="Sprite3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0275174, 0)
Expand All @@ -105,7 +105,7 @@ pixel_size = 0.05
billboard = 1
shaded = true
double_sided = false
texture = ExtResource("8_wgh4n")
texture = ExtResource("9_vd6sy")

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
visible = false
Expand All @@ -122,9 +122,9 @@ cast_shadow = 0
gi_mode = 0
mesh = SubResource("QuadMesh_bbnvr")

[connection signal="timeout" from="StateMachine/EnemyAttack/AttackCooldown" to="StateMachine/EnemyAttack" method="_on_attack_cooldown_timeout"]
[connection signal="timeout" from="StateMachine/EnemyIdle/MovingCooldown" to="StateMachine/EnemyIdle" method="_on_moving_cooldown_timeout"]
[connection signal="timeout" from="StateMachine/EnemyFollow/Timer" to="StateMachine/EnemyFollow" method="_on_timer_timeout"]
[connection signal="player_spotted" from="Detection" to="StateMachine/EnemyAttack" method="_on_detection_player_spotted"]
[connection signal="player_spotted" from="Detection" to="StateMachine/EnemyIdle" method="_on_detection_player_spotted"]
[connection signal="player_spotted" from="Detection" to="StateMachine/EnemyFollow" method="_on_detection_player_spotted"]
[connection signal="timeout" from="StateMachine/MobAttack/AttackCooldown" to="StateMachine/MobAttack" method="_on_attack_cooldown_timeout"]
[connection signal="timeout" from="StateMachine/MobIdle/MovingCooldown" to="StateMachine/MobIdle" method="_on_moving_cooldown_timeout"]
[connection signal="timeout" from="StateMachine/MobFollow/Timer" to="StateMachine/MobFollow" method="_on_timer_timeout"]
[connection signal="player_spotted" from="Detection" to="StateMachine/MobAttack" method="_on_detection_player_spotted"]
[connection signal="player_spotted" from="Detection" to="StateMachine/MobIdle" method="_on_detection_player_spotted"]
[connection signal="player_spotted" from="Detection" to="StateMachine/MobFollow" method="_on_detection_player_spotted"]
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bu00lw1luehxr"
path.s3tc="res://.godot/imported/1.png-97878b150c8cfea86d5ee12c89d61658.s3tc.ctex"
path.s3tc="res://.godot/imported/1.png-0a2a220d5dbae2055345f2757451ae49.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}

[deps]

source_file="res://Textures/Tiles/Actual textures/1.png"
dest_files=["res://.godot/imported/1.png-97878b150c8cfea86d5ee12c89d61658.s3tc.ctex"]
source_file="res://Defaults/Sprites/1.png"
dest_files=["res://.godot/imported/1.png-0a2a220d5dbae2055345f2757451ae49.s3tc.ctex"]

[params]

Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://c31w0wuk8qabw"
path.s3tc="res://.godot/imported/2.png-054b4df51feed804de7ba33365535c1c.s3tc.ctex"
path.s3tc="res://.godot/imported/2.png-064a12f2e68879b8011ec8d7535f90a6.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}

[deps]

source_file="res://Textures/Tiles/Actual textures/2.png"
dest_files=["res://.godot/imported/2.png-054b4df51feed804de7ba33365535c1c.s3tc.ctex"]
source_file="res://Defaults/Sprites/2.png"
dest_files=["res://.godot/imported/2.png-064a12f2e68879b8011ec8d7535f90a6.s3tc.ctex"]

[params]

Expand Down
File renamed without changes
Loading