Moved boss data to resource

This commit is contained in:
Marco 2025-03-04 15:00:39 +01:00
commit b0d5edc84e
6 changed files with 27 additions and 23 deletions

View file

@ -1,13 +1,18 @@
[gd_resource type="Resource" script_class="BossScript" load_steps=7 format=3 uid="uid://d2l607uabv3d6"]
[gd_resource type="Resource" script_class="BossScript" load_steps=9 format=3 uid="uid://d2l607uabv3d6"]
[ext_resource type="Script" uid="uid://cdd6q2h0t1hhq" path="res://Scripts/Resources/BossPhase.cs" id="1_rrh11"]
[ext_resource type="PackedScene" uid="uid://bwlstkdibs7oc" path="res://Scenes/HUD/BossHud.tscn" id="1_tlqss"]
[ext_resource type="Resource" uid="uid://ks6fypeil6gk" path="res://Resources/BossPhases/TestBoss1.tres" id="2_mpjlq"]
[ext_resource type="Resource" uid="uid://ccj0cqbveey8c" path="res://Resources/BossPhases/Rumia_SP1.tres" id="3_tlqss"]
[ext_resource type="Resource" uid="uid://ddb5dqocmk6x7" path="res://Resources/BossPhases/Rumia_NS2.tres" id="4_liqsl"]
[ext_resource type="Resource" uid="uid://hy1alw04fbds" path="res://Resources/BossPhases/Rumia_Lasers.tres" id="5_r3b4k"]
[ext_resource type="Script" uid="uid://inasa76li3ym" path="res://Scripts/Resources/ScriptableBullets/BossScript.cs" id="6_6bmbe"]
[ext_resource type="Texture2D" uid="uid://csuprfskdo1qp" path="res://Sprites/Portraits/Rumia.png" id="7_liqsl"]
[resource]
script = ExtResource("6_6bmbe")
BossName = &"Rumia"
Phases = Array[ExtResource("1_rrh11")]([ExtResource("2_mpjlq"), ExtResource("3_tlqss"), ExtResource("4_liqsl"), ExtResource("5_r3b4k")])
PortraitTexture = ExtResource("7_liqsl")
HudPrefab = ExtResource("1_tlqss")
metadata/_custom_type_script = "uid://inasa76li3ym"

View file

@ -14,7 +14,10 @@
[sub_resource type="Resource" id="Resource_ygnne"]
script = ExtResource("4_mmsvp")
BossName = &"Marisa"
Phases = Array[ExtResource("3_prj5f")]([ExtResource("2_q4m3q")])
PortraitTexture = ExtResource("7_h84or")
HudPrefab = ExtResource("6_r0018")
metadata/_custom_type_script = "uid://inasa76li3ym"
[sub_resource type="CircleShape2D" id="CircleShape2D_8gtts"]
@ -34,10 +37,7 @@ collision_layer = 16
collision_mask = 9
script = ExtResource("1_4dxms")
BossName = "Marisa"
Phases = Array[Resource]([ExtResource("2_q4m3q")])
BossScript = SubResource("Resource_ygnne")
BossHudPrefab = ExtResource("6_r0018")
_bossPortraitTexture = ExtResource("7_h84or")
Health = 200.0
metadata/_edit_group_ = true

View file

@ -1,14 +1,8 @@
[gd_scene load_steps=18 format=3 uid="uid://d1rlw6ddpmrn8"]
[gd_scene load_steps=12 format=3 uid="uid://d1rlw6ddpmrn8"]
[ext_resource type="Script" uid="uid://bjs2u8gogvs03" path="res://Scripts/Actors/Boss.cs" id="1_na4uq"]
[ext_resource type="Resource" uid="uid://ks6fypeil6gk" path="res://Resources/BossPhases/TestBoss1.tres" id="2_1rhf6"]
[ext_resource type="Texture2D" uid="uid://bcqgke6dthlrj" path="res://Sprites/Actors/Rumia.png" id="2_7k5gp"]
[ext_resource type="Resource" uid="uid://ddb5dqocmk6x7" path="res://Resources/BossPhases/Rumia_NS2.tres" id="2_eyxw4"]
[ext_resource type="Resource" uid="uid://hy1alw04fbds" path="res://Resources/BossPhases/Rumia_Lasers.tres" id="2_p8j4e"]
[ext_resource type="Script" uid="uid://c4qmuxjhheahr" path="res://Scripts/Components/ProximityPlayerDetection.cs" id="3_gka5j"]
[ext_resource type="Resource" uid="uid://ccj0cqbveey8c" path="res://Resources/BossPhases/Rumia_SP1.tres" id="3_j7lbl"]
[ext_resource type="Texture2D" uid="uid://csuprfskdo1qp" path="res://Sprites/Portraits/Rumia.png" id="4_at5iq"]
[ext_resource type="PackedScene" uid="uid://bwlstkdibs7oc" path="res://Scenes/HUD/BossHud.tscn" id="4_ehp8q"]
[ext_resource type="PackedScene" uid="uid://crry0rgk7a8sm" path="res://Scenes/Weapons/BaseWeapon.tscn" id="4_xc6nm"]
[ext_resource type="PackedScene" uid="uid://cuixq5ex0j40h" path="res://Scenes/enemyBullet.tscn" id="5_g1p0m"]
[ext_resource type="Resource" uid="uid://d2l607uabv3d6" path="res://Resources/BossPhases/Rumia_Boss_Script.tres" id="6_ifwrk"]
@ -31,11 +25,8 @@ collision_layer = 16
collision_mask = 9
script = ExtResource("1_na4uq")
BossName = "Rumia"
Phases = Array[Resource]([ExtResource("2_1rhf6"), ExtResource("3_j7lbl"), ExtResource("2_eyxw4"), ExtResource("2_p8j4e")])
BossScript = ExtResource("6_ifwrk")
BossHudPrefab = ExtResource("4_ehp8q")
CameraOffset = Vector2(0, 32)
_bossPortraitTexture = ExtResource("4_at5iq")
Health = 200.0
metadata/_edit_group_ = true

View file

@ -214,7 +214,7 @@ SpawnMarkers = Dictionary[int, NodePath]({
2: NodePath("Factory Tilemaps/LevelProps/BossDebugTeleporterDestination"),
255: NodePath("Factory Tilemaps/Debug Room/DebugRoomStartPosition")
})
StartingEquipment = Array[ExtResource("6_8tdlb")]([ExtResource("4_swym2"), ExtResource("5_nqier")])
StartingEquipment = [ExtResource("4_swym2"), ExtResource("5_nqier")]
MapStartData = SubResource("Resource_6sau4")
metadata/_edit_lock_ = true
@ -972,7 +972,7 @@ position = Vector2(-2000, -736)
[node name="ControlPad8" parent="Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")]
position = Vector2(-2027, -735)
Targets = [NodePath("../HorizontalForceField")]
Requirements = Array[ExtResource("6_8tdlb")]([ExtResource("84_ma1ta")])
Requirements = [ExtResource("84_ma1ta")]
[node name="IcicleRepeater2" parent="Factory Tilemaps/LevelProps" instance=ExtResource("32_xof4a")]
position = Vector2(-923, 69)

View file

@ -12,7 +12,7 @@ public partial class Boss : Enemy, IActivable
[Export] public string BossName { get; private set; }
//[Export] private Array<BossPhase> Phases;
[Export] public BossScript BossScript { get; private set; }
[Export] private PackedScene BossHudPrefab;
//[Export] private PackedScene BossHudPrefab;
[Export] public Vector2 BossPhaseAnimationStartingPosition = new Vector2(180, 10);
private int currentPhaseIndex = 0;
@ -33,8 +33,7 @@ public partial class Boss : Enemy, IActivable
private TextureRect _animationTextureRect;
[Export]
private Texture2D _bossPortraitTexture;
//[Export] private Texture2D _bossPortraitTexture;
private BossHud _bossHud;
@ -55,9 +54,9 @@ public partial class Boss : Enemy, IActivable
_gameManager.CallDeferred("add_child", _cameraMarker);
_cameraMarker.GlobalPosition = _homePosition + CameraOffset;
if (BossHudPrefab is not null)
if (BossScript.HudPrefab is not null)
{
_bossHud = BossHudPrefab.Instantiate<BossHud>();
_bossHud = BossScript.HudPrefab.Instantiate<BossHud>();
_gameManager.CallDeferred("add_child", _bossHud);
_bossHud.Name = $"{BossName}_BossHud";
@ -70,7 +69,7 @@ public partial class Boss : Enemy, IActivable
// TODO: Do some translation for health values to match the thresholds
this.HealthChanged += (float newValue) => {_bossHud.BossHealth = newValue;};
if (_bossPortraitTexture is not null)
if (BossScript.PortraitTexture is not null)
{
// var canvas = new CanvasLayer();
// canvas.Name = "BossPhaseAnimationCanvas";
@ -78,7 +77,7 @@ public partial class Boss : Enemy, IActivable
// _gameManager.CallDeferred("add_child", canvas);
_animationTextureRect = new TextureRect();
_animationTextureRect.Texture = _bossPortraitTexture;
_animationTextureRect.Texture = BossScript.PortraitTexture;
_bossHud.CallDeferred("add_child", _animationTextureRect);

View file

@ -6,6 +6,15 @@ namespace Cirno.Scripts.Resources.ScriptableBullets;
[GlobalClass]
public partial class BossScript : Resource
{
[Export]
public StringName BossName { get; private set; }
[Export]
public Array<BossPhase> Phases { get; private set; } = [];
[Export]
public Texture2D PortraitTexture { get; private set; }
[Export]
public PackedScene HudPrefab { get; private set; }
}