diff --git a/forge/abilities/ForgeSpawnProjectileBehavior.cs b/forge/abilities/ForgeSpawnProjectileBehavior.cs new file mode 100644 index 00000000..002f17df --- /dev/null +++ b/forge/abilities/ForgeSpawnProjectileBehavior.cs @@ -0,0 +1,42 @@ +using Gamesmiths.Forge.Abilities; +using Gamesmiths.Forge.Effects; +using Gamesmiths.Forge.Godot.Resources; +using Gamesmiths.Forge.Godot.Resources.Abilities; +using Godot; +using Movementtests.interfaces; + +namespace Movementtests.forge.abilities; + + +public class SpawnProjectileBehavior(PackedScene projectileScene) : IAbilityBehavior +{ + public void OnStarted(AbilityBehaviorContext context) + { + if (context.Target is not Node3D target || context.Source is not Node3D source) return; + + var sourceLocation = source.GlobalPosition; + + if (projectileScene.Instantiate() is not Projectile projectile) return; + source.GetTree().GetCurrentScene().AddChild(projectile); + + projectile.GlobalPosition = source is ITargetable targetable ? targetable.GetTargetGlobalPosition() : sourceLocation; + projectile.Target = target; + if (projectile is ISpawnable spawnable) spawnable.Init(); + + context.AbilityHandle.CommitAbility(); + context.InstanceHandle.End(); + } + + public void OnEnded(AbilityBehaviorContext context) + { + } +} + + +[Tool] +[GlobalClass] +public partial class ForgeSpawnProjectileBehavior : ForgeAbilityBehavior +{ + [Export] public required PackedScene Projectile { get; set; } + public override IAbilityBehavior GetBehavior() => new SpawnProjectileBehavior(Projectile); +} \ No newline at end of file diff --git a/forge/abilities/ForgeSpawnProjectileBehavior.cs.uid b/forge/abilities/ForgeSpawnProjectileBehavior.cs.uid new file mode 100644 index 00000000..60b1204e --- /dev/null +++ b/forge/abilities/ForgeSpawnProjectileBehavior.cs.uid @@ -0,0 +1 @@ +uid://dxtjifb8hv8k4 diff --git a/forge/forge_data.tres b/forge/forge_data.tres index d416082c..4935e8f8 100644 --- a/forge/forge_data.tres +++ b/forge/forge_data.tres @@ -4,4 +4,4 @@ [resource] script = ExtResource("1_l686n") -RegisteredTags = Array[String](["character.player", "character.enemy", "weapon", "status.stunned", "status.burning", "status.frozen", "abilities.weapon.land", "abilities.weapon.flying", "abilities.weapon.left", "events.combat.damage", "events.combat.hit", "events.weapon.flyingTick", "events.weapon.startedFlying", "events.weapon.stoppedFlying", "events.weapon.handToFlying", "events.weapon.flyingToHand", "events.weapon.plantedToHand", "events.weapon.plantedToFlying", "events.weapon.planted", "cooldown.empoweredAction", "cooldown.empoweredSwordThrow", "cues.resources.mana", "events.player.empowered_action_used", "cues.resources.mana.inhibited", "cues.resources.health", "cooldown.enemy.hit", "events.combat.death", "cooldown.hit", "events.player.hit", "cues.enemy.health", "immunity.damage", "status", "traits.damageable", "traits.knockbackable", "events.combat.knockback_dealt", "events.combat.knockback_received", "events.weapon.plantedtick", "events.weapon.unplanted", "abilities.weapon.planted", "events.enemy.try_hit", "events.enemy.launch_projectile"]) +RegisteredTags = Array[String](["character.player", "character.enemy", "status.stunned", "status.burning", "status.frozen", "abilities.weapon.land", "abilities.weapon.flying", "abilities.weapon.left", "events.combat.damage", "events.combat.hit", "events.weapon.flyingTick", "events.weapon.startedFlying", "events.weapon.stoppedFlying", "events.weapon.handToFlying", "events.weapon.flyingToHand", "events.weapon.plantedToHand", "events.weapon.plantedToFlying", "events.weapon.planted", "cooldown.empoweredAction", "cooldown.empoweredSwordThrow", "cues.resources.mana", "events.player.empowered_action_used", "cues.resources.mana.inhibited", "cues.resources.health", "cooldown.enemy.hit", "events.combat.death", "cooldown.hit", "events.player.hit", "cues.enemy.health", "immunity.damage", "status", "traits.damageable", "traits.knockbackable", "events.combat.knockback_dealt", "events.combat.knockback_received", "events.weapon.plantedtick", "events.weapon.unplanted", "abilities.weapon.planted", "events.enemy.try_hit", "events.enemy.launch_projectile", "objects.projectile", "objects.weapon", "events.enemy.request_projectile"]) diff --git a/forge/resources/ability_datas/weapon_planted_tick_ability.tres b/forge/resources/ability_datas/weapon_planted_tick_ability.tres index 4609db2f..435c9545 100644 --- a/forge/resources/ability_datas/weapon_planted_tick_ability.tres +++ b/forge/resources/ability_datas/weapon_planted_tick_ability.tres @@ -30,8 +30,8 @@ BaseValue = 1 [sub_resource type="Resource" id="Resource_hgeae"] script = ExtResource("4_4348y") Name = "Raise Planted Tick Periodically" -Modifiers = null -Components = null +Modifiers = [] +Components = [] Executions = Array[Object]([SubResource("Resource_l3tir")]) DurationType = 1 HasPeriodicApplication = true @@ -39,7 +39,7 @@ Period = SubResource("Resource_cykp3") ExecuteOnApplication = true StackLimit = SubResource("Resource_rvogu") InitialStack = SubResource("Resource_yc0gp") -Cues = null +Cues = [] metadata/_custom_type_script = "uid://b83hf13nj37k3" [sub_resource type="Resource" id="Resource_jiqxq"] diff --git a/forge/resources/behaviors/flying tick application ability behavior.tres b/forge/resources/behaviors/flying tick application ability behavior.tres index ec7096fd..aa069e07 100644 --- a/forge/resources/behaviors/flying tick application ability behavior.tres +++ b/forge/resources/behaviors/flying tick application ability behavior.tres @@ -6,5 +6,5 @@ [resource] script = ExtResource("2_f5qgs") EffectData = ExtResource("1_hlq5f") -Name = "Planted tick application" +Name = "Flying tick application" metadata/_custom_type_script = "uid://cl5hudinl1rex" diff --git a/forge/resources/effect_datas/raise_flying_tick_event_periodically.tres b/forge/resources/effect_datas/raise_flying_tick_event_periodically.tres index f0161d88..595f8047 100644 --- a/forge/resources/effect_datas/raise_flying_tick_event_periodically.tres +++ b/forge/resources/effect_datas/raise_flying_tick_event_periodically.tres @@ -20,7 +20,7 @@ BaseValue = 1 [resource] script = ExtResource("4_7ma6b") -Name = "Call Planted Tick Event Periodically" +Name = "Call Flying Tick Event Periodically" Modifiers = [] Components = [] Executions = Array[Object]([ExtResource("1_cd13a")]) diff --git a/scenes/enemies/Enemy.cs b/scenes/enemies/Enemy.cs index c5f252e5..38b17633 100644 --- a/scenes/enemies/Enemy.cs +++ b/scenes/enemies/Enemy.cs @@ -116,8 +116,6 @@ public partial class Enemy : CharacterBody3D, CMovement.RMovement = RMovement; CKnockback = GetNode("CKnockback") as IKnockbackable ?? throw new Exception("Knockback component not found"); CKnockback.RKnockback = RKnockback; - - // _hitAbilityHandle = Abilities.GrantAbilityPermanently(HitAbility.GetAbilityData(), 1, LevelComparison.None, this); } public void OnResolved() @@ -126,20 +124,25 @@ public partial class Enemy : CharacterBody3D, HealthBarWrapper.ResourceBar.Init(healthAttribute); healthAttribute.OnValueChanged += OnHealthChanged; - Events.Subscribe(Tag.RequestTag(TagsManager, "events.combat.hit"), - data => {GD.Print("Hit!");}); + // Events.Subscribe(Tag.RequestTag(TagsManager, "events.combat.hit"), data => {GD.Print("Hit!");}); Events.Subscribe(Tag.RequestTag(TagsManager, "events.combat.damage"), OnDamageReceived); Events.Subscribe(Tag.RequestTag(TagsManager, "events.combat.knockback_received"), OnKnockbackReceived); Events.Subscribe(Tag.RequestTag(TagsManager, "events.combat.death"), OnDeath); + Events.Subscribe(Tag.RequestTag(TagsManager, "events.enemy.request_projectile"), ProjectileTokenRequested); - GetTree().CreateTimer(3).Timeout += () => Events.Raise(new EventData + } + + private void ProjectileTokenRequested(EventData obj) + { + // TODO: replace with token manager + Events.Raise(new EventData { EventTags = Tag.RequestTag(TagsManager, "events.enemy.launch_projectile").GetSingleTagContainer()!, Source = this, Target = Target as IForgeEntity }); } - + public void OnKnockbackReceived(EventData data) { RegisterKnockback(new KnockbackRecord(data.Payload.knockbackDirection, data.EventMagnitude)); diff --git a/scenes/enemies/projectile_enemy/projectile_enemy.tscn b/scenes/enemies/projectile_enemy/projectile_enemy.tscn index 8390ce8d..fbafb99f 100644 --- a/scenes/enemies/projectile_enemy/projectile_enemy.tscn +++ b/scenes/enemies/projectile_enemy/projectile_enemy.tscn @@ -15,12 +15,18 @@ [ext_resource type="PackedScene" uid="uid://dbr7ioio158ew" path="res://scenes/components/movement/CGroundedMovement.tscn" id="10_d3cra"] [ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="11_f6vvi"] [ext_resource type="Script" uid="uid://dtpxijlnb2c5" path="res://scenes/components/movement/RMovement.cs" id="11_fi4yv"] +[ext_resource type="PackedScene" uid="uid://bhp6qunnwhncf" path="res://scenes/projectile/Projectile.tscn" id="12_5ac6t"] [ext_resource type="PackedScene" uid="uid://bctpe34ddamg5" path="res://scenes/components/knockback/CKnockback.tscn" id="12_7k8no"] -[ext_resource type="Resource" uid="uid://ifeavnlps7hy" path="res://forge/resources/behaviors/exploding_sword.tres" id="12_f6vvi"] +[ext_resource type="Texture2D" uid="uid://g0u88alm6hcb" path="res://assets/ui/IconGodotNode/node/icon_bullet.png" id="12_rlvdp"] [ext_resource type="Script" uid="uid://72kj3n4lm1em" path="res://addons/forge/resources/components/ForgeGrantAbilityConfig.cs" id="12_ssnfc"] [ext_resource type="Script" uid="uid://b3wo2uge4ddnj" path="res://addons/forge/resources/components/GrantAbility.cs" id="13_5ac6t"] +[ext_resource type="Script" uid="uid://dxtjifb8hv8k4" path="res://forge/abilities/ForgeSpawnProjectileBehavior.cs" id="13_rlvdp"] [ext_resource type="Resource" uid="uid://bkr1xfokymvp4" path="res://forge/resources/tag_containers/on_enemy_lauch_project.tres" id="13_ssnfc"] [ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="14_rlvdp"] +[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="17_xabdf"] +[ext_resource type="Script" uid="uid://br7ut4lbau66w" path="res://forge/calculators/ForgeRaiseEventTagExecution.cs" id="18_ufku3"] +[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="19_hgi6f"] +[ext_resource type="Script" uid="uid://cl5hudinl1rex" path="res://forge/abilities/ForgeEffectApplicationBehavior.cs" id="21_17f1o"] [sub_resource type="Resource" id="Resource_x50ya"] script = ExtResource("8_ti0v2") @@ -44,11 +50,18 @@ AbilityData = ExtResource("2_nbf6l") AbilityLevel = SubResource("Resource_55uge") metadata/_custom_type_script = "uid://72kj3n4lm1em" +[sub_resource type="Resource" id="Resource_idpl5"] +script = ExtResource("13_rlvdp") +Projectile = ExtResource("12_5ac6t") +Name = "Spawn projectile" +Icon = ExtResource("12_rlvdp") +metadata/_custom_type_script = "uid://dxtjifb8hv8k4" + [sub_resource type="Resource" id="Resource_5ac6t"] script = ExtResource("10_b62xo") -Name = "Test projectile" +Name = "Launch projectile" CooldownEffects = [] -AbilityBehavior = ExtResource("12_f6vvi") +AbilityBehavior = SubResource("Resource_idpl5") TriggerSource = 1 TriggerTag = ExtResource("13_ssnfc") metadata/_custom_type_script = "uid://dhxfbxh54pyxp" @@ -63,9 +76,69 @@ AbilityData = SubResource("Resource_5ac6t") AbilityLevel = SubResource("Resource_rlvdp") metadata/_custom_type_script = "uid://72kj3n4lm1em" +[sub_resource type="Resource" id="Resource_5xe4r"] +script = ExtResource("17_xabdf") +ContainerTags = Array[String](["events.enemy.request_projectile"]) +metadata/_custom_type_script = "uid://cw525n4mjqgw0" + +[sub_resource type="Resource" id="Resource_5hctm"] +script = ExtResource("18_ufku3") +EventTags = SubResource("Resource_5xe4r") +metadata/_custom_type_script = "uid://br7ut4lbau66w" + +[sub_resource type="Resource" id="Resource_xq5v1"] +script = ExtResource("11_f6vvi") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_s7hsu"] +script = ExtResource("19_hgi6f") +BaseValue = 1.0 +metadata/_custom_type_script = "uid://cn3b4ya15fg7e" + +[sub_resource type="Resource" id="Resource_xuuuu"] +script = ExtResource("11_f6vvi") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_nr327"] +script = ExtResource("14_rlvdp") +Name = "Raise request projectile event periodically" +Modifiers = [] +Components = [] +Executions = Array[Object]([SubResource("Resource_5hctm")]) +DurationType = 1 +HasPeriodicApplication = true +Period = SubResource("Resource_s7hsu") +StackLimit = SubResource("Resource_xuuuu") +InitialStack = SubResource("Resource_xq5v1") +Cues = [] +metadata/_custom_type_script = "uid://b83hf13nj37k3" + +[sub_resource type="Resource" id="Resource_ov8t2"] +script = ExtResource("21_17f1o") +EffectData = SubResource("Resource_nr327") +metadata/_custom_type_script = "uid://cl5hudinl1rex" + +[sub_resource type="Resource" id="Resource_gg1oy"] +script = ExtResource("10_b62xo") +Name = "Request projectile token event raise" +CooldownEffects = [] +AbilityBehavior = SubResource("Resource_ov8t2") +metadata/_custom_type_script = "uid://dhxfbxh54pyxp" + +[sub_resource type="Resource" id="Resource_r40oc"] +script = ExtResource("11_f6vvi") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_nu2lf"] +script = ExtResource("12_ssnfc") +AbilityData = SubResource("Resource_gg1oy") +AbilityLevel = SubResource("Resource_r40oc") +TryActivateOnGrant = true +metadata/_custom_type_script = "uid://72kj3n4lm1em" + [sub_resource type="Resource" id="Resource_ufku3"] script = ExtResource("13_5ac6t") -GrantAbilityConfigs = [SubResource("Resource_xabdf"), SubResource("Resource_ei7hs")] +GrantAbilityConfigs = [SubResource("Resource_xabdf"), SubResource("Resource_ei7hs"), SubResource("Resource_nu2lf")] metadata/_custom_type_script = "uid://b3wo2uge4ddnj" [sub_resource type="Resource" id="Resource_hgi6f"] @@ -79,15 +152,15 @@ BaseValue = 1 [sub_resource type="Resource" id="Resource_ytrix"] script = ExtResource("14_rlvdp") Name = "Grant abilities" -Modifiers = null +Modifiers = [] Components = Array[Object]([SubResource("Resource_ufku3")]) -Executions = null +Executions = [] StackLimit = SubResource("Resource_17f1o") InitialStack = SubResource("Resource_hgi6f") -Cues = null +Cues = [] metadata/_custom_type_script = "uid://b83hf13nj37k3" -[sub_resource type="ViewportTexture" id="ViewportTexture_3kqd1"] +[sub_resource type="ViewportTexture" id="ViewportTexture_f6vvi"] viewport_path = NodePath("SubViewport") [sub_resource type="Resource" id="Resource_6d4gl"] @@ -122,7 +195,6 @@ radius = 2.0 collision_layer = 16 collision_mask = 273 script = ExtResource("1_ha67n") -HitAbility = ExtResource("2_nbf6l") EnemyHeight = 2.0 RKnockback = ExtResource("3_ymgar") RMovement = ExtResource("4_0f52b") @@ -168,7 +240,7 @@ metadata/_custom_type_script = "uid://dps0oef50noil" [node name="CHealthBar" parent="." unique_id=1278247727 instance=ExtResource("9_6ew2r")] transform = Transform3D(0.4, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2, 0) -texture = SubResource("ViewportTexture_3kqd1") +texture = SubResource("ViewportTexture_f6vvi") [node name="CMovement" parent="." unique_id=1080640834 node_paths=PackedStringArray("WallInFrontRayCast") instance=ExtResource("10_d3cra")] RMovement = SubResource("Resource_6d4gl") diff --git a/scenes/player_controller/components/weapon/WeaponSystem.cs b/scenes/player_controller/components/weapon/WeaponSystem.cs index c98a4a67..04788848 100644 --- a/scenes/player_controller/components/weapon/WeaponSystem.cs +++ b/scenes/player_controller/components/weapon/WeaponSystem.cs @@ -91,9 +91,6 @@ public partial class WeaponSystem : RigidBody3D, IForgeEntity public Tag WeaponInHandStatusTag; public Tag WeaponFlyingStatusTag; public Tag WeaponPlantedStatusTag; - - public Tag WeaponFlyingAbilityTag; - public Tag WeaponPlantedAbilityTag; private AbilityHandle? _weaponFlyingAbility; private AbilityHandle? _weaponPlantedAbility; @@ -235,13 +232,11 @@ public partial class WeaponSystem : RigidBody3D, IForgeEntity // Manage weapon tick raising abilities if (FlyingTickAbility != null) { - WeaponFlyingAbilityTag = Tag.RequestTag(TagsManager,"abilities.weapon.flying"); _weaponFlyingAbility = Abilities.GrantAbilityPermanently(FlyingTickAbility.GetAbilityData(), 1, LevelComparison.None, this); Events.Subscribe(WeaponStoppedFlyingEventTag, _ => { _weaponFlyingAbility.Cancel(); }); } if (PlantedTickAbility != null) { - WeaponPlantedAbilityTag = Tag.RequestTag(TagsManager,"abilities.weapon.planted"); _weaponPlantedAbility = Abilities.GrantAbilityPermanently(PlantedTickAbility.GetAbilityData(), 1, LevelComparison.None, this); Events.Subscribe(WeaponUnplantedEventTag, _ => { _weaponPlantedAbility.Cancel(); }); } diff --git a/scenes/player_controller/components/weapon/weapon.tscn b/scenes/player_controller/components/weapon/weapon.tscn index e4a98350..050db17e 100644 --- a/scenes/player_controller/components/weapon/weapon.tscn +++ b/scenes/player_controller/components/weapon/weapon.tscn @@ -1,7 +1,6 @@ [gd_scene format=3 uid="uid://ckm3d6k08a72u"] [ext_resource type="Script" uid="uid://iii3wfto4t5b" path="res://scenes/player_controller/components/weapon/WeaponSystem.cs" id="1_csqwk"] -[ext_resource type="Resource" uid="uid://dgjsi1my7nlnk" path="res://forge/resources/ability_datas/player_hit.tres" id="2_2wsgo"] [ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="2_l1xlx"] [ext_resource type="Script" uid="uid://cxihb42t2mfqi" path="res://addons/forge/nodes/ForgeAttributeSet.cs" id="3_3xjpi"] [ext_resource type="Script" uid="uid://couw105c3bde4" path="res://addons/godot_state_charts/state_chart.gd" id="3_5owyf"] @@ -23,9 +22,9 @@ [ext_resource type="Script" uid="uid://72kj3n4lm1em" path="res://addons/forge/resources/components/ForgeGrantAbilityConfig.cs" id="14_i0jsb"] [ext_resource type="Script" uid="uid://b3wo2uge4ddnj" path="res://addons/forge/resources/components/GrantAbility.cs" id="15_a8u16"] -[sub_resource type="Resource" id="Resource_7bruw"] +[sub_resource type="Resource" id="Resource_rgbou"] script = ExtResource("2_l1xlx") -ContainerTags = Array[String](["weapon"]) +ContainerTags = Array[String](["objects.weapon"]) metadata/_custom_type_script = "uid://cw525n4mjqgw0" [sub_resource type="Resource" id="Resource_pgbtr"] @@ -125,13 +124,12 @@ continuous_cd = true contact_monitor = true max_contacts_reported = 1 script = ExtResource("1_csqwk") -OnPlantedInEnemy = ExtResource("2_2wsgo") FlyingTickAbility = ExtResource("4_7bruw") PlantedTickAbility = ExtResource("3_7bruw") [node name="ForgeEntityNode" type="Node3D" parent="." unique_id=1798885192] script = ExtResource("5_7bruw") -BaseTags = SubResource("Resource_7bruw") +BaseTags = SubResource("Resource_rgbou") metadata/_custom_type_script = "uid://rpcbb54q4atx" [node name="WeaponAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=14845649] diff --git a/scenes/projectile/Projectile.cs b/scenes/projectile/Projectile.cs new file mode 100644 index 00000000..e0db1a9c --- /dev/null +++ b/scenes/projectile/Projectile.cs @@ -0,0 +1,124 @@ +using Godot; +using System; +using Chickensoft.AutoInject; +using Chickensoft.Introspection; +using Gamesmiths.Forge.Abilities; +using Gamesmiths.Forge.Core; +using Gamesmiths.Forge.Cues; +using Gamesmiths.Forge.Effects; +using Gamesmiths.Forge.Events; +using Gamesmiths.Forge.Godot.Resources.Abilities; +using Gamesmiths.Forge.Statescript; +using Gamesmiths.Forge.Tags; +using Movementtests.interfaces; +using Movementtests.tools; +using Node = Godot.Node; + +[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_bullet.png"), Meta(typeof(IAutoNode))] +public partial class Projectile : RigidBody3D, IForgeEntity, ITargetable, IKillable, ISpawnable +{ + public override void _Notification(int what) => this.Notify(what); + + #region Dependencies + + [Dependency] + public TagsManager TagsManager => this.DependOn(); + [Dependency] + public CuesManager CuesManager => this.DependOn(); + + #endregion + + #region IForgeEntity + + // Perfectly forward the IForgeEntity interface to the ForgeEntity component + public EntityAttributes Attributes + { + get => ForgeEntity.Attributes; + set => ForgeEntity.Attributes = value; + } + public EntityTags Tags + { + get => ForgeEntity.Tags; + set => ForgeEntity.Tags = value; + } + public EffectsManager EffectsManager + { + get => ForgeEntity.EffectsManager; + set => ForgeEntity.EffectsManager = value; + } + public EntityAbilities Abilities + { + get => ForgeEntity.Abilities; + set => ForgeEntity.Abilities = value; + } + public EventManager Events + { + get => ForgeEntity.Events; + set => ForgeEntity.Events = value; + } + + public Variables SharedVariables + { + get => ForgeEntity.SharedVariables; + set => ForgeEntity.SharedVariables = value; + } + + #endregion + + [Node("ForgeEntityNode")] public required ForgeEntityNode ForgeEntity { get; set;} + + [Export] public float Damage = 10f; + + public Node3D Target { get; set; } + + public void Init() + { + ApplyCentralImpulse(Vector3.Up * 10); + } + + public override void _IntegrateForces(PhysicsDirectBodyState3D state) + { + var direction = GlobalPosition.DirectionTo(Target.GlobalPosition); + state.LinearVelocity += direction / 10.0f; + } + + public void OnResolved() + { + BodyEntered += OnProjectileHit; + + // Events.Subscribe(Tag.RequestTag(TagsManager, "events.weapon.flyingtick"), data => { GD.Print("tick"); }); + } + + private void OnProjectileHit(Node body) + { + if (body is IForgeEntity entity) + { + Events.Raise(new EventData + { + EventTags = Tag.RequestTag(TagsManager, "events.combat.hit").GetSingleTagContainer()!, + Source = this, + Target = entity, + EventMagnitude = Damage + }); + } + + Events.Raise(new EventData + { + EventTags = Tag.RequestTag(TagsManager, "events.weapon.planted").GetSingleTagContainer()!, + Source = this, + EventMagnitude = Damage + }); + + Kill(); + } + + public Vector3 GetTargetGlobalPosition() + { + return GlobalPosition; + } + + public void Kill() + { + QueueFree(); // If thrown offmap + } +} diff --git a/scenes/projectile/Projectile.cs.uid b/scenes/projectile/Projectile.cs.uid new file mode 100644 index 00000000..2da6ef55 --- /dev/null +++ b/scenes/projectile/Projectile.cs.uid @@ -0,0 +1 @@ +uid://bmpfvyccbou3b diff --git a/scenes/projectile/Projectile.tscn b/scenes/projectile/Projectile.tscn new file mode 100644 index 00000000..76a4dda7 --- /dev/null +++ b/scenes/projectile/Projectile.tscn @@ -0,0 +1,236 @@ +[gd_scene format=3 uid="uid://bhp6qunnwhncf"] + +[ext_resource type="Script" uid="uid://bmpfvyccbou3b" path="res://scenes/projectile/Projectile.cs" id="1_bwggc"] +[ext_resource type="Resource" uid="uid://btnnpqann3ktp" path="res://forge/resources/ability_datas/weapon_flying_tick_ability.tres" id="2_gxghe"] +[ext_resource type="Script" uid="uid://rpcbb54q4atx" path="res://forge/ForgeEntityNode.cs" id="3_0m0gv"] +[ext_resource type="Script" uid="uid://cxihb42t2mfqi" path="res://addons/forge/nodes/ForgeAttributeSet.cs" id="3_8gwhl"] +[ext_resource type="Script" uid="uid://ccovd5i0wr3kk" path="res://addons/forge/editor/attributes/AttributeValues.cs" id="4_bwggc"] +[ext_resource type="Script" uid="uid://dps0oef50noil" path="res://addons/forge/nodes/ForgeEffect.cs" id="6_j80uc"] +[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="7_hwhpw"] +[ext_resource type="Resource" uid="uid://bpovqvlqv5bs5" path="res://forge/resources/effect_components/damageable.tres" id="7_ufml1"] +[ext_resource type="Resource" uid="uid://sn6kndc6ukic" path="res://forge/resources/tag_containers/on_damage_dealt.tres" id="8_4opcx"] +[ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="8_eb14h"] +[ext_resource type="Resource" uid="uid://5tr54q0rdpho" path="res://forge/resources/tag_containers/on_damage_taken.tres" id="9_0m0gv"] +[ext_resource type="Script" uid="uid://72kj3n4lm1em" path="res://addons/forge/resources/components/ForgeGrantAbilityConfig.cs" id="9_ah28r"] +[ext_resource type="Script" uid="uid://cfx62w40nd84v" path="res://forge/calculators/ForgeDamageExecution.cs" id="10_gxghe"] +[ext_resource type="Script" uid="uid://b3wo2uge4ddnj" path="res://addons/forge/resources/components/GrantAbility.cs" id="10_mss85"] +[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="11_aepsp"] +[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="12_6slh1"] +[ext_resource type="Script" uid="uid://bdfcavbjyhxxa" path="res://addons/forge/resources/ForgeModifier.cs" id="13_nh3w7"] +[ext_resource type="Script" uid="uid://n6efm5o4uxvr" path="res://forge/abilities/ForgeSimpleHitBehavior.cs" id="15_7ctk5"] +[ext_resource type="Script" uid="uid://dpakv7agvir6y" path="res://addons/forge/resources/ForgeTag.cs" id="16_4opcx"] +[ext_resource type="Script" uid="uid://bnee6amtc2bhj" path="res://forge/abilities/ForgeExplodingSwordBehavior.cs" id="19_0m0gv"] +[ext_resource type="PackedScene" uid="uid://duju3atqgltkg" path="res://scenes/explosion/explosion.tscn" id="19_gxghe"] + +[sub_resource type="Resource" id="Resource_n3xfy"] +script = ExtResource("10_gxghe") +DamageType = 1 +DamageDealerEventTags = ExtResource("8_4opcx") +DamageReceiverEventTags = ExtResource("9_0m0gv") +metadata/_custom_type_script = "uid://cfx62w40nd84v" + +[sub_resource type="Resource" id="Resource_5se5x"] +script = ExtResource("8_eb14h") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_tsnac"] +script = ExtResource("12_6slh1") +BaseValue = 1.0 + +[sub_resource type="Resource" id="Resource_4tmlu"] +script = ExtResource("12_6slh1") + +[sub_resource type="Resource" id="Resource_nsq4o"] +script = ExtResource("12_6slh1") + +[sub_resource type="Resource" id="Resource_wvq73"] +script = ExtResource("12_6slh1") +BaseValue = 1.0 + +[sub_resource type="Resource" id="Resource_ocyfe"] +script = ExtResource("12_6slh1") + +[sub_resource type="Resource" id="Resource_idlka"] +script = ExtResource("12_6slh1") + +[sub_resource type="Resource" id="Resource_uh7hr"] +script = ExtResource("12_6slh1") +BaseValue = 10.0 +metadata/_custom_type_script = "uid://cn3b4ya15fg7e" + +[sub_resource type="Resource" id="Resource_ckp55"] +script = ExtResource("13_nh3w7") +Attribute = "MetaAttributeSet.IncomingDamage" +Operation = 2 +ScalableFloat = SubResource("Resource_uh7hr") +Coefficient = SubResource("Resource_wvq73") +PreMultiplyAdditiveValue = SubResource("Resource_idlka") +PostMultiplyAdditiveValue = SubResource("Resource_ocyfe") +CalculatorCoefficient = SubResource("Resource_tsnac") +CalculatorPreMultiplyAdditiveValue = SubResource("Resource_nsq4o") +CalculatorPostMultiplyAdditiveValue = SubResource("Resource_4tmlu") +metadata/_custom_type_script = "uid://bdfcavbjyhxxa" + +[sub_resource type="Resource" id="Resource_yl520"] +script = ExtResource("8_eb14h") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_1kwc2"] +script = ExtResource("11_aepsp") +Name = "Projectile damate" +Modifiers = Array[Object]([SubResource("Resource_ckp55")]) +Components = Array[Object]([ExtResource("7_ufml1")]) +Executions = Array[Object]([SubResource("Resource_n3xfy")]) +StackLimit = SubResource("Resource_yl520") +InitialStack = SubResource("Resource_5se5x") +Cues = [] +metadata/_custom_type_script = "uid://b83hf13nj37k3" + +[sub_resource type="Resource" id="Resource_3icyc"] +script = ExtResource("15_7ctk5") +DamageEffect = SubResource("Resource_1kwc2") +metadata/_custom_type_script = "uid://n6efm5o4uxvr" + +[sub_resource type="Resource" id="Resource_7ctk5"] +script = ExtResource("16_4opcx") +Tag = "events.combat.hit" +metadata/_custom_type_script = "uid://dpakv7agvir6y" + +[sub_resource type="Resource" id="Resource_iburv"] +script = ExtResource("7_hwhpw") +Name = "On player hit" +CooldownEffects = [] +AbilityBehavior = SubResource("Resource_3icyc") +TriggerSource = 1 +TriggerTag = SubResource("Resource_7ctk5") +metadata/_custom_type_script = "uid://dhxfbxh54pyxp" + +[sub_resource type="Resource" id="Resource_ufml1"] +script = ExtResource("8_eb14h") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_4opcx"] +script = ExtResource("9_ah28r") +AbilityData = SubResource("Resource_iburv") +AbilityLevel = SubResource("Resource_ufml1") +metadata/_custom_type_script = "uid://72kj3n4lm1em" + +[sub_resource type="Resource" id="Resource_uhv33"] +script = ExtResource("19_0m0gv") +Explosion = ExtResource("19_gxghe") +Radius = 10.0 +metadata/_custom_type_script = "uid://bnee6amtc2bhj" + +[sub_resource type="Resource" id="Resource_hnbha"] +script = ExtResource("16_4opcx") +Tag = "events.weapon.planted" +metadata/_custom_type_script = "uid://dpakv7agvir6y" + +[sub_resource type="Resource" id="Resource_ynqlf"] +script = ExtResource("7_hwhpw") +Name = "Explode on contact" +CooldownEffects = [] +AbilityBehavior = SubResource("Resource_uhv33") +TriggerSource = 1 +TriggerTag = SubResource("Resource_hnbha") +metadata/_custom_type_script = "uid://dhxfbxh54pyxp" + +[sub_resource type="Resource" id="Resource_ltce2"] +script = ExtResource("8_eb14h") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_xxtl1"] +script = ExtResource("9_ah28r") +AbilityData = SubResource("Resource_ynqlf") +AbilityLevel = SubResource("Resource_ltce2") +metadata/_custom_type_script = "uid://72kj3n4lm1em" + +[sub_resource type="Resource" id="Resource_h6udq"] +script = ExtResource("8_eb14h") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_k64oi"] +script = ExtResource("9_ah28r") +AbilityData = ExtResource("2_gxghe") +AbilityLevel = SubResource("Resource_h6udq") +TryActivateOnGrant = true +metadata/_custom_type_script = "uid://72kj3n4lm1em" + +[sub_resource type="Resource" id="Resource_0m0gv"] +script = ExtResource("10_mss85") +GrantAbilityConfigs = [SubResource("Resource_4opcx"), SubResource("Resource_xxtl1"), SubResource("Resource_k64oi")] +metadata/_custom_type_script = "uid://b3wo2uge4ddnj" + +[sub_resource type="Resource" id="Resource_gxghe"] +script = ExtResource("8_eb14h") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_6slh1"] +script = ExtResource("8_eb14h") +BaseValue = 1 + +[sub_resource type="Resource" id="Resource_nh3w7"] +script = ExtResource("11_aepsp") +Name = "Grant abilities" +Modifiers = [] +Components = Array[Object]([SubResource("Resource_0m0gv")]) +Executions = [] +StackLimit = SubResource("Resource_6slh1") +InitialStack = SubResource("Resource_gxghe") +Cues = [] +metadata/_custom_type_script = "uid://b83hf13nj37k3" + +[sub_resource type="SphereShape3D" id="SphereShape3D_16rri"] +radius = 0.2 + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_bwggc"] +albedo_color = Color(0.9999997, 0.34948558, 0.033228315, 1) + +[sub_resource type="SphereMesh" id="SphereMesh_p7dfg"] +material = SubResource("StandardMaterial3D_bwggc") +radius = 0.4 +height = 0.8 + +[sub_resource type="SphereShape3D" id="SphereShape3D_p7dfg"] +radius = 2.0 + +[node name="Projectile" type="RigidBody3D" unique_id=1536748036] +collision_layer = 32 +collision_mask = 289 +continuous_cd = true +contact_monitor = true +max_contacts_reported = 1 +script = ExtResource("1_bwggc") + +[node name="ForgeEntityNode" type="Node3D" parent="." unique_id=1961065393] +script = ExtResource("3_0m0gv") +metadata/_custom_type_script = "uid://rpcbb54q4atx" + +[node name="ForgeAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=100377985] +script = ExtResource("3_8gwhl") +AttributeSetClass = "MetaAttributeSet" +InitialAttributeValues = Dictionary[String, ExtResource("4_bwggc")]({ +"IncomingDamage": Object(RefCounted,"script":ExtResource("4_bwggc"),"Default":0,"Min":0,"Max":1000) +, +"Level": Object(RefCounted,"script":ExtResource("4_bwggc"),"Default":1,"Min":1,"Max":1000) + +}) +metadata/_custom_type_script = "uid://cxihb42t2mfqi" + +[node name="GrantAbilities" type="Node" parent="ForgeEntityNode" unique_id=699633438] +script = ExtResource("6_j80uc") +EffectData = SubResource("Resource_nh3w7") +metadata/_custom_type_script = "uid://dps0oef50noil" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=2109664666] +shape = SubResource("SphereShape3D_16rri") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=472918778] +mesh = SubResource("SphereMesh_p7dfg") + +[node name="AimAssistTarget" type="Area3D" parent="." unique_id=734689820] +collision_layer = 64 +collision_mask = 0 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="AimAssistTarget" unique_id=1220912429] +shape = SubResource("SphereShape3D_p7dfg")