diff --git a/data/itemRegs/items.yaml b/data/itemRegs/items.yaml index 499790a..a6eafd1 100644 --- a/data/itemRegs/items.yaml +++ b/data/itemRegs/items.yaml @@ -1,5 +1,5 @@ -#Register spells used by the projectile here. -#在这里注册抛射体使用的法术。 +#Register items here. +#在这里注册物品。 #Note: The id must be the same as the item id in the scene. Otherwise, an ArgumentException will be thrown. #备注:id必须和场景内的物品id保持一致。否则会抛出ArgumentException。 #After you declare the id of the item, add the corresponding localized text to the csv file in the locals' folder. For example, if the id is a corresponding name is item_a and the corresponding description is item_a_desc. diff --git a/prefab/weapons/StaffNecromancy.tscn b/prefab/weapons/StaffNecromancy.tscn index 1397579..cd3fdd0 100644 --- a/prefab/weapons/StaffNecromancy.tscn +++ b/prefab/weapons/StaffNecromancy.tscn @@ -14,9 +14,9 @@ size = Vector2(49, 5.25) [node name="StaffOfTheUndead" type="RigidBody2D"] collision_layer = 8 collision_mask = 34 -angular_damp = -1.0 script = ExtResource("1_w8hhv") _numberSlots = 5 +_spellList = PackedStringArray("necromancy") _fireSequentially = true FiringIntervalAsMillisecond = 300 _recoilStrength = 5 diff --git a/scenes/mapContainer.tscn b/scenes/mapContainer.tscn index 8f3473f..cdd4b20 100644 --- a/scenes/mapContainer.tscn +++ b/scenes/mapContainer.tscn @@ -134,10 +134,8 @@ grow_vertical = 0 [node name="MiniMap" type="NinePatchRect" parent="Control"] layout_mode = 1 -offset_left = 983.0 -offset_top = 480.0 -offset_right = 1133.0 -offset_bottom = 630.0 +offset_right = 150.0 +offset_bottom = 150.0 texture = ExtResource("1_h88bi") patch_margin_left = 7 patch_margin_top = 7 diff --git a/scripts/HealthBarUi.cs b/scripts/HealthBarUi.cs index a664ca1..274cbed 100644 --- a/scripts/HealthBarUi.cs +++ b/scripts/HealthBarUi.cs @@ -153,10 +153,10 @@ public partial class HealthBarUi : HBoxContainer { base._Ready(); NodeUtils.DeleteAllChild(this); - _heartEmpty = GD.Load("res://sprites/ui/HeartEmpty.png"); - _heartQuarter = GD.Load("res://sprites/ui/HeartQuarter.png"); - _heartHalf = GD.Load("res://sprites/ui/HeartHalf.png"); - _heartThreeFourths = GD.Load("res://sprites/ui/HeartThreeFourths.png"); - _heartFull = GD.Load("res://sprites/ui/HeartFull.png"); + _heartEmpty = ResourceLoader.Load("res://sprites/ui/HeartEmpty.png"); + _heartQuarter = ResourceLoader.Load("res://sprites/ui/HeartQuarter.png"); + _heartHalf = ResourceLoader.Load("res://sprites/ui/HeartHalf.png"); + _heartThreeFourths = ResourceLoader.Load("res://sprites/ui/HeartThreeFourths.png"); + _heartFull = ResourceLoader.Load("res://sprites/ui/HeartFull.png"); } } \ No newline at end of file diff --git a/scripts/character/AiCharacter.cs b/scripts/character/AiCharacter.cs index 41e910f..cbefc43 100644 --- a/scripts/character/AiCharacter.cs +++ b/scripts/character/AiCharacter.cs @@ -121,14 +121,14 @@ public sealed partial class AiCharacter : CharacterTemplate _bubbleMarker = GetNode("BubbleMarker"); if (_bubbleMarker != null) { - using var plaintScene = GD.Load("res://prefab/ui/plaint.tscn"); + using var plaintScene = ResourceLoader.Load("res://prefab/ui/plaint.tscn"); var plaint = NodeUtils.InstantiatePackedScene(plaintScene); if (plaint != null) { _bubbleMarker.AddBubble(PlaintBubbleId, plaint); } - using var queryScene = GD.Load("res://prefab/ui/query.tscn"); + using var queryScene = ResourceLoader.Load("res://prefab/ui/query.tscn"); var query = NodeUtils.InstantiatePackedScene(queryScene); if (query != null) { @@ -200,7 +200,7 @@ public sealed partial class AiCharacter : CharacterTemplate //Set the resource path of the initial weapon and try to create the object of the initial weapon. //设置了初始武器的资源路径,尝试创建初始武器的对象。 - var packedScene = GD.Load(initWeaponRes); + var packedScene = ResourceLoader.Load(initWeaponRes); var weaponTemplate = NodeUtils.InstantiatePackedScene(packedScene); if (weaponTemplate == null) { diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index a1e1260..08bd2c3 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -53,7 +53,7 @@ public partial class Player : CharacterTemplate //Mount the camera. //挂载相机。 - var mainCameraPackedScene = GD.Load("res://prefab/MainCamera.tscn"); + var mainCameraPackedScene = ResourceLoader.Load("res://prefab/MainCamera.tscn"); var camera2D = NodeUtils.InstantiatePackedScene(mainCameraPackedScene); if (camera2D != null) { diff --git a/scripts/damage/DamageNumberNodeSpawn.cs b/scripts/damage/DamageNumberNodeSpawn.cs index fd2b06b..4cc516e 100644 --- a/scripts/damage/DamageNumberNodeSpawn.cs +++ b/scripts/damage/DamageNumberNodeSpawn.cs @@ -46,7 +46,7 @@ public partial class DamageNumberNodeSpawn : Marker2D public override void _Ready() { base._Ready(); - _damageNumberPackedScene = GD.Load("res://prefab/ui/DamageNumber.tscn") as PackedScene; + _damageNumberPackedScene = ResourceLoader.Load("res://prefab/ui/DamageNumber.tscn") as PackedScene; _rootNode = GetNode("/root/Game/DamageNumberContainer"); //The horizontal velocity is in the X positive direction //水平速度的X正方向 diff --git a/scripts/furniture/GuiFurniture.cs b/scripts/furniture/GuiFurniture.cs index 2d50717..0d147dc 100644 --- a/scripts/furniture/GuiFurniture.cs +++ b/scripts/furniture/GuiFurniture.cs @@ -47,7 +47,7 @@ public partial class GuiFurniture : Furniture { GameSceneDepend.DynamicUiGroup?.RegisterControl(Path, () => { - var packedScene = GD.Load(Path); + var packedScene = ResourceLoader.Load(Path); return NodeUtils.InstantiatePackedScene(packedScene); }); } diff --git a/scripts/inventory/ItemSlotContainerDisplay.cs b/scripts/inventory/ItemSlotContainerDisplay.cs index 26769f2..6725f21 100644 --- a/scripts/inventory/ItemSlotContainerDisplay.cs +++ b/scripts/inventory/ItemSlotContainerDisplay.cs @@ -5,7 +5,7 @@ namespace ColdMint.scripts.inventory; public class ItemSlotContainerDisplay(Node rootNode) : ItemContainerDisplayTemplate { - private readonly PackedScene? _packedScene = GD.Load("res://prefab/ui/ItemSlot.tscn"); + private readonly PackedScene? _packedScene = ResourceLoader.Load("res://prefab/ui/ItemSlot.tscn"); protected override void AddItemDisplay() { diff --git a/scripts/inventory/ItemSlotNode.cs b/scripts/inventory/ItemSlotNode.cs index d7e15b1..281e651 100644 --- a/scripts/inventory/ItemSlotNode.cs +++ b/scripts/inventory/ItemSlotNode.cs @@ -20,8 +20,8 @@ public partial class ItemSlotNode : MarginContainer, IItemDisplay public override void _Ready() { - _backgroundTexture = GD.Load("res://sprites/ui/ItemBarEmpty.png"); - _backgroundTextureWhenSelect = GD.Load("res://sprites/ui/ItemBarFocus.png"); + _backgroundTexture = ResourceLoader.Load("res://sprites/ui/ItemBarEmpty.png"); + _backgroundTextureWhenSelect = ResourceLoader.Load("res://sprites/ui/ItemBarFocus.png"); _backgroundTextureRect = GetNode("BackgroundTexture"); _iconTextureRect = GetNode("BackgroundTexture/IconTextureRect"); diff --git a/scripts/inventory/Packsack.cs b/scripts/inventory/Packsack.cs index 906450c..9d8d870 100644 --- a/scripts/inventory/Packsack.cs +++ b/scripts/inventory/Packsack.cs @@ -62,7 +62,7 @@ public partial class Packsack : PickAbleTemplate } GameSceneDepend.DynamicUiGroup?.RegisterControl(Path, () => { - var packedScene = GD.Load(Path); + var packedScene = ResourceLoader.Load(Path); return NodeUtils.InstantiatePackedScene(packedScene); }); } diff --git a/scripts/loader/uiLoader/ContributorLoader.cs b/scripts/loader/uiLoader/ContributorLoader.cs index 9fbedaa..1b53f9a 100644 --- a/scripts/loader/uiLoader/ContributorLoader.cs +++ b/scripts/loader/uiLoader/ContributorLoader.cs @@ -18,9 +18,9 @@ public partial class ContributorLoader : UiLoaderTemplate public override void InitializeData() { - _mainMenu = GD.Load("res://scenes/mainMenu.tscn"); - _packedScene = GD.Load("res://prefab/ui/contributorGroup.tscn"); - _contributorGroup = GD.Load("res://prefab/ui/contributorGroup.tscn"); + _mainMenu = ResourceLoader.Load("res://scenes/mainMenu.tscn"); + _packedScene = ResourceLoader.Load("res://prefab/ui/contributorGroup.tscn"); + _contributorGroup = ResourceLoader.Load("res://prefab/ui/contributorGroup.tscn"); } public override void InitializeUi() diff --git a/scripts/loader/uiLoader/LevelGraphEditorLoader.cs b/scripts/loader/uiLoader/LevelGraphEditorLoader.cs index e3a3180..827aee5 100644 --- a/scripts/loader/uiLoader/LevelGraphEditorLoader.cs +++ b/scripts/loader/uiLoader/LevelGraphEditorLoader.cs @@ -60,8 +60,8 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate public override void InitializeData() { base.InitializeData(); - _mainMenu = GD.Load("res://scenes/mainMenu.tscn"); - _roomNodeScene = GD.Load("res://prefab/ui/RoomNode.tscn"); + _mainMenu = ResourceLoader.Load("res://scenes/mainMenu.tscn"); + _roomNodeScene = ResourceLoader.Load("res://prefab/ui/RoomNode.tscn"); _defaultRoomName = TranslationServerUtils.Translate("ui_default_room_name"); var folder = Config.GetLevelGraphExportDirectory(); if (!Directory.Exists(folder)) diff --git a/scripts/loader/uiLoader/MainMenuLoader.cs b/scripts/loader/uiLoader/MainMenuLoader.cs index ddec51b..a997328 100644 --- a/scripts/loader/uiLoader/MainMenuLoader.cs +++ b/scripts/loader/uiLoader/MainMenuLoader.cs @@ -25,9 +25,9 @@ public partial class MainMenuLoader : UiLoaderTemplate public override void InitializeData() { - _gameScene = GD.Load("res://scenes/game.tscn"); - _contributor = GD.Load("res://scenes/contributor.tscn"); - _levelGraphEditor = GD.Load("res://scenes/levelGraphEditor.tscn"); + _gameScene = ResourceLoader.Load("res://scenes/game.tscn"); + _contributor = ResourceLoader.Load("res://scenes/contributor.tscn"); + _levelGraphEditor = ResourceLoader.Load("res://scenes/levelGraphEditor.tscn"); } public override void InitializeUi() diff --git a/scripts/loader/uiLoader/PacksackUi.cs b/scripts/loader/uiLoader/PacksackUi.cs index c704a24..0b318f0 100644 --- a/scripts/loader/uiLoader/PacksackUi.cs +++ b/scripts/loader/uiLoader/PacksackUi.cs @@ -69,7 +69,7 @@ public partial class PacksackUi : UiLoaderTemplate public override void InitializeData() { - _packedScene = GD.Load("res://prefab/ui/ItemSlot.tscn"); + _packedScene = ResourceLoader.Load("res://prefab/ui/ItemSlot.tscn"); } private void BindItemContainer() diff --git a/scripts/loader/uiLoader/SplashScreenLoader.cs b/scripts/loader/uiLoader/SplashScreenLoader.cs index 263fd58..05f73d8 100644 --- a/scripts/loader/uiLoader/SplashScreenLoader.cs +++ b/scripts/loader/uiLoader/SplashScreenLoader.cs @@ -29,7 +29,7 @@ public partial class SplashScreenLoader : UiLoaderTemplate public override void InitializeData() { - _mainMenuScene = GD.Load("res://scenes/mainMenu.tscn"); + _mainMenuScene = ResourceLoader.Load("res://scenes/mainMenu.tscn"); } public override void InitializeUi() diff --git a/scripts/map/AiCharacterSpawn.cs b/scripts/map/AiCharacterSpawn.cs index 60262b6..1de8ec7 100644 --- a/scripts/map/AiCharacterSpawn.cs +++ b/scripts/map/AiCharacterSpawn.cs @@ -32,7 +32,7 @@ public partial class AiCharacterSpawn : Marker2D, ISpawnMarker { return null; } - var packedScene = GD.Load(resPath); + var packedScene = ResourceLoader.Load(resPath); if (packedScene == null) { return null; diff --git a/scripts/map/PlayerSpawn.cs b/scripts/map/PlayerSpawn.cs index e35852b..7d92878 100644 --- a/scripts/map/PlayerSpawn.cs +++ b/scripts/map/PlayerSpawn.cs @@ -24,7 +24,7 @@ public partial class PlayerSpawn : Marker2D, ISpawnMarker public override void _Ready() { base._Ready(); - _playerPackedScene = GD.Load("res://prefab/entitys/Character.tscn"); + _playerPackedScene = ResourceLoader.Load("res://prefab/entitys/Character.tscn"); EventBus.MapGenerationCompleteEvent += MapGenerationCompleteEvent; EventBus.GameReplayEvent += GameReplayEvent; } diff --git a/scripts/map/room/RoomFactory.cs b/scripts/map/room/RoomFactory.cs index 5adab31..559f659 100644 --- a/scripts/map/room/RoomFactory.cs +++ b/scripts/map/room/RoomFactory.cs @@ -88,7 +88,7 @@ public static class RoomFactory var room = new Room { - RoomScene = GD.Load(ResUtils.GetEditorResPath(resPath)), + RoomScene = ResourceLoader.Load(ResUtils.GetEditorResPath(resPath)), EnterRoomEventHandlerId = enterRoomEventHandlerId, ExitRoomEventHandlerId = exitRoomEventHandlerId }; diff --git a/scripts/projectile/decorator/NodeSpawnOnKillCharacterDecorator.cs b/scripts/projectile/decorator/NodeSpawnOnKillCharacterDecorator.cs index ec2fade..a222c63 100644 --- a/scripts/projectile/decorator/NodeSpawnOnKillCharacterDecorator.cs +++ b/scripts/projectile/decorator/NodeSpawnOnKillCharacterDecorator.cs @@ -42,7 +42,7 @@ public class NodeSpawnOnKillCharacterDecorator : IProjectileDecorator return; } - var packedScene = GD.Load(PackedScenePath); + var packedScene = ResourceLoader.Load(PackedScenePath); var node2D = NodeUtils.InstantiatePackedScene(packedScene); if (node2D == null) { diff --git a/scripts/spell/SpellPickAble.cs b/scripts/spell/SpellPickAble.cs index 233bd58..1c7d4ec 100644 --- a/scripts/spell/SpellPickAble.cs +++ b/scripts/spell/SpellPickAble.cs @@ -34,7 +34,7 @@ public partial class SpellPickAble : PickAbleTemplate, ISpell base._Ready(); if (!string.IsNullOrEmpty(_projectilePath)) { - _projectileScene = GD.Load(_projectilePath); + _projectileScene = ResourceLoader.Load(_projectilePath); } } diff --git a/scripts/weapon/ProjectileWeapon.cs b/scripts/weapon/ProjectileWeapon.cs index 41b8845..6766a1a 100644 --- a/scripts/weapon/ProjectileWeapon.cs +++ b/scripts/weapon/ProjectileWeapon.cs @@ -31,6 +31,17 @@ public partial class ProjectileWeapon : WeaponTemplate [Export] private int _numberSlots; + /// + /// SpellList + /// 法术列表 + /// + /// + ///To make weapons out of the box, you need to configure pre-made spells here. + ///为了使武器开箱即用,您需要在这里配置预制的法术。 + /// + [Export] + private string[]? _spellList; + /// /// How many projectiles are generated per fire /// 每次开火生成多少个抛射体 @@ -119,6 +130,25 @@ public partial class ProjectileWeapon : WeaponTemplate { SelfItemContainer = new UniversalItemContainer(_numberSlots); SelfItemContainer.AllowAddingItemByType(Config.ItemType.Spell); + //Reload pre-made spells. + //装填预制的法术。 + if (_spellList is not { Length: > 0 }) return; + foreach (var spellId in _spellList) + { + if (string.IsNullOrEmpty(spellId)) + { + continue; + } + var item = ItemTypeManager.CreateItem(spellId, this); + if (item == null) + { + continue; + } + if (SelfItemContainer.CanAddItem(item)) + { + SelfItemContainer.AddItem(item); + } + } } }