diff --git a/Cirno.csproj b/Cirno.csproj index ff0cdeff..afde3cb6 100644 --- a/Cirno.csproj +++ b/Cirno.csproj @@ -1,4 +1,4 @@ - + net8.0 true diff --git a/Cirno.csproj.old.5 b/Cirno.csproj.old.5 index afde3cb6..ff0cdeff 100644 --- a/Cirno.csproj.old.5 +++ b/Cirno.csproj.old.5 @@ -1,4 +1,4 @@ - + net8.0 true diff --git a/Resources/Debug/DebugLevels.tres b/Resources/Debug/DebugLevels.tres index 83bc6d0d..c5224ec4 100644 --- a/Resources/Debug/DebugLevels.tres +++ b/Resources/Debug/DebugLevels.tres @@ -21,8 +21,8 @@ _name = "Intro" [sub_resource type="Resource" id="Resource_cfhv5"] script = ExtResource("1_ov731") EggIndex = 0 -StartingEquipment = Array[ExtResource("2_bkci5")]([]) -RemoveEquipment = Array[ExtResource("2_bkci5")]([]) +StartingEquipment = [] +RemoveEquipment = [] [sub_resource type="Resource" id="Resource_0k62o"] script = ExtResource("2_tnajf") @@ -34,8 +34,8 @@ StartData = SubResource("Resource_cfhv5") [sub_resource type="Resource" id="Resource_tpb7s"] script = ExtResource("1_ov731") EggIndex = 0 -StartingEquipment = Array[ExtResource("2_bkci5")]([]) -RemoveEquipment = Array[ExtResource("2_bkci5")]([]) +StartingEquipment = [] +RemoveEquipment = [] [sub_resource type="Resource" id="Resource_edoov"] script = ExtResource("2_tnajf") @@ -47,8 +47,8 @@ StartData = SubResource("Resource_tpb7s") [sub_resource type="Resource" id="Resource_1sw5g"] script = ExtResource("1_ov731") EggIndex = 255 -StartingEquipment = Array[ExtResource("2_bkci5")]([]) -RemoveEquipment = Array[ExtResource("2_bkci5")]([]) +StartingEquipment = [] +RemoveEquipment = [] [sub_resource type="Resource" id="Resource_47bot"] script = ExtResource("2_tnajf") @@ -61,7 +61,7 @@ StartData = SubResource("Resource_1sw5g") script = ExtResource("1_ov731") EggIndex = 2 StartingEquipment = Array[ExtResource("2_bkci5")]([ExtResource("3_fydgr"), ExtResource("4_38yta"), ExtResource("5_em757"), ExtResource("6_sdmg8")]) -RemoveEquipment = Array[ExtResource("2_bkci5")]([]) +RemoveEquipment = [] [sub_resource type="Resource" id="Resource_mgdm6"] script = ExtResource("2_tnajf") @@ -79,8 +79,8 @@ _name = "Rebel Base" [sub_resource type="Resource" id="Resource_maxpt"] script = ExtResource("1_ov731") EggIndex = 0 -StartingEquipment = Array[ExtResource("2_bkci5")]([]) -RemoveEquipment = Array[ExtResource("2_bkci5")]([]) +StartingEquipment = [] +RemoveEquipment = [] [sub_resource type="Resource" id="Resource_pein5"] script = ExtResource("2_tnajf") @@ -117,7 +117,7 @@ _name = "Default Scene" script = ExtResource("1_ov731") EggIndex = 0 StartingEquipment = Array[ExtResource("2_bkci5")]([ExtResource("7_b3oo5")]) -RemoveEquipment = Array[ExtResource("2_bkci5")]([]) +RemoveEquipment = [] [sub_resource type="Resource" id="Resource_6ijnv"] script = ExtResource("2_tnajf") @@ -136,8 +136,8 @@ metadata/_custom_type_script = "uid://dnthdjrx78u6m" [sub_resource type="Resource" id="Resource_7sue8"] script = ExtResource("1_ov731") EggIndex = 255 -StartingEquipment = Array[ExtResource("2_bkci5")]([]) -RemoveEquipment = Array[ExtResource("2_bkci5")]([]) +StartingEquipment = [] +RemoveEquipment = [] metadata/_custom_type_script = "uid://mja0rk7n2kln" [sub_resource type="Resource" id="Resource_ognca"] @@ -151,8 +151,8 @@ metadata/_custom_type_script = "uid://dnthdjrx78u6m" [sub_resource type="Resource" id="Resource_olpjo"] script = ExtResource("1_ov731") EggIndex = 0 -StartingEquipment = Array[ExtResource("2_bkci5")]([]) -RemoveEquipment = Array[ExtResource("2_bkci5")]([]) +StartingEquipment = [] +RemoveEquipment = [] metadata/_custom_type_script = "uid://mja0rk7n2kln" [sub_resource type="Resource" id="Resource_nbnej"] diff --git a/Resources/Items/Ammo1.tres b/Resources/Items/Ammo1.tres index ffbb488b..aabfb87a 100644 --- a/Resources/Items/Ammo1.tres +++ b/Resources/Items/Ammo1.tres @@ -22,4 +22,4 @@ UiType = 2 Selectable = false AutoPickup = true InventorySprite = SubResource("AtlasTexture_3y0hf") -DropScenePath = &"res://Scenes/Items/Ammo1.tscn" +DropScenePath = &"res://Scenes/Items/GenericItem.tscn" diff --git a/Resources/Weapons/IcicleGun.tres b/Resources/Weapons/IcicleGun.tres index 90e23d7b..0a771cda 100644 --- a/Resources/Weapons/IcicleGun.tres +++ b/Resources/Weapons/IcicleGun.tres @@ -15,7 +15,7 @@ ReloadTime = 0.6 AutoReload = true InfiniteAmmo = true ItemKey = &"ICICLE_GUN" -AmmoKey = null +AmmoKey = &"" BulletsPerShot = 1 SpreadAngle = 0.0 RandomSpread = 0.0 diff --git a/Scenes/Items/Ammo1.tscn b/Scenes/Items/Ammo1.tscn index 544968e9..f1b6e4b3 100644 --- a/Scenes/Items/Ammo1.tscn +++ b/Scenes/Items/Ammo1.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://cmr6fclttrpkb"] +[gd_scene load_steps=6 format=3 uid="uid://cmr6fclttrpkb"] [ext_resource type="Script" uid="uid://b3h7b30kerf60" path="res://Scripts/Interactables/ItemPickup.cs" id="1_it180"] [ext_resource type="Resource" uid="uid://ct1fa2huvy34n" path="res://Resources/Items/Ammo1.tres" id="2_j10i4"] +[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_k1yis"] [ext_resource type="SpriteFrames" uid="uid://pmwatoyt2ase" path="res://Resources/Sprites/Ammo_Inventory_Sprite.tres" id="3_6n103"] [sub_resource type="CircleShape2D" id="CircleShape2D_6vv2s"] @@ -10,7 +11,7 @@ collision_layer = 4 collision_mask = 2 script = ExtResource("1_it180") -LootTable = [ExtResource("2_j10i4")] +LootTable = Array[ExtResource("2_k1yis")]([ExtResource("2_j10i4")]) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_6vv2s") diff --git a/Scenes/Items/GenericItem.tscn b/Scenes/Items/GenericItem.tscn new file mode 100644 index 00000000..57096f31 --- /dev/null +++ b/Scenes/Items/GenericItem.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://yj383ec5xnx"] + +[ext_resource type="Script" uid="uid://b3h7b30kerf60" path="res://Scripts/Interactables/ItemPickup.cs" id="1_rj4fe"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_6vv2s"] + +[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_e0m7j"] +size = Vector2(8, 8) + +[node name="Item" type="Area2D" groups=["Interactable"]] +collision_layer = 4 +collision_mask = 2 +script = ExtResource("1_rj4fe") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("CircleShape2D_6vv2s") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = SubResource("PlaceholderTexture2D_e0m7j") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/Gray_Keycard.tscn b/Scenes/Items/Gray_Keycard.tscn index 2f90f2e8..d8063836 100644 --- a/Scenes/Items/Gray_Keycard.tscn +++ b/Scenes/Items/Gray_Keycard.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=7 format=3 uid="uid://mtn26qwp4yqy"] +[gd_scene load_steps=8 format=3 uid="uid://mtn26qwp4yqy"] [ext_resource type="PackedScene" uid="uid://dxs3ks2ucaxl4" path="res://Scenes/Items/Red_Keycard.tscn" id="1_0bwjc"] +[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_0bwjc"] [ext_resource type="Resource" uid="uid://oa8s6xydriib" path="res://Resources/Items/Generic_Keycard.tres" id="3_0bwjc"] [ext_resource type="Texture2D" uid="uid://bvybqletsvqgk" path="res://Sprites/Items/BlueKeycard_Small.png" id="4_7ohj7"] @@ -27,7 +28,7 @@ animations = [{ }] [node name="GrayKeycard" instance=ExtResource("1_0bwjc")] -LootTable = [ExtResource("3_0bwjc")] +LootTable = Array[ExtResource("2_0bwjc")]([ExtResource("3_0bwjc")]) [node name="AnimatedSprite2D" parent="." index="1"] sprite_frames = SubResource("SpriteFrames_gbw5v") diff --git a/Scenes/test.tscn b/Scenes/test.tscn index 9f18ba65..b146b401 100644 --- a/Scenes/test.tscn +++ b/Scenes/test.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=158 format=4 uid="uid://bv451a8wgty4u"] +[gd_scene load_steps=159 format=4 uid="uid://bv451a8wgty4u"] [ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_8tmoj"] [ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_ksslq"] @@ -92,6 +92,7 @@ [ext_resource type="AudioStream" uid="uid://blohh20jktoyo" path="res://SFX/270641__phantastonia__alarm2.wav" id="79_jn1m0"] [ext_resource type="PackedScene" uid="uid://dky13otbks8cm" path="res://Scenes/Actors/Thermatron_FSM.tscn" id="80_f37sa"] [ext_resource type="PackedScene" uid="uid://ihy1ew7bo6no" path="res://Scenes/Items/Yin_Yang_Orb.tscn" id="81_ati1v"] +[ext_resource type="Script" uid="uid://cqoqovfvk83wn" path="res://Scripts/Actors/ItemMarker.cs" id="82_fuaed"] [ext_resource type="Resource" uid="uid://b0jpn0kkmciuq" path="res://Resources/Music/Overtime_Fairy_Dance.tres" id="82_ksslq"] [ext_resource type="PackedScene" uid="uid://cvctgw8eo2f7e" path="res://Scenes/Items/SpiderBomb_Pickup.tscn" id="83_jn1m0"] [ext_resource type="PackedScene" uid="uid://e80xujqyjoh" path="res://Scenes/Props/Box_Vertical.tscn" id="84_bwt6v"] @@ -692,6 +693,30 @@ position = Vector2(-736, -438) [node name="VendingMachine" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("87_gqbl6")] position = Vector2(-840, -423) +[node name="AmmoMarker" type="Marker2D" parent="Parallax2D/Factory Tilemaps/Debug Room"] +position = Vector2(-808, -410) +script = ExtResource("82_fuaed") +Item = ExtResource("4_swym2") +AutoSpawn = true + +[node name="AmmoMarker2" type="Marker2D" parent="Parallax2D/Factory Tilemaps/Debug Room"] +position = Vector2(-808, -397) +script = ExtResource("82_fuaed") +Item = ExtResource("4_swym2") +AutoSpawn = true + +[node name="AmmoMarker3" type="Marker2D" parent="Parallax2D/Factory Tilemaps/Debug Room"] +position = Vector2(-792, -410) +script = ExtResource("82_fuaed") +Item = ExtResource("4_swym2") +AutoSpawn = true + +[node name="AmmoMarker4" type="Marker2D" parent="Parallax2D/Factory Tilemaps/Debug Room"] +position = Vector2(-792, -397) +script = ExtResource("82_fuaed") +Item = ExtResource("4_swym2") +AutoSpawn = true + [node name="Part2" type="Node2D" parent="Parallax2D/Factory Tilemaps"] y_sort_enabled = true @@ -1103,18 +1128,6 @@ label_settings = ExtResource("14_c4c20") position = Vector2(290, 79) EnemyData = ExtResource("71_xhinl") -[node name="Ammo1" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")] -position = Vector2(-792, -396) - -[node name="Ammo2" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")] -position = Vector2(-808, -396) - -[node name="Ammo3" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")] -position = Vector2(-808, -408) - -[node name="Ammo4" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")] -position = Vector2(-792, -407) - [node name="BossBattleEndScript" type="Node2D" parent="Parallax2D/Factory Tilemaps/LevelProps"] position = Vector2(-1628.53, -477.628) script = ExtResource("42_wigyb") diff --git a/Scripts/Actors/ItemMarker.cs b/Scripts/Actors/ItemMarker.cs new file mode 100644 index 00000000..d771fbed --- /dev/null +++ b/Scripts/Actors/ItemMarker.cs @@ -0,0 +1,65 @@ +using Cirno.Scripts.Interactables; +using Cirno.Scripts.Resources; +using Godot; + +namespace Cirno.Scripts.Actors; + +[Tool] +public partial class ItemMarker : Marker2D +{ + private LootItem _item; + + [Export] + public LootItem Item + { + get => _item; + set + { + _item = value; + if (Engine.IsEditorHint()) + { + QueueRedraw(); + } + } + } + + [Export] public bool AutoSpawn { get; set; } = false; + + [ExportToolButton("Update Icon")] public Callable RedrawButton => Callable.From(Redraw); + + public override void _Draw() + { + if (!Engine.IsEditorHint()) return; + if (Item is null) return; + if (Item.InventorySprite is null) return; + + DrawTexture(Item.InventorySprite, - new Vector2(Item.InventorySprite.GetWidth() / 2f, Item.InventorySprite.GetHeight() / 2f)); + } + + private void Redraw() + { + QueueRedraw(); + } + + public override void _Ready() + { + if (Engine.IsEditorHint()) return; + if (AutoSpawn) + { + Spawn(true); + } + } + + public ItemPickup Spawn(bool deleteMarker) + { + if (Engine.IsEditorHint()) return null; + if (Item is null) return null; + + if (deleteMarker) + { + this.QueueFree(); + } + + return Item.Spawn(this); + } +} \ No newline at end of file diff --git a/Scripts/Actors/ItemMarker.cs.uid b/Scripts/Actors/ItemMarker.cs.uid new file mode 100644 index 00000000..26e79551 --- /dev/null +++ b/Scripts/Actors/ItemMarker.cs.uid @@ -0,0 +1 @@ +uid://cqoqovfvk83wn diff --git a/Scripts/Editor/CreateWeapon.cs b/Scripts/Editor/CreateWeapon.cs new file mode 100644 index 00000000..a8835629 --- /dev/null +++ b/Scripts/Editor/CreateWeapon.cs @@ -0,0 +1,15 @@ +#if TOOLS +using Godot; + +namespace Cirno.Scripts.Editor; + +[Tool] +public partial class CreateWeapon : EditorScript +{ + // Called when the script is executed (using File -> Run in Script Editor). + public override void _Run() + { + + } +} +#endif diff --git a/Scripts/Editor/CreateWeapon.cs.uid b/Scripts/Editor/CreateWeapon.cs.uid new file mode 100644 index 00000000..fd7484ed --- /dev/null +++ b/Scripts/Editor/CreateWeapon.cs.uid @@ -0,0 +1 @@ +uid://8y0ql44v5ckt diff --git a/Scripts/Interactables/ItemPickup.cs b/Scripts/Interactables/ItemPickup.cs index 8bcd90f7..cdf5d2a0 100644 --- a/Scripts/Interactables/ItemPickup.cs +++ b/Scripts/Interactables/ItemPickup.cs @@ -100,4 +100,11 @@ public partial class ItemPickup : Interactable // } // } } + + public void SetSprite(Texture2D sprite) + { + var spriteNode = GetNodeOrNull("Sprite2D"); + if (spriteNode is null) return; + spriteNode.Texture = sprite; + } } \ No newline at end of file diff --git a/Scripts/Resources/LootItem.cs b/Scripts/Resources/LootItem.cs index eed4085a..45a98101 100644 --- a/Scripts/Resources/LootItem.cs +++ b/Scripts/Resources/LootItem.cs @@ -1,4 +1,5 @@ -using Cirno.Scripts.Resources.ItemEffects; +using Cirno.Scripts.Interactables; +using Cirno.Scripts.Resources.ItemEffects; using Godot; namespace Cirno.Scripts.Resources; @@ -26,6 +27,20 @@ public partial class LootItem : Resource //[Export] public SpriteFrames WorldSprite; //[Export] public PackedScene HudItemScene; [Export(PropertyHint.File)] public StringName DropScenePath { get; private set; } // Has to be a string path to avoid recursion issues + + public ItemPickup Spawn(Node2D parent) + { + if (string.IsNullOrWhiteSpace(DropScenePath)) return null; + var itemScene = GD.Load(DropScenePath); + var spawnedItem = parent.CreateSibling(itemScene); + + spawnedItem.Name = this.ItemKey; + + spawnedItem.LootTable.Add(this); + spawnedItem.SetSprite(InventorySprite); + + return spawnedItem; + } } public enum UiItemType