From 00be67d787d0feab16f45f4b310aa1e5309817b2 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Thu, 9 Nov 2023 16:22:52 -0800 Subject: [PATCH] prework for buff system --- Characters/Character.cs | 10 ---------- Characters/Player.tscn | 2 ++ Entities/Campfire.tscn | 3 +-- Entities/Projectile.cs | 4 ++-- Entities/Torch.tscn | 14 +++++++++++++- Items/Weapons/Bow.cs | 26 ++++++++++++++++++++++++++ Items/Weapons/Bow.tscn | 13 ++++++++++++- Items/Weapons/ProjectileSpawner.cs | 5 +++-- 8 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 Items/Weapons/Bow.cs diff --git a/Characters/Character.cs b/Characters/Character.cs index 13f91e6..2f19b95 100644 --- a/Characters/Character.cs +++ b/Characters/Character.cs @@ -396,16 +396,6 @@ public partial class Character : CharacterBody2D, IFaction bus.EmitSignal(Events.EventBus.SignalName.PlayerHit, newArgs); } -#if DEBUG - /// - /// For debugging purposes - /// - public void Inflict(float damage) - { - OnReceivedDamage(damage, null, 0); - } -#endif - /// /// Plays a footstep sound. This should be called through an /// AnimationPlayer to sync sounds with animations. diff --git a/Characters/Player.tscn b/Characters/Player.tscn index 7f9ab70..35bd384 100644 --- a/Characters/Player.tscn +++ b/Characters/Player.tscn @@ -693,6 +693,8 @@ libraries = { "": SubResource("AnimationLibrary_kks2p") } +[node name="Buffs" type="Node2D" parent="."] + [node name="Effects" type="Node2D" parent="."] unique_name_in_owner = true diff --git a/Entities/Campfire.tscn b/Entities/Campfire.tscn index d658cc5..b310ccb 100644 --- a/Entities/Campfire.tscn +++ b/Entities/Campfire.tscn @@ -10,7 +10,7 @@ radius = 20.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_bw3hg"] -size = Vector2(20, 23) +size = Vector2(20, 16) [node name="Campfire" type="StaticBody2D"] texture_filter = 3 @@ -46,7 +46,6 @@ offset_bottom = -19.0 text = "Clone Machine" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(0, -3.5) shape = SubResource("RectangleShape2D_bw3hg") [editable path="InteractionTrigger"] diff --git a/Entities/Projectile.cs b/Entities/Projectile.cs index 5f09fa5..38982da 100644 --- a/Entities/Projectile.cs +++ b/Entities/Projectile.cs @@ -43,8 +43,8 @@ public partial class Projectile : RigidBody2D [Export] public double Delay { get; set; } = 0; - [System.Obsolete] - public Character Character { get; set; } + [Export(PropertyHint.File, "*.tscn")] + public Godot.Collections.Array Buffs { get; set; } public Items.Weapon Weapon { get; set; } diff --git a/Entities/Torch.tscn b/Entities/Torch.tscn index 5753fd7..4e9a2bc 100644 --- a/Entities/Torch.tscn +++ b/Entities/Torch.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://c1w7t6irnohfx"] +[gd_scene load_steps=12 format=3 uid="uid://c1w7t6irnohfx"] [ext_resource type="Texture2D" uid="uid://har1bd5u4dq3" path="res://Assets/Sprites/Misc/torch.png" id="1_14bgb"] [ext_resource type="Texture2D" uid="uid://coarr28adgo1u" path="res://Assets/Sprites/Particles/point-light.png" id="2_hotvd"] @@ -60,6 +60,9 @@ animations = [{ "speed": 10.0 }] +[sub_resource type="CircleShape2D" id="CircleShape2D_ljsf5"] +radius = 4.0 + [node name="Torch" type="Node2D"] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] @@ -77,3 +80,12 @@ shadow_filter_smooth = 3.0 texture = ExtResource("2_hotvd") offset = Vector2(0, 2) texture_scale = 0.25 + +[node name="Area2D" type="Area2D" parent="."] +position = Vector2(0, -8) +collision_layer = 128 +collision_mask = 0 +monitoring = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource("CircleShape2D_ljsf5") diff --git a/Items/Weapons/Bow.cs b/Items/Weapons/Bow.cs new file mode 100644 index 0000000..cc4a78a --- /dev/null +++ b/Items/Weapons/Bow.cs @@ -0,0 +1,26 @@ +using Godot; + +namespace SupaLidlGame.Items.Weapons; + +public partial class Bow : ProjectileSpawner +{ + protected bool _isOnFire = false; + + protected Area2D _ignitionArea; + + protected override void SpawnProjectile(Scenes.Map map, + Vector2 direction, float velocityModifier = 1) + { + base.SpawnProjectile(map, direction, velocityModifier); + } + + public override void _Ready() + { + base._Ready(); + _ignitionArea = GetNode("IgnitionArea"); + _ignitionArea.AreaEntered += (Area2D area) => + { + _isOnFire = false; + }; + } +} diff --git a/Items/Weapons/Bow.tscn b/Items/Weapons/Bow.tscn index 9a9df29..f1d91d5 100644 --- a/Items/Weapons/Bow.tscn +++ b/Items/Weapons/Bow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://cgg0sfm2qeiwn"] +[gd_scene load_steps=16 format=3 uid="uid://cgg0sfm2qeiwn"] [ext_resource type="Texture2D" uid="uid://dam6aigkw8xs" path="res://Assets/Sprites/Items/bow-and-arrow.png" id="1_1ghvv"] [ext_resource type="Script" path="res://Items/Weapons/ProjectileSpawner.cs" id="1_76bur"] @@ -109,6 +109,8 @@ _data = { "idle": SubResource("Animation_riv7t") } +[sub_resource type="CircleShape2D" id="CircleShape2D_6b356"] + [node name="Bow" type="Node2D" node_paths=PackedStringArray("StateMachine")] y_sort_enabled = true script = ExtResource("1_76bur") @@ -170,3 +172,12 @@ libraries = { [node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] volume_db = -8.0 bus = &"Effects" + +[node name="IgnitionArea" type="Area2D" parent="."] +position = Vector2(8, 0) +collision_layer = 0 +collision_mask = 128 +monitorable = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="IgnitionArea"] +shape = SubResource("CircleShape2D_6b356") diff --git a/Items/Weapons/ProjectileSpawner.cs b/Items/Weapons/ProjectileSpawner.cs index 591d97a..6362899 100644 --- a/Items/Weapons/ProjectileSpawner.cs +++ b/Items/Weapons/ProjectileSpawner.cs @@ -24,7 +24,8 @@ public partial class ProjectileSpawner : Ranged [Export] public float ProjectileAngleDeviation { get; set; } - private void SpawnProjectile(Scenes.Map map, Vector2 direction, float v = 1) + protected virtual void SpawnProjectile(Scenes.Map map, + Vector2 direction, float velocityModifier = 1) { var projectile = map.SpawnEntity(Projectile); projectile.Hitbox.Faction = Character.Faction; @@ -33,7 +34,7 @@ public partial class ProjectileSpawner : Ranged if (ShouldOverrideVelocity) { - projectile.Speed = InitialVelocity * v; + projectile.Speed = InitialVelocity * velocityModifier; } if (ShouldRotate)