Generic marker pickups

This commit is contained in:
Marco 2025-05-01 10:04:15 +02:00
commit 692c33c939
15 changed files with 176 additions and 36 deletions

View file

@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.4.0">
<Project Sdk="Godot.NET.Sdk/4.4.1">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>

View file

@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.4.1">
<Project Sdk="Godot.NET.Sdk/4.4.0">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>

View file

@ -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"]

View file

@ -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"

View file

@ -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

View file

@ -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")

View file

@ -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"]

View file

@ -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")

View file

@ -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")

View file

@ -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);
}
}

View file

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

View file

@ -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

View file

@ -0,0 +1 @@
uid://8y0ql44v5ckt

View file

@ -100,4 +100,11 @@ public partial class ItemPickup : Interactable
// }
// }
}
public void SetSprite(Texture2D sprite)
{
var spriteNode = GetNodeOrNull<Sprite2D>("Sprite2D");
if (spriteNode is null) return;
spriteNode.Texture = sprite;
}
}

View file

@ -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<PackedScene>(DropScenePath);
var spawnedItem = parent.CreateSibling<ItemPickup>(itemScene);
spawnedItem.Name = this.ItemKey;
spawnedItem.LootTable.Add(this);
spawnedItem.SetSprite(InventorySprite);
return spawnedItem;
}
}
public enum UiItemType