Explosions for bullets

This commit is contained in:
Marco 2025-03-06 17:05:45 +01:00
commit 8ab4546579
9 changed files with 58 additions and 11 deletions

View file

@ -1,7 +1,7 @@
[gd_resource type="Resource" script_class="BulletResource" load_steps=6 format=3 uid="uid://bopwqpmxoy1rd"]
[ext_resource type="PackedScene" uid="uid://eqppkegmt562" path="res://Scenes/Weapons/Bullets/Yin_Yan_Bullet.tscn" id="1_5pffv"]
[ext_resource type="PackedScene" uid="uid://h11o0et1y54v" path="res://Scenes/Weapons/Bullets/explosion.tscn" id="2_26vvh"]
[ext_resource type="PackedScene" uid="uid://1lowv5ce2poq" path="res://Scenes/Weapons/Bullets/Autoclearing_Explosion_Bullet.tscn" id="2_26vvh"]
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_dbvc7"]
[ext_resource type="Script" uid="uid://ci2vjo54w7i18" path="res://Scripts/Resources/Modifiers/DelayedSpeedIncreaseModifier.cs" id="2_w7k7r"]

View file

@ -20,3 +20,4 @@ UiType = 1
Selectable = true
InventorySprite = ExtResource("2_5g5j1")
HudItemScene = ExtResource("1_i6xgq")
DropScenePath = null

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=48 format=4 uid="uid://dqyfnby0t7gu1"]
[gd_scene load_steps=49 format=4 uid="uid://dqyfnby0t7gu1"]
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_c3v4x"]
[ext_resource type="Resource" uid="uid://cs3ihltcn2166" path="res://Resources/Items/IcicleGun.tres" id="3_6314l"]
@ -35,6 +35,7 @@
[ext_resource type="LabelSettings" uid="uid://buk3e7bbwmnv1" path="res://Resources/Styles/Hud_Text_Style.tres" id="27_4rfvg"]
[ext_resource type="PackedScene" uid="uid://cxjumgf8bhr3l" path="res://Scenes/Elevator.tscn" id="28_3ll5g"]
[ext_resource type="PackedScene" uid="uid://fxvlaidieiv7" path="res://Scenes/Interactable/ScriptableAreaTrigger.tscn" id="28_fuxq3"]
[ext_resource type="PackedScene" uid="uid://4q82gggqax87" path="res://Scenes/Items/Cheat_Gun_Pickup.tscn" id="28_pgobb"]
[ext_resource type="Script" uid="uid://dkihoo85jfec5" path="res://Scripts/Resources/Events/MovePlayerEvent.cs" id="29_3ll5g"]
[ext_resource type="Script" uid="uid://bgertv72tq1dt" path="res://Scripts/Components/FSM/NewPlayerStateMachine.cs" id="34_2vu2h"]
[ext_resource type="Script" uid="uid://btwuahxvreivs" path="res://Scripts/Components/FSM/Player/NewInit.cs" id="35_mpb62"]
@ -106,7 +107,7 @@ tile_set = ExtResource("5_6314l")
metadata/_edit_lock_ = true
[node name="Props" type="TileMapLayer" parent="Tilemaps"]
tile_map_data = PackedByteArray("AAATAAUAAAAKAAwAAAATAAYAAAAKAA0AAAATAAcAAAAKAAwAAAATAAgAAAAKAAwAAAATAAkAAAAKAA0AAAANAAUAAAAJAAwAAAANAAYAAAAJAA0AAAANAAcAAAAJAAwAAAANAAgAAAAJAA0AAAANAAkAAAAJAAwAAAARAAUAAAAJAAwAAAARAAYAAAAJAA0AAAARAAcAAAAJAAwAAAARAAgAAAAJAAwAAAARAAkAAAAJAA0AAAAOAAUAAAAKAAwAAAAOAAYAAAAKAA0AAAAOAAcAAAAKAAwAAAAOAAgAAAAKAAwAAAAOAAkAAAAKAA0AAAAOAAMAAAAGAAMAAAA=")
tile_map_data = PackedByteArray("AAATAAUAAAAKAAwAAAATAAYAAAAKAA0AAAATAAcAAAAKAAwAAAATAAgAAAAKAAwAAAATAAkAAAAKAA0AAAANAAUAAAAJAAwAAAANAAYAAAAJAA0AAAANAAcAAAAJAAwAAAANAAgAAAAJAA0AAAANAAkAAAAJAAwAAAARAAUAAAAJAAwAAAARAAYAAAAJAA0AAAARAAcAAAAJAAwAAAARAAgAAAAJAAwAAAARAAkAAAAJAA0AAAAOAAUAAAAKAAwAAAAOAAYAAAAKAA0AAAAOAAcAAAAKAAwAAAAOAAgAAAAKAAwAAAAOAAkAAAAKAA0AAAAOAAMAAAAGAAMAAAAKAAsAAQAAAAAAAQALAAsAAQAAAAAAAQALAAwAAQAAAAAAAQAMAAwAAQAAAAAAAQALAAoAAQAAAAAAAgAKAAoAAQAAAAAAAgAJAAoAAQAAAAAAAgAJAAkAAQAAAAAAAgAKAAkAAQAAAAAAAgASAAAAAQAAAAAAAgATAAAAAQAAAAAAAgATAAEAAQAAAAAAAgA=")
tile_set = ExtResource("5_6314l")
metadata/_edit_lock_ = true
@ -217,6 +218,9 @@ offset_bottom = 425.0
text = "Pools"
label_settings = ExtResource("27_4rfvg")
[node name="CheaetGun" parent="Tilemaps/Actors" instance=ExtResource("28_pgobb")]
position = Vector2(342, 193)
[node name="ElevatorControlPadBottom" parent="Tilemaps/Actors" node_paths=PackedStringArray("Targets") instance=ExtResource("20_0knpf")]
position = Vector2(228, 144)
Targets = [NodePath("../Path2D/Elevator")]
@ -234,7 +238,7 @@ metadata/_edit_group_ = true
ElevatorPath = NodePath("..")
[node name="ScriptableAreaTrigger" parent="Tilemaps" instance=ExtResource("28_fuxq3")]
position = Vector2(197, 177)
position = Vector2(230, 250)
Events = Array[Object]([SubResource("Resource_pgobb")])
[node name="CameraController" type="Camera2D" parent="."]

View file

@ -0,0 +1,14 @@
[gd_scene load_steps=4 format=3 uid="uid://1lowv5ce2poq"]
[ext_resource type="Script" uid="uid://df81kn4u8yigu" path="res://Scripts/Weapons/AutoclearingBulletEmitter.cs" id="1_5c773"]
[ext_resource type="Resource" uid="uid://ncukdupc7hbm" path="res://Resources/Bullets/Explosion.tres" id="2_d2d24"]
[ext_resource type="Script" uid="uid://c6467d6yx50qh" path="res://Scripts/Components/BulletSpawner.cs" id="3_d2d24"]
[node name="AutoclearingExplosionBullet" type="Node2D"]
script = ExtResource("1_5c773")
BulletResource = ExtResource("2_d2d24")
EmitOnStart = true
EmitCoolDown = 10.0
[node name="BulletSpawner" type="Node2D" parent="."]
script = ExtResource("3_d2d24")

View file

@ -221,7 +221,7 @@ SpawnMarkers = Dictionary[int, NodePath]({
2: NodePath("Factory Tilemaps/LevelProps/BossDebugTeleporterDestination"),
255: NodePath("Factory Tilemaps/Debug Room/DebugRoomStartPosition")
})
StartingEquipment = [ExtResource("4_swym2"), ExtResource("5_nqier")]
StartingEquipment = Array[ExtResource("6_8tdlb")]([ExtResource("4_swym2"), ExtResource("5_nqier")])
MapStartData = SubResource("Resource_6sau4")
metadata/_edit_lock_ = true

View file

@ -24,7 +24,7 @@ public partial class BulletEmitter : Node2D, IActivable
private BulletSpawner _bulletSpawner;
private bool _isEmitting = false;
protected bool IsEmitting = false;
private double _emitTimer = 0f;
@ -33,13 +33,14 @@ public partial class BulletEmitter : Node2D, IActivable
_bulletSpawner = GetNode<BulletSpawner>("BulletSpawner");
if (EmitOnStart)
{
_isEmitting = true;
IsEmitting = true;
CallDeferred(MethodName.Shoot);
}
}
public override void _Process(double delta)
{
if (!_isEmitting) return;
if (!IsEmitting) return;
_emitTimer += delta;
if (_emitTimer >= EmitCoolDown)
@ -60,17 +61,17 @@ public partial class BulletEmitter : Node2D, IActivable
{
case ActivationType.Open:
case ActivationType.Enable:
_isEmitting = true;
IsEmitting = true;
_emitTimer = 0;
break;
case ActivationType.Close:
case ActivationType.Disable:
_isEmitting = false;
IsEmitting = false;
_emitTimer = 0;
break;
case ActivationType.Use:
case ActivationType.Toggle:
_isEmitting = !_isEmitting;
IsEmitting = !IsEmitting;
_emitTimer = 0;
break;
case ActivationType.Destroy:

View file

@ -22,6 +22,8 @@ public partial class WeaponAmmoCounter : Container
{
Item = item;
Icon.Texture = item.InventorySprite;
InventoryManager.Instance.LoadedAmmoChanged += (weaponKey, count) =>
{
if (weaponKey != Item.WeaponData.ItemKey) return;

View file

@ -0,0 +1,24 @@
using Cirno.Scripts.Activables;
using Godot;
namespace Cirno.Scripts.Weapons;
public partial class AutoclearingBulletEmitter : BulletEmitter
{
[Export]
public float Timeout { get; private set; } = 5f;
private double _timeoutTimer = 0f;
public override void _Process(double delta)
{
base._Process(delta);
if (!IsEmitting) return;
_timeoutTimer += delta;
if (_timeoutTimer >= Timeout)
{
QueueFree();
}
}
}

View file

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