Compare commits

...

6 Commits

Author SHA1 Message Date
dc81796d52 fixed cue issue and setup proper waves
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 26s
Create tag and build when new code gets to main / Export (push) Has been cancelled
2026-05-16 20:56:20 +02:00
2103832e46 all spawners available can be used on first wave tick 2026-05-16 19:56:07 +02:00
1898d91a28 wave behavior and fixed explosion 2026-05-16 19:48:48 +02:00
b3ae3e37ea fixed weapon loss bug 2026-05-16 13:19:01 +02:00
4cd67023d9 token manager for projectile 2026-05-16 01:29:02 +02:00
afa335e7bf stunnable targets on hit 2026-05-15 15:29:24 +02:00
52 changed files with 987 additions and 90 deletions

View File

@@ -3,19 +3,21 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bun38n3ff5wvv"
path="res://.godot/imported/keyboard_shift_icon_outline.svg-21854f9aeab065c26ab9185b7d09e5f2.ctex"
path.s3tc="res://.godot/imported/keyboard_shift_icon_outline.svg-21854f9aeab065c26ab9185b7d09e5f2.s3tc.ctex"
path.etc2="res://.godot/imported/keyboard_shift_icon_outline.svg-21854f9aeab065c26ab9185b7d09e5f2.etc2.ctex"
metadata={
"vram_texture": false
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://assets/ui/input-prompts/Keyboard & Mouse/Vector/keyboard_shift_icon_outline.svg"
dest_files=["res://.godot/imported/keyboard_shift_icon_outline.svg-21854f9aeab065c26ab9185b7d09e5f2.ctex"]
dest_files=["res://.godot/imported/keyboard_shift_icon_outline.svg-21854f9aeab065c26ab9185b7d09e5f2.s3tc.ctex", "res://.godot/imported/keyboard_shift_icon_outline.svg-21854f9aeab065c26ab9185b7d09e5f2.etc2.ctex"]
[params]
compress/mode=0
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
@@ -23,7 +25,7 @@ compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
@@ -37,7 +39,7 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -6,18 +6,21 @@ using Godot;
namespace Movementtests.forge.abilities;
public class ManualCancelHitBehavior(ForgeEffectData? damage) : IAbilityBehavior
public class ManualCancelHitBehavior(ForgeEffectData[] effects) : IAbilityBehavior
{
public void OnStarted(AbilityBehaviorContext context)
{
if (context.Target == null || damage == null) return;
if (context.Target == null) return;
var sourceLocation = (context.Source as Node3D)?.GlobalPosition ?? Vector3.Zero;
var targetLocation = (context.Target as Node3D)?.GlobalPosition ?? Vector3.Zero;
var magnitude = context.Magnitude == 0 ? 1 : context.Magnitude;
var effect = new Effect(damage.GetEffectData(), new EffectOwnership(context.Owner, context.Owner));
context.Target.EffectsManager.ApplyEffect(effect, new SimpleHitEffectData(sourceLocation, targetLocation, magnitude));
foreach (var effectData in effects)
{
var effect = new Effect(effectData.GetEffectData(), new EffectOwnership(context.Owner, context.Owner));
context.Target.EffectsManager.ApplyEffect(effect, new SimpleHitEffectData(sourceLocation, targetLocation, magnitude));
}
}
public void OnEnded(AbilityBehaviorContext context)
@@ -30,6 +33,6 @@ public class ManualCancelHitBehavior(ForgeEffectData? damage) : IAbilityBehavior
[GlobalClass]
public partial class ForgeManualCancelHitBehavior : ForgeAbilityBehavior
{
[Export] public ForgeEffectData? DamageEffect { get; set; }
public override IAbilityBehavior GetBehavior() => new ManualCancelHitBehavior(DamageEffect);
[Export] public ForgeEffectData[] OnHitEffects { get; set; } = [];
public override IAbilityBehavior GetBehavior() => new ManualCancelHitBehavior(OnHitEffects);
}

View File

@@ -5,11 +5,12 @@ using Gamesmiths.Forge.Godot.Resources;
using Gamesmiths.Forge.Godot.Resources.Abilities;
using Godot;
using Movementtests.interfaces;
using Movementtests.managers;
using Movementtests.tools;
namespace Movementtests.forge.abilities;
public record OnProjectileSpawned(Vector3 Direction, float SpeedMultiplier, Vector3? SpawnOffset = null, uint? CollisionOverride = null);
public record OnProjectileSpawned(Vector3 Direction, float SpeedMultiplier, Vector3? SpawnOffset = null, uint? CollisionOverride = null, TokenManager.Token? Token = null);
public class SpawnProjectileBehavior(PackedScene projectileScene) : IAbilityBehavior<OnProjectileSpawned>
{
@@ -31,13 +32,12 @@ public class SpawnProjectileBehavior(PackedScene projectileScene) : IAbilityBeha
var impulse = data.Direction * data.SpeedMultiplier * magnitude;
var collisionOverride = data.CollisionOverride ?? projectile.CollisionMask;
GD.Print(impulse);
// Setting up projectile
projectile.GlobalPosition = startPos + offset;
projectile.Target = target;
projectile.ImpulseDirection = impulse;
projectile.CollisionMask = collisionOverride;
projectile.Token = data.Token;
if (projectile is ISpawnable spawnable) spawnable.Init();

View File

@@ -30,6 +30,7 @@ public class DamageExecution : CustomExecution
public DamageExecution(DamageType damageType, ForgeTagContainer? damageDealerEventTags, ForgeTagContainer? damageReceiverEventTags)
{
// Capture target mana and magic resistance
TargetHealth = new AttributeCaptureDefinition(
"CharacterAttributeSet.Health",
@@ -60,6 +61,8 @@ public class DamageExecution : CustomExecution
target,
effectEvaluatedData);
GD.Print(targetIncomingDamage);
if (targetIncomingDamage <= 0)
{
return [.. results];
@@ -70,6 +73,7 @@ public class DamageExecution : CustomExecution
targetIncomingDamage *= hitEffectData.Magnitude;
}
// Apply health reduction to target if attribute exists
if (TargetHealth.TryGetAttribute(target, out EntityAttribute? targetHealthAttribute))
{

View File

@@ -18,16 +18,18 @@ public record KnockbackDone(float KnockbackValue, Vector3 knockbackDirection);
public class KnockbackExecution : CustomExecution
{
private readonly RKnockback _knockback;
private readonly ForgeTag _knockbackTag;
private readonly ForgeTag _knockbackableTag;
private readonly ForgeTag _knockbackImmuneTag;
private readonly ForgeTagContainer? _knockbackReceiverEventTags;
private readonly ForgeTagContainer? _knockbackDealerEventTags;
public AttributeCaptureDefinition TargetIncomingDamage { get; }
public KnockbackExecution(ForgeTag knockbackTag, RKnockback knockback, ForgeTagContainer? knockbackDealerEventTags, ForgeTagContainer? knockbackReceiverEventTags)
public KnockbackExecution(ForgeTag knockbackableTag, ForgeTag knockbackImmuneTag, RKnockback knockback, ForgeTagContainer? knockbackDealerEventTags, ForgeTagContainer? knockbackReceiverEventTags)
{
_knockback = knockback;
_knockbackTag = knockbackTag;
_knockbackableTag = knockbackableTag;
_knockbackImmuneTag = knockbackImmuneTag;
_knockbackDealerEventTags = knockbackDealerEventTags;
_knockbackReceiverEventTags = knockbackReceiverEventTags;
@@ -40,7 +42,7 @@ public class KnockbackExecution : CustomExecution
public override ModifierEvaluatedData[] EvaluateExecution(Effect effect, IForgeEntity target, EffectEvaluatedData? effectEvaluatedData)
{
var results = new List<ModifierEvaluatedData>();
if (!target.Tags.CombinedTags.HasTag(_knockbackTag.GetTag()))
if (!target.Tags.CombinedTags.HasTag(_knockbackableTag.GetTag()) || target.Tags.CombinedTags.HasTag(_knockbackImmuneTag.GetTag()))
return [.. results];
float targetIncomingDamage = CaptureAttributeMagnitude(
@@ -91,12 +93,13 @@ public class KnockbackExecution : CustomExecution
public partial class ForgeKnockbackExecution : ForgeCustomExecution
{
[Export] public ForgeTag? KnockbackableTag { get; set; }
[Export] public ForgeTag? KnockbackImmuneTag { get; set; }
[Export] public RKnockback? Knockback { get; set; }
[Export] public ForgeTagContainer? KnockbackDealerEventTags { get; set; }
[Export] public ForgeTagContainer? KnockbackReceiverEventTags { get; set; }
public override CustomExecution GetExecutionClass()
{
if (Knockback == null || KnockbackableTag == null) throw new System.ArgumentException("Knockback or KnockbackableTag is null");
return new KnockbackExecution(KnockbackableTag, Knockback, KnockbackDealerEventTags, KnockbackReceiverEventTags);
if (Knockback == null || KnockbackableTag == null || KnockbackImmuneTag == null) throw new System.ArgumentException("Knockback or KnockbackableTag is null");
return new KnockbackExecution(KnockbackableTag, KnockbackImmuneTag, Knockback, KnockbackDealerEventTags, KnockbackReceiverEventTags);
}
}

View File

@@ -4,4 +4,4 @@
[resource]
script = ExtResource("1_l686n")
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", "events.player.parry"])
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", "events.player.parry", "traits.stunnable", "immunity.knockback", "immunity.stun", "events.combat.stun_applied", "events.combat.stun_received"])

View File

@@ -6,6 +6,7 @@
[ext_resource type="Script" uid="uid://cfx62w40nd84v" path="res://forge/calculators/ForgeDamageExecution.cs" id="4_xfamx"]
[ext_resource type="Script" uid="uid://b44cse62qru7j" path="res://scenes/components/knockback/RKnockback.cs" id="5_tw4gc"]
[ext_resource type="Resource" uid="uid://bhn27s8ne0uyg" path="res://forge/resources/tag_containers/on_knockback_dealt.tres" id="6_nq3a0"]
[ext_resource type="Resource" uid="uid://5obdxlcpw8qt" path="res://forge/resources/tag_containers/knockback_immune.tres" id="7_3ma4g"]
[ext_resource type="Resource" uid="uid://bkr6uu57wm3o3" path="res://forge/resources/tag_containers/on_knockback_received.tres" id="7_3utx7"]
[ext_resource type="Resource" uid="uid://45l7vnfs72b" path="res://forge/resources/tag_containers/knockbackable_tag.tres" id="8_7hfxb"]
[ext_resource type="Script" uid="uid://diondfg5xp78h" path="res://forge/calculators/ForgeKnockbackExecution.cs" id="9_lysxe"]
@@ -32,6 +33,7 @@ metadata/_custom_type_script = "uid://b44cse62qru7j"
[sub_resource type="Resource" id="Resource_dy671"]
script = ExtResource("9_lysxe")
KnockbackableTag = ExtResource("8_7hfxb")
KnockbackImmuneTag = ExtResource("7_3ma4g")
Knockback = SubResource("Resource_ndb8p")
KnockbackDealerEventTags = ExtResource("6_nq3a0")
KnockbackReceiverEventTags = ExtResource("7_3utx7")
@@ -89,7 +91,7 @@ BaseValue = 1
script = ExtResource("13_c85am")
Name = "Explosion hit"
Modifiers = Array[Object]([SubResource("Resource_xwtie")])
Components = Array[Object]([ExtResource("1_w36j6")])
Components = [ExtResource("1_w36j6")]
Executions = Array[Object]([SubResource("Resource_vy8wr"), SubResource("Resource_dy671")])
StackLimit = SubResource("Resource_ikb7l")
InitialStack = SubResource("Resource_i0sj3")

View File

@@ -6,13 +6,98 @@
[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="2_5vjbv"]
[ext_resource type="Script" uid="uid://d1bb1fvh1mnpd" path="res://forge/abilities/ForgeManualCancelHitBehavior.cs" id="2_c4wry"]
[ext_resource type="Script" uid="uid://dngf30hxy5go4" path="res://addons/forge/resources/components/ModifierTags.cs" id="2_jwyed"]
[ext_resource type="Resource" uid="uid://vs6kfo2ubhvr" path="res://forge/resources/effect_components/stunnable.tres" id="2_r7waw"]
[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="3_w1wo0"]
[ext_resource type="Script" uid="uid://cn3b4ya15fg7e" path="res://addons/forge/resources/magnitudes/ForgeScalableFloat.cs" id="4_c4wry"]
[ext_resource type="Script" uid="uid://2gm1hdhi8u08" path="res://addons/forge/resources/magnitudes/ForgeModifierMagnitude.cs" id="5_0cyim"]
[ext_resource type="Script" uid="uid://br7ut4lbau66w" path="res://forge/calculators/ForgeRaiseEventTagExecution.cs" id="7_l5emy"]
[sub_resource type="Resource" id="Resource_h8gc3"]
script = ExtResource("1_w1wo0")
ContainerTags = Array[String](["status.stunned"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[sub_resource type="Resource" id="Resource_vioyh"]
script = ExtResource("2_jwyed")
TagsToAdd = SubResource("Resource_h8gc3")
metadata/_custom_type_script = "uid://dngf30hxy5go4"
[sub_resource type="Resource" id="Resource_m6xnn"]
script = ExtResource("4_c4wry")
BaseValue = 1.0
[sub_resource type="Resource" id="Resource_uinv8"]
script = ExtResource("4_c4wry")
[sub_resource type="Resource" id="Resource_04hqa"]
script = ExtResource("4_c4wry")
[sub_resource type="Resource" id="Resource_8fbeq"]
script = ExtResource("4_c4wry")
BaseValue = 1.0
[sub_resource type="Resource" id="Resource_ees2v"]
script = ExtResource("4_c4wry")
[sub_resource type="Resource" id="Resource_6x2ov"]
script = ExtResource("4_c4wry")
[sub_resource type="Resource" id="Resource_ml8x2"]
script = ExtResource("4_c4wry")
BaseValue = 1.0
metadata/_custom_type_script = "uid://cn3b4ya15fg7e"
[sub_resource type="Resource" id="Resource_1uqo4"]
script = ExtResource("5_0cyim")
ScalableFloat = SubResource("Resource_ml8x2")
Coefficient = SubResource("Resource_8fbeq")
PreMultiplyAdditiveValue = SubResource("Resource_6x2ov")
PostMultiplyAdditiveValue = SubResource("Resource_ees2v")
CalculatorCoefficient = SubResource("Resource_m6xnn")
CalculatorPreMultiplyAdditiveValue = SubResource("Resource_04hqa")
CalculatorPostMultiplyAdditiveValue = SubResource("Resource_uinv8")
metadata/_custom_type_script = "uid://2gm1hdhi8u08"
[sub_resource type="Resource" id="Resource_fyrcc"]
script = ExtResource("1_w1wo0")
ContainerTags = Array[String](["events.combat.stun_applied"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[sub_resource type="Resource" id="Resource_sgtcb"]
script = ExtResource("1_w1wo0")
ContainerTags = Array[String](["events.combat.stun_received"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[sub_resource type="Resource" id="Resource_3p0ly"]
script = ExtResource("7_l5emy")
EventTags = SubResource("Resource_fyrcc")
TargetEventTags = SubResource("Resource_sgtcb")
metadata/_custom_type_script = "uid://br7ut4lbau66w"
[sub_resource type="Resource" id="Resource_ewmvj"]
script = ExtResource("1_l0l1a")
BaseValue = 1
[sub_resource type="Resource" id="Resource_8wvcn"]
script = ExtResource("1_l0l1a")
BaseValue = 1
[sub_resource type="Resource" id="Resource_no8t2"]
script = ExtResource("2_5vjbv")
Name = "Basic stun"
Modifiers = Array[Object]([])
Components = Array[Object]([ExtResource("2_r7waw"), SubResource("Resource_vioyh")])
Executions = [SubResource("Resource_3p0ly")]
DurationType = 2
Duration = SubResource("Resource_1uqo4")
StackLimit = SubResource("Resource_8wvcn")
InitialStack = SubResource("Resource_ewmvj")
Cues = []
metadata/_custom_type_script = "uid://b83hf13nj37k3"
[sub_resource type="Resource" id="Resource_0cyim"]
script = ExtResource("2_c4wry")
DamageEffect = ExtResource("1_c4wry")
OnHitEffects = [ExtResource("1_c4wry"), SubResource("Resource_no8t2")]
Name = "Player hit"
metadata/_custom_type_script = "uid://d1bb1fvh1mnpd"

View File

@@ -3,6 +3,7 @@
[ext_resource type="Script" uid="uid://b44cse62qru7j" path="res://scenes/components/knockback/RKnockback.cs" id="1_kcl5u"]
[ext_resource type="Resource" uid="uid://bhn27s8ne0uyg" path="res://forge/resources/tag_containers/on_knockback_dealt.tres" id="2_oqtq1"]
[ext_resource type="Resource" uid="uid://bkr6uu57wm3o3" path="res://forge/resources/tag_containers/on_knockback_received.tres" id="3_1va1b"]
[ext_resource type="Resource" uid="uid://5obdxlcpw8qt" path="res://forge/resources/tag_containers/knockback_immune.tres" id="3_oqtq1"]
[ext_resource type="Resource" uid="uid://45l7vnfs72b" path="res://forge/resources/tag_containers/knockbackable_tag.tres" id="4_0i0oh"]
[ext_resource type="Script" uid="uid://diondfg5xp78h" path="res://forge/calculators/ForgeKnockbackExecution.cs" id="5_babc1"]
@@ -14,6 +15,7 @@ metadata/_custom_type_script = "uid://b44cse62qru7j"
[resource]
script = ExtResource("5_babc1")
KnockbackableTag = ExtResource("4_0i0oh")
KnockbackImmuneTag = ExtResource("3_oqtq1")
Knockback = SubResource("Resource_6x2ov")
KnockbackDealerEventTags = ExtResource("2_oqtq1")
KnockbackReceiverEventTags = ExtResource("3_1va1b")

View File

@@ -0,0 +1,20 @@
[gd_resource type="Resource" script_class="TargetTagRequirements" format=3 uid="uid://vs6kfo2ubhvr"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="1_52mex"]
[ext_resource type="Script" uid="uid://b0eq12mjqfage" path="res://addons/forge/resources/components/TargetTagRequirements.cs" id="2_d06a4"]
[sub_resource type="Resource" id="Resource_r7waw"]
script = ExtResource("1_52mex")
ContainerTags = Array[String](["immunity.stun"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[sub_resource type="Resource" id="Resource_vioyh"]
script = ExtResource("1_52mex")
ContainerTags = Array[String](["traits.stunnable"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[resource]
script = ExtResource("2_d06a4")
ApplicationRequiredTags = SubResource("Resource_vioyh")
ApplicationIgnoredTags = SubResource("Resource_r7waw")
metadata/_custom_type_script = "uid://b0eq12mjqfage"

View File

@@ -4,5 +4,5 @@
[resource]
script = ExtResource("1_kdy2b")
ContainerTags = Array[String](["character.enemy", "traits.damageable", "traits.knockbackable"])
ContainerTags = Array[String](["character.enemy", "traits.damageable", "traits.knockbackable", "traits.stunnable"])
metadata/_custom_type_script = "uid://cw525n4mjqgw0"

View File

@@ -0,0 +1,8 @@
[gd_resource type="Resource" script_class="ForgeTag" format=3 uid="uid://5obdxlcpw8qt"]
[ext_resource type="Script" uid="uid://dpakv7agvir6y" path="res://addons/forge/resources/ForgeTag.cs" id="1_pjklh"]
[resource]
script = ExtResource("1_pjklh")
Tag = "immunity.knockback"
metadata/_custom_type_script = "uid://dpakv7agvir6y"

View File

@@ -5,9 +5,10 @@ namespace Movementtests.interfaces;
public record MovementInputs(
Vector3 Velocity = default,
Vector3 TargetLocation = default,
bool isOnFloor = false,
Vector3 gravity = default,
double delta = 0);
bool IsOnFloor = false,
bool IsStunned = false,
Vector3 Gravity = default,
double Delta = 0);
public interface IMoveable
{

61
managers/TokenManager.cs Normal file
View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
namespace Movementtests.managers;
[GlobalClass, Meta(typeof(IAutoNode))]
public partial class TokenManager : Node
{
public override void _Notification(int what) => this.Notify(what);
public record struct Token(ulong InstanceId, Action OnUse);
private Dictionary<ulong, Token> Tokens { get; set; } = [];
public int TokenCount => Tokens.Count;
private Queue<ulong> RequestQueue { get; set; } = [];
public int MaxTokens { get; set;}
public void Initialize(int maxTokens)
{
MaxTokens = maxTokens;
}
public Token? RequestToken(Node owner)
{
if (Tokens.ContainsKey(owner.GetInstanceId()))
{
GD.Print("Already has a token");
return null; // Already has a token
}
if (TokenCount >= MaxTokens)
{
GD.Print($"Max tokens reached: {TokenCount}");
return null; // Max tokens reached
}
if (!RequestQueue.Contains(owner.GetInstanceId()))
{
RequestQueue.Enqueue(owner.GetInstanceId());
}
if (RequestQueue.First() != owner.GetInstanceId())
{
GD.Print("Waiting its turn");
return null; // Next in line is not the requester
}
var ownerInstanceId = RequestQueue.Dequeue();
var token = new Token(ownerInstanceId, () => UseToken(ownerInstanceId));
Tokens.Add(token.InstanceId, token);
return token;
}
public void UseToken(ulong instanceId)
{
Tokens.Remove(instanceId);
}
}

View File

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

View File

@@ -0,0 +1,22 @@
using Godot;
namespace Movementtests.managers;
[GlobalClass]
public partial class EnemyDescription(PackedScene scene, EnemyDescription.EnemyType type, RMovement? movementOverride) : Resource
{
public enum EnemyType
{
Normal,
Flying,
Projectile,
}
[Export(PropertyHint.NodeType)] public required PackedScene Scene { get; set; } = scene;
[Export] public required EnemyType Type { get; set; } = type;
[Export] public RMovement? MovementOverride { get; set; } = movementOverride;
public EnemyDescription() : this(ResourceLoader.Load<PackedScene>("uid://dxt0e2ugmttqq"), EnemyType.Normal, null) {}
}

View File

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

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
using Godot;
namespace Movementtests.managers;
[GlobalClass]
public partial class SingleWave(EnemyDescription[] enemies) : Resource
{
[Export] public Godot.Collections.Dictionary<EnemyDescription, int> EnemiesToSpawn { get; set; } = [];
public SingleWave() : this([]) {}
}

View File

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

View File

@@ -0,0 +1,11 @@
using Godot;
namespace Movementtests.managers;
[GlobalClass]
public partial class WaveContent(SingleWave[] waves) : Resource
{
[Export] public SingleWave[] Waves { get; set; } = waves;
public WaveContent() : this([]) {}
}

View File

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

View File

@@ -0,0 +1,121 @@
using System.Collections.Generic;
using System.Linq;
using Chickensoft.AutoInject;
using Chickensoft.Collections;
using Chickensoft.Introspection;
using Godot;
using Movementtests.tools;
namespace Movementtests.managers;
[GlobalClass, Meta(typeof(IAutoNode))]
public partial class WaveManager : Node
{
public override void _Notification(int what) => this.Notify(what);
public WaveContent WaveContent { get; set; }
public int CurrentWaveIndex { get; set; }
public int CurrentWaveCount => WaveContent.Waves.Length;
public Godot.Collections.Dictionary<EnemyDescription, int> CurrentWave =>
WaveContent.Waves[CurrentWaveIndex].EnemiesToSpawn;
public Dictionary<ulong, Enemy?> CurrentSpawnedEnemies { get; set; } = [];
public Set<Spawner> SpawnersInUse { get; set; } = [];
public List<Spawner> Spawners { get; set; } = [];
public void RegisterSpawner(Spawner spawner) => Spawners.Add(spawner);
public void InitializeFromResource(WaveContent waveContent) => WaveContent = waveContent;
public void StartWaves()
{
CurrentWaveIndex = 0;
StartNextWave();
}
public void StartNextWave()
{
if (CurrentWave.Count == 0)
{
GD.PrintErr("Wave has no enemies");
return;
}
if (Spawners.Count == 0)
{
GD.PrintErr("No spawners registered");
return;
}
SpawnEnemiesAsAvailable();
}
public void SpawnEnemiesAsAvailable()
{
var randomizedSpawners = Spawners.ToArray();
randomizedSpawners.Shuffle();
foreach (var spawner in randomizedSpawners)
{
if (SpawnersInUse.Contains(spawner)) continue;
foreach (var (enemyDescription, numberRemaining) in CurrentWave)
{
if (numberRemaining <= 0) continue;
if (!spawner.SupportedEnemyTypes.Contains(enemyDescription.Type)) continue;
var spawnedEnemy = spawner.SpawnEnemy(enemyDescription);
if (spawnedEnemy == null) continue;
CurrentSpawnedEnemies[spawnedEnemy.GetInstanceId()] = spawnedEnemy;
SpawnersInUse.Add(spawner);
spawnedEnemy.OnKilled += instanceId=> SpawnedEnemyDied(instanceId, spawner);
CurrentWave[enemyDescription]--;
break;
}
}
// foreach (var (enemyDescription, numberRemaining) in CurrentWave)
// {
// if (numberRemaining <= 0) continue;
// foreach (var spawner in randomizedSpawners)
// {
// if (!spawner.SupportedEnemyTypes.Contains(enemyDescription.Type)) continue;
// if (SpawnersInUse.Contains(spawner)) continue;
//
// var spawnedEnemy = spawner.SpawnEnemy(enemyDescription);
// if (spawnedEnemy == null) continue;
//
// CurrentSpawnedEnemies[spawnedEnemy.GetInstanceId()] = spawnedEnemy;
// SpawnersInUse.Add(spawner);
//
// spawnedEnemy.OnKilled += instanceId=> SpawnedEnemyDied(instanceId, spawner);
//
// CurrentWave[enemyDescription]--;
// break;
// }
// }
var remainingEnemiesToSpawn = CurrentWave.Values.Sum();
if (remainingEnemiesToSpawn <= 0) return; // Wave is fully spawned
GetTree().CreateTimer(1.0f).Timeout += SpawnEnemiesAsAvailable; // Call back the same function later to try and spawn the rest
}
public void SpawnedEnemyDied(ulong instanceId, Spawner spawner)
{
CurrentSpawnedEnemies.Remove(instanceId);
SpawnersInUse.Remove(spawner);
if (CurrentSpawnedEnemies.Count == 0) FinishWave();
}
public void FinishWave()
{
if (CurrentWaveIndex >= CurrentWaveCount) return; // All waves finished
CurrentWaveIndex++;
GetTree().CreateTimer(1.0f).Timeout += StartNextWave; // Start next wave in 1s
}
}

View File

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

View File

@@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="EnemyDescription" format=3 uid="uid://cfyafss8ncbhh"]
[ext_resource type="Resource" uid="uid://bwqjaom4k7rc3" path="res://scenes/enemies/flying_enemy/flying_enemy_movement.tres" id="1_hsb6g"]
[ext_resource type="PackedScene" uid="uid://cmlud1hwkd6sv" path="res://scenes/enemies/flying_enemy/flying_enemy.tscn" id="1_yvgr4"]
[ext_resource type="Script" uid="uid://rhdkfi7nuvu1" path="res://managers/Wave/EnemyDescription.cs" id="2_hsb6g"]
[resource]
script = ExtResource("2_hsb6g")
Scene = ExtResource("1_yvgr4")
Type = 1
MovementOverride = ExtResource("1_hsb6g")
metadata/_custom_type_script = "uid://rhdkfi7nuvu1"

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="EnemyDescription" format=3 uid="uid://3clksludry8g"]
[ext_resource type="PackedScene" uid="uid://dxt0e2ugmttqq" path="res://scenes/enemies/grounded_enemy/grounded_enemy.tscn" id="1_wxdbf"]
[ext_resource type="Script" uid="uid://rhdkfi7nuvu1" path="res://managers/Wave/EnemyDescription.cs" id="2_gk6ig"]
[resource]
script = ExtResource("2_gk6ig")
Scene = ExtResource("1_wxdbf")
metadata/_custom_type_script = "uid://rhdkfi7nuvu1"

View File

@@ -0,0 +1,17 @@
[gd_resource type="Resource" script_class="SingleWave" format=3 uid="uid://dm71u0ryn0w1o"]
[ext_resource type="Resource" uid="uid://cfyafss8ncbhh" path="res://managers/Wave/resources/flying_enemy_desc.tres" id="1_bcssi"]
[ext_resource type="Script" uid="uid://rhdkfi7nuvu1" path="res://managers/Wave/EnemyDescription.cs" id="2_3r6ce"]
[ext_resource type="Resource" uid="uid://3clksludry8g" path="res://managers/Wave/resources/grounded_enemy_desc.tres" id="2_mmsra"]
[ext_resource type="Resource" uid="uid://lnturc3ibr5c" path="res://managers/Wave/resources/projectile_enemy_desc.tres" id="3_3r6ce"]
[ext_resource type="Script" uid="uid://cr8wog705ane6" path="res://managers/Wave/SingleWave.cs" id="5_qckro"]
[resource]
script = ExtResource("5_qckro")
Enemies = Array[Object]([ExtResource("1_bcssi"), ExtResource("2_mmsra"), ExtResource("3_3r6ce")])
EnemiesToSpawn = Dictionary[ExtResource("2_3r6ce"), int]({
ExtResource("1_bcssi"): 1,
ExtResource("2_mmsra"): 1,
ExtResource("3_3r6ce"): 1
})
metadata/_custom_type_script = "uid://cr8wog705ane6"

View File

@@ -0,0 +1,10 @@
[gd_resource type="Resource" script_class="EnemyDescription" format=3 uid="uid://lnturc3ibr5c"]
[ext_resource type="PackedScene" uid="uid://dx3y8sjftqk8f" path="res://scenes/enemies/projectile_enemy/projectile_enemy.tscn" id="1_2nepo"]
[ext_resource type="Script" uid="uid://rhdkfi7nuvu1" path="res://managers/Wave/EnemyDescription.cs" id="2_bn1dh"]
[resource]
script = ExtResource("2_bn1dh")
Scene = ExtResource("1_2nepo")
Type = 1
metadata/_custom_type_script = "uid://rhdkfi7nuvu1"

View File

@@ -13,7 +13,12 @@ using Movementtests.systems;
typeof(IAutoConnect),
typeof(IProvider)
)]
public partial class MainSceneTemplate : Node3D, IProvide<InventoryManager>, IProvide<TagsManager>, IProvide<CuesManager>
public partial class MainSceneTemplate : Node3D,
IProvide<InventoryManager>,
IProvide<TagsManager>,
IProvide<CuesManager>,
IProvide<TokenManager>,
IProvide<WaveManager>
{
public override void _Notification(int what) => this.Notify(what);
@@ -31,6 +36,8 @@ public partial class MainSceneTemplate : Node3D, IProvide<InventoryManager>, IPr
#region Exports
[Export] public WeaponInventory? InitialWeaponInventory { get; set; }
[Export] public int MaxNumberOfProjectiles { get; set; } = 3;
[Export] public WaveContent? WaveContent { get; set; }
#endregion
@@ -40,6 +47,12 @@ public partial class MainSceneTemplate : Node3D, IProvide<InventoryManager>, IPr
TagsManager IProvide<TagsManager>.Value() => ForgeManagers.Instance.TagsManager;
CuesManager IProvide<CuesManager>.Value() => ForgeManagers.Instance.CuesManager;
public required TokenManager TokenManager { get; set; }
TokenManager IProvide<TokenManager>.Value() => TokenManager;
public required WaveManager WaveManager { get; set; }
WaveManager IProvide<WaveManager>.Value() => WaveManager;
public void OnReady()
{
PlayerFellPlane.BodyEntered += StartResetPlayerAnimation;
@@ -49,9 +62,25 @@ public partial class MainSceneTemplate : Node3D, IProvide<InventoryManager>, IPr
if (InitialWeaponInventory != null)
InventoryManager.InitializeFromResource(InitialWeaponInventory);
AddChild(InventoryManager);
TokenManager = new TokenManager();
TokenManager.Initialize(MaxNumberOfProjectiles);
AddChild(TokenManager);
WaveManager = new WaveManager();
if (WaveContent != null)
WaveManager.InitializeFromResource(WaveContent);
AddChild(WaveManager);
this.Provide();
}
public void OnProvided()
{
if (WaveContent != null)
GetTree().CreateTimer(3).Timeout += WaveManager.StartWaves;
}
public void ResetPlayerPosition()
{
if (Respawnabble == null || PlayerRespawnMarker == null) throw new Exception("Player or respawn marker is null");

View File

@@ -16,8 +16,6 @@
[ext_resource type="Texture2D" uid="uid://bhlrmh5v3fa2n" path="res://assets/ui/input-prompts/Keyboard & Mouse/Vector/mouse_left_outline.svg" id="16_ca01l"]
[ext_resource type="Texture2D" uid="uid://b580m114ivbse" path="res://assets/ui/input-prompts/Xbox Series/Vector/xbox_button_menu_outline.svg" id="17_5461m"]
[ext_resource type="Texture2D" uid="uid://goerc3svgoqd" path="res://assets/ui/input-prompts/Keyboard & Mouse/Vector/keyboard_escape_outline.svg" id="18_22eiu"]
[ext_resource type="Texture2D" uid="uid://db6uqhcmcfs5t" path="res://assets/ui/input-prompts/Xbox Series/Vector/xbox_lb_outline.svg" id="19_ci5dp"]
[ext_resource type="Texture2D" uid="uid://ybwqghk70io" path="res://assets/ui/input-prompts/Keyboard & Mouse/Vector/keyboard_f_outline.svg" id="20_4ouww"]
[sub_resource type="Resource" id="Resource_nwk5u"]
script = ExtResource("6_465vr")
@@ -58,6 +56,18 @@ use_collision = true
size = Vector3(1, 17.5, 9.5)
material = ExtResource("3_4m8g1")
[node name="CSGBox3D109" type="CSGBox3D" parent="Playground/PlaytestArena" index="89" unique_id=167333800]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 50, 24.75, -41.74998)
use_collision = true
size = Vector3(1, 1.5, 9.5)
material = ExtResource("3_4m8g1")
[node name="CSGBox3D112" type="CSGBox3D" parent="Playground/PlaytestArena" index="90" unique_id=2075934946]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 45.5, 24.75, -46.999954)
use_collision = true
size = Vector3(10, 1.5, 1)
material = ExtResource("3_4m8g1")
[node name="Targets" type="Node3D" parent="Playground" index="1" unique_id=1727473773]
[node name="FixedDashthroughTarget" parent="Playground/Targets" index="0" unique_id=1291663508 instance=ExtResource("4_4u5eu")]
@@ -235,7 +245,7 @@ Target = NodePath("../../../Player")
RMovement = SubResource("Resource_nwk5u")
[node name="Enemy24" parent="Playground/GroundedEnemies" index="16" unique_id=2068813971 node_paths=PackedStringArray("Target") instance=ExtResource("7_egib5")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 45, 24.5, -43.336807)
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 45, 24.5, -43.336803)
Target = NodePath("../../../Player")
RMovement = SubResource("Resource_nwk5u")
@@ -345,8 +355,8 @@ shape = SubResource("BoxShape3D_dkfm7")
[node name="TutoTrigger4" parent="Tutorial/Triggers" index="3" unique_id=321542244 instance=ExtResource("10_vqwwk")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.5, 17.75, -27.5)
first_input_icon = ExtResource("15_1s3jl")
first_input_icon_keyboard = ExtResource("16_ca01l")
first_input_icon = ExtResource("13_ocbap")
first_input_icon_keyboard = ExtResource("14_4hfom")
input_related_text = "at target"
tuto_text = "dash through"
@@ -356,8 +366,8 @@ shape = SubResource("BoxShape3D_nwk5u")
[node name="TutoTrigger6" parent="Tutorial/Triggers" index="4" unique_id=26112457 instance=ExtResource("10_vqwwk")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.75, 22.75, 11.25)
first_input_icon = ExtResource("15_1s3jl")
first_input_icon_keyboard = ExtResource("16_ca01l")
first_input_icon = ExtResource("13_ocbap")
first_input_icon_keyboard = ExtResource("14_4hfom")
input_related_text = "at enemy"
tuto_text = "dash through"
@@ -389,10 +399,9 @@ shape = SubResource("BoxShape3D_trte5")
[node name="TutoTrigger8" parent="Tutorial/Triggers" index="7" unique_id=36196488 instance=ExtResource("10_vqwwk")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5, 21.75, 28.25)
first_input_icon = ExtResource("19_ci5dp")
first_input_icon_keyboard = ExtResource("20_4ouww")
input_related_text = "at enemy"
tuto_text = "knockback"
first_input_icon = ExtResource("15_1s3jl")
first_input_icon_keyboard = ExtResource("16_ca01l")
tuto_text = "hit"
[node name="CollisionShape3D" type="CollisionShape3D" parent="Tutorial/Triggers/TutoTrigger8" index="1" unique_id=929676345]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.125, 1.875, 0.375)

View File

@@ -0,0 +1,348 @@
[gd_scene format=3 uid="uid://b2g2gys4dopmn"]
[ext_resource type="PackedScene" uid="uid://55wehh6xombr" path="res://maps/_templates/main_scene_template.tscn" id="1_pxwoj"]
[ext_resource type="PackedScene" uid="uid://y77cdg7gg3y7" path="res://maps/levels/_arenas/playtest_1.tscn" id="2_apgv3"]
[ext_resource type="Material" uid="uid://31aulub2nqov" path="res://assets/materials/greybox/m_greybox.tres" id="3_452yy"]
[ext_resource type="Script" uid="uid://rhdkfi7nuvu1" path="res://managers/Wave/EnemyDescription.cs" id="3_a6jwd"]
[ext_resource type="Resource" uid="uid://cfyafss8ncbhh" path="res://managers/Wave/resources/flying_enemy_desc.tres" id="3_re07p"]
[ext_resource type="PackedScene" uid="uid://c305mfrtumcyq" path="res://scenes/spawners/spawner.tscn" id="4_6q0yp"]
[ext_resource type="Resource" uid="uid://3clksludry8g" path="res://managers/Wave/resources/grounded_enemy_desc.tres" id="4_7ijxg"]
[ext_resource type="Script" uid="uid://cr8wog705ane6" path="res://managers/Wave/SingleWave.cs" id="5_7ijxg"]
[ext_resource type="Resource" uid="uid://lnturc3ibr5c" path="res://managers/Wave/resources/projectile_enemy_desc.tres" id="5_hm1dp"]
[ext_resource type="Script" uid="uid://dijmv0wqc1xuv" path="res://managers/Wave/WaveContent.cs" id="6_hm1dp"]
[sub_resource type="Resource" id="Resource_7ijxg"]
script = ExtResource("5_7ijxg")
EnemiesToSpawn = Dictionary[ExtResource("3_a6jwd"), int]({
ExtResource("4_7ijxg"): 4
})
metadata/_custom_type_script = "uid://cr8wog705ane6"
[sub_resource type="Resource" id="Resource_hm1dp"]
script = ExtResource("5_7ijxg")
EnemiesToSpawn = Dictionary[ExtResource("3_a6jwd"), int]({
ExtResource("4_7ijxg"): 8,
ExtResource("3_re07p"): 3
})
metadata/_custom_type_script = "uid://cr8wog705ane6"
[sub_resource type="Resource" id="Resource_a6jwd"]
script = ExtResource("5_7ijxg")
EnemiesToSpawn = Dictionary[ExtResource("3_a6jwd"), int]({
ExtResource("5_hm1dp"): 3
})
metadata/_custom_type_script = "uid://cr8wog705ane6"
[sub_resource type="Resource" id="Resource_wllel"]
script = ExtResource("5_7ijxg")
EnemiesToSpawn = Dictionary[ExtResource("3_a6jwd"), int]({
ExtResource("4_7ijxg"): 4,
ExtResource("5_hm1dp"): 4,
ExtResource("3_re07p"): 4
})
metadata/_custom_type_script = "uid://cr8wog705ane6"
[sub_resource type="Resource" id="Resource_re07p"]
script = ExtResource("5_7ijxg")
EnemiesToSpawn = Dictionary[ExtResource("3_a6jwd"), int]({
ExtResource("3_re07p"): 15
})
metadata/_custom_type_script = "uid://cr8wog705ane6"
[sub_resource type="Resource" id="Resource_t6pb5"]
script = ExtResource("5_7ijxg")
EnemiesToSpawn = Dictionary[ExtResource("3_a6jwd"), int]({
ExtResource("4_7ijxg"): 15,
ExtResource("5_hm1dp"): 10,
ExtResource("3_re07p"): 10
})
metadata/_custom_type_script = "uid://cr8wog705ane6"
[sub_resource type="Resource" id="Resource_e88eg"]
script = ExtResource("6_hm1dp")
Waves = Array[Object]([SubResource("Resource_7ijxg"), SubResource("Resource_hm1dp"), SubResource("Resource_a6jwd"), SubResource("Resource_wllel"), SubResource("Resource_re07p"), SubResource("Resource_t6pb5")])
metadata/_custom_type_script = "uid://dijmv0wqc1xuv"
[node name="Main" unique_id=955321579 instance=ExtResource("1_pxwoj")]
WaveContent = SubResource("Resource_e88eg")
[node name="PlaytestArena" parent="." index="12" unique_id=664535670 instance=ExtResource("2_apgv3")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16, 0, 9.5)
[node name="CSGBox3D108" type="CSGBox3D" parent="PlaytestArena" index="89" unique_id=94297910]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 8.75, 2.25)
use_collision = true
size = Vector3(1, 17.5, 9.5)
material = ExtResource("3_452yy")
[node name="Spawner2" parent="." index="13" unique_id=1982641431 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.5, 1, -4)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../Player")
IsActiveOnStart = false
[node name="Spawner3" parent="." index="14" unique_id=1743153579 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.5, 1, -4)
SupportedEnemyTypes = Array[int]([1])
Target = NodePath("../Player")
IsActiveOnStart = false
[node name="Spawner4" parent="." index="15" unique_id=536869732 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 1, -4)
SupportedEnemyTypes = Array[int]([1, 0])
Target = NodePath("../Player")
IsActiveOnStart = false
[node name="Spawner5" parent="." index="16" unique_id=275129467 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 13, 1, -4)
SupportedEnemyTypes = Array[int]([1, 0])
Target = NodePath("../Player")
IsActiveOnStart = false
[node name="Spawners" type="Node3D" parent="." index="17" unique_id=1784503796]
[node name="Grounded" type="Node3D" parent="Spawners" index="0" unique_id=2135113359]
[node name="Spawner" parent="Spawners/Grounded" index="0" unique_id=580981173 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 1, -4)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner13" parent="Spawners/Grounded" index="1" unique_id=771710160 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, -4)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner14" parent="Spawners/Grounded" index="2" unique_id=947491829 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.5, 1, -4)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner15" parent="Spawners/Grounded" index="3" unique_id=519369782 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.5, 1, 5.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner16" parent="Spawners/Grounded" index="4" unique_id=1219755801 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.5, 1, -9.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner17" parent="Spawners/Grounded" index="5" unique_id=1403055240 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 22.5, 1, -9.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner18" parent="Spawners/Grounded" index="6" unique_id=1479410245 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29.5, 1, 7.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner19" parent="Spawners/Grounded" index="7" unique_id=1743292696 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29.5, 7, -9.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner21" parent="Spawners/Grounded" index="8" unique_id=1801083740 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29.5, 11.5, -24.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner22" parent="Spawners/Grounded" index="9" unique_id=1296256003 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.5, 11.5, -24.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner20" parent="Spawners/Grounded" index="10" unique_id=1527237523 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 18.5, 7, -9.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner2" parent="Spawners/Grounded" index="11" unique_id=834604221 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 1, -23.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner3" parent="Spawners/Grounded" index="12" unique_id=270195635 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8, 1, -30.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner4" parent="Spawners/Grounded" index="13" unique_id=1202580658 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 1, -33)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner5" parent="Spawners/Grounded" index="14" unique_id=1987649511 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.5, 1, -33)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner6" parent="Spawners/Grounded" index="15" unique_id=1276050304 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 26.5, 1, -25)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner7" parent="Spawners/Grounded" index="16" unique_id=825475214 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 26.5, 1, -17.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner8" parent="Spawners/Grounded" index="17" unique_id=1896505808 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 6, -17.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner11" parent="Spawners/Grounded" index="18" unique_id=1922800453 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 7, -8)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner12" parent="Spawners/Grounded" index="19" unique_id=172297553 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14, 7, -8)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner9" parent="Spawners/Grounded" index="20" unique_id=242104600 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 5, -17.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner10" parent="Spawners/Grounded" index="21" unique_id=1537236940 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.5, 3.5, -17.5)
SupportedEnemyTypes = Array[int]([0])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Flying" type="Node3D" parent="Spawners" index="1" unique_id=1568736683]
[node name="Spawner2" parent="Spawners/Flying" index="0" unique_id=540145996 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 26.051147, -34)
SupportedEnemyTypes = Array[int]([1])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner3" parent="Spawners/Flying" index="1" unique_id=286744715 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 27, 26.051147, -34)
SupportedEnemyTypes = Array[int]([1])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner4" parent="Spawners/Flying" index="2" unique_id=97624405 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 30.5, 26.051147, -31)
SupportedEnemyTypes = Array[int]([1])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner5" parent="Spawners/Flying" index="3" unique_id=452318421 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 20.5, 13.051147, 3.5)
SupportedEnemyTypes = Array[int]([1])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner6" parent="Spawners/Flying" index="4" unique_id=1238823469 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 20.5, 13.051147, 8)
SupportedEnemyTypes = Array[int]([1])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Projectile" type="Node3D" parent="Spawners" index="2" unique_id=1258161549]
[node name="Spawner3" parent="Spawners/Projectile" index="0" unique_id=1747138734 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 7.5, 8.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner4" parent="Spawners/Projectile" index="1" unique_id=1503627609 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7, 11, 9.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner5" parent="Spawners/Projectile" index="2" unique_id=2041198655 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 20.5, 11, 9.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner6" parent="Spawners/Projectile" index="3" unique_id=552715567 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 20.5, 11, 1.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner7" parent="Spawners/Projectile" index="4" unique_id=70054371 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 22.5, 12, -9.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner8" parent="Spawners/Projectile" index="5" unique_id=1180979948 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 17, 12, -9.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner9" parent="Spawners/Projectile" index="6" unique_id=1257162636 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.5, 12, -9.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner10" parent="Spawners/Projectile" index="7" unique_id=508868686 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 17.5, -8.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner11" parent="Spawners/Projectile" index="8" unique_id=1732590308 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 17.5, -17.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner12" parent="Spawners/Projectile" index="9" unique_id=1601257376 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7, 17.5, -24.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner13" parent="Spawners/Projectile" index="10" unique_id=391332199 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 17, 17.5, -24.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner14" parent="Spawners/Projectile" index="11" unique_id=1920158287 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29.5, 17.5, -24.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false
[node name="Spawner15" parent="Spawners/Projectile" index="12" unique_id=1099390523 node_paths=PackedStringArray("Target") instance=ExtResource("4_6q0yp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 11, -26.5)
SupportedEnemyTypes = Array[int]([2])
Target = NodePath("../../../Player")
IsActiveOnStart = false

View File

@@ -112,5 +112,13 @@ RMovement = SubResource("Resource_xixm3")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.0893264, -1.9073486e-06, -17.405575)
Target = NodePath("../Player")
[node name="Player" parent="." index="16" unique_id=1309399929]
[node name="ProjectileEnemy2" parent="." index="15" unique_id=1908678308 node_paths=PackedStringArray("Target") instance=ExtResource("10_mm5sa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.42922592, -3.8146973e-06, -20.257122)
Target = NodePath("../Player")
[node name="ProjectileEnemy3" parent="." index="16" unique_id=1327447050 node_paths=PackedStringArray("Target") instance=ExtResource("10_mm5sa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.4421315, -1.9073486e-06, -13.8114)
Target = NodePath("../Player")
[node name="Player" parent="." index="18" unique_id=1309399929]
transform = Transform3D(0.99999994, 0, 0, 0, 1, 0, 0, 0, 0.99999994, 2, 1.5, 9.5)

View File

@@ -43,7 +43,7 @@ item_0/text = "1 - ExampleLevel"
[node name="SceneLister" type="Node" parent="." unique_id=149935027]
script = ExtResource("3_stdqw")
files = Array[String](["res://maps/levels/1 - tuto_movement.tscn", "res://maps/levels/2 - tuto_sword.tscn", "res://maps/levels/3 - tuto_enemies.tscn", "res://maps/zoos/grounded_flying_ennemies.tscn", "res://maps/gyms/metrics.tscn"])
files = Array[String](["res://maps/levels/1 - tuto_movement.tscn", "res://maps/levels/2 - tuto_sword.tscn", "res://maps/levels/3 - tuto_enemies.tscn", "res://maps/levels/4 - tuto_waves.tscn"])
directory = "res://maps"
[connection signal="item_activated" from="Control/LevelButtonsContainer" to="." method="_on_level_buttons_container_item_activated"]

View File

@@ -21,14 +21,18 @@ public partial class CFlyingMovement : Node3D, IMoveable
public Vector3 ComputeVelocity(MovementInputs inputs)
{
if (inputs.IsStunned) return inputs.Velocity.Lerp(Vector3.Zero, (float) inputs.Delta * RMovement.Acceleration);
var velocity = inputs.Velocity;
var spaceState = GetWorld3D().DirectSpaceState;
var target = inputs.TargetLocation;
var direction = (target - GlobalPosition).Normalized();
var direction = GlobalPosition.DirectionTo(target);
velocity = velocity.Lerp(direction * RMovement.Speed, (float) inputs.Delta * RMovement.Acceleration);
return velocity;
// Check if we have a direct line of sight to the player
if (!_movingToDesiredHeight)
{
velocity = velocity.Lerp(direction * RMovement.Speed, (float) inputs.delta * RMovement.Acceleration);
velocity = velocity.Lerp(direction * RMovement.Speed, (float) inputs.Delta * RMovement.Acceleration);
var query = PhysicsRayQueryParameters3D.Create(GlobalPosition, target, TerrainCollision);
var result = spaceState.IntersectRay(query);
@@ -40,7 +44,7 @@ public partial class CFlyingMovement : Node3D, IMoveable
}
else
{
velocity = velocity.Lerp(_randomDirection * RMovement.Speed, (float) inputs.delta * RMovement.Acceleration);
velocity = velocity.Lerp(_randomDirection * RMovement.Speed, (float) inputs.Delta * RMovement.Acceleration);
var groundQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition, GlobalPosition+Vector3.Down*RMovement.TargetHeight, TerrainCollision);
var groundResult = spaceState.IntersectRay(groundQuery);

View File

@@ -19,15 +19,18 @@ public partial class CGroundedMovement : Node3D, IMoveable
var targetPlane = new Vector3(target.X, GlobalPosition.Y, target.Z);
LookAt(targetPlane);
float xAcc = (float) Mathf.Lerp(velocity.X, direction.X * RMovement.Speed, inputs.delta * RMovement.Acceleration);
float zAcc = (float) Mathf.Lerp(velocity.Z, direction.Z * RMovement.Speed, inputs.delta * RMovement.Acceleration);
var targetXSpeed = inputs.IsStunned ? 0 : direction.X * RMovement.Speed;
var targetZSpeed = inputs.IsStunned ? 0 : direction.Z * RMovement.Speed;
float xAcc = (float) Mathf.Lerp(velocity.X, targetXSpeed, inputs.Delta * RMovement.Acceleration);
float zAcc = (float) Mathf.Lerp(velocity.Z, targetZSpeed, inputs.Delta * RMovement.Acceleration);
velocity.X = xAcc;
velocity.Z = zAcc;
if (WallInFrontRayCast.IsColliding())
if (WallInFrontRayCast.IsColliding() && !inputs.IsStunned)
velocity.Y = RMovement.Speed;
else if (!inputs.isOnFloor)
velocity += inputs.gravity * (float)inputs.delta * RMovement.GravityModifier;
else if (!inputs.IsOnFloor)
velocity += inputs.Gravity * (float)inputs.Delta * RMovement.GravityModifier;
return velocity;
}

View File

@@ -15,6 +15,7 @@ using Gamesmiths.Forge.Tags;
using Godot;
using Movementtests.forge.abilities;
using Movementtests.interfaces;
using Movementtests.managers;
using Movementtests.scenes.components.knockback;
using Movementtests.systems;
using Movementtests.tools;
@@ -38,7 +39,15 @@ public partial class Enemy : CharacterBody3D,
public TagsManager TagsManager => this.DependOn<TagsManager>();
[Dependency]
public CuesManager CuesManager => this.DependOn<CuesManager>();
[Dependency]
public TokenManager TokenManager => this.DependOn<TokenManager>();
#endregion
#region Signals
[Signal] public delegate void OnKilledEventHandler(ulong instanceId);
#endregion
#region Inspector
@@ -130,18 +139,26 @@ public partial class Enemy : CharacterBody3D,
Events.Subscribe<KnockbackDone>(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);
}
private bool IsStunned()
{
return Tags.CombinedTags.HasTag(Tag.RequestTag(TagsManager, "status.stunned"));
}
private void ProjectileTokenRequested(EventData obj)
{
// TODO: replace with token manager
if (IsStunned()) return;
var token = TokenManager.RequestToken(this);
if (token == null) return;
Events.Raise(new EventData<OnProjectileSpawned>
{
EventTags = Tag.RequestTag(TagsManager, "events.enemy.launch_projectile").GetSingleTagContainer()!,
Source = this,
Target = Target as IForgeEntity,
Payload = new OnProjectileSpawned(Vector3.Up, 20, Vector3.Up)
Payload = new OnProjectileSpawned(Vector3.Up, 20, Vector3.Up, Token: token)
});
}
@@ -154,25 +171,30 @@ public partial class Enemy : CharacterBody3D,
{
// Only trigger gameplay-related effects on specific frames
if(Engine.GetPhysicsFrames() % 10 == 0) ProcessGameplay(delta);
var targetPlanar = new Vector3(Target.GlobalPosition.X, GlobalPosition.Y, Target.GlobalPosition.Z);
LookAt(targetPlanar);
if (!IsStunned())
{
var targetPlanar = new Vector3(Target.GlobalPosition.X, GlobalPosition.Y, Target.GlobalPosition.Z);
LookAt(targetPlanar);
}
var inputs = new MovementInputs(
Velocity: Velocity,
TargetLocation: Target.GlobalPosition,
isOnFloor: IsOnFloor(),
gravity: GetGravity(),
delta: delta
IsOnFloor: IsOnFloor(),
IsStunned: IsStunned(),
Gravity: GetGravity(),
Delta: delta
);
Velocity = ComputeVelocity(inputs);
Velocity += ComputeKnockback();
MoveAndSlide();
}
public void ProcessGameplay(double delta)
{
// if (_hitAbilityHandle == null) return;
if (IsStunned()) return;
var bodies = DamageBox.GetOverlappingBodies();
foreach (var body in bodies)
@@ -232,6 +254,8 @@ public partial class Enemy : CharacterBody3D,
{
killable.Kill();
}
EmitSignalOnKilled(GetInstanceId());
CallDeferred(Node.MethodName.QueueFree);
}

View File

@@ -64,7 +64,7 @@ InitialStack = SubResource("Resource_8x1id")
Cues = []
metadata/_custom_type_script = "uid://b83hf13nj37k3"
[sub_resource type="ViewportTexture" id="ViewportTexture_4oy82"]
[sub_resource type="ViewportTexture" id="ViewportTexture_46wn3"]
viewport_path = NodePath("SubViewport")
[sub_resource type="Resource" id="Resource_on7rt"]
@@ -141,7 +141,7 @@ metadata/_custom_type_script = "uid://dps0oef50noil"
[node name="CHealthBar" parent="." unique_id=1635725931 instance=ExtResource("7_ykkxn")]
transform = Transform3D(0.3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.70000005, 0)
texture = SubResource("ViewportTexture_4oy82")
texture = SubResource("ViewportTexture_46wn3")
[node name="CMovement" parent="." unique_id=1699571730 instance=ExtResource("7_vaeds")]
RMovement = SubResource("Resource_on7rt")

View File

@@ -4,7 +4,7 @@
[resource]
script = ExtResource("1_3yq0a")
Speed = 3.0
Acceleration = 5.0
TargetHeight = 10.0
Speed = 6.0
Acceleration = 8.0
TargetHeight = 8.0
metadata/_custom_type_script = "uid://dtpxijlnb2c5"

View File

@@ -141,7 +141,7 @@ InitialStack = SubResource("Resource_hgi6f")
Cues = []
metadata/_custom_type_script = "uid://b83hf13nj37k3"
[sub_resource type="ViewportTexture" id="ViewportTexture_xabdf"]
[sub_resource type="ViewportTexture" id="ViewportTexture_rlvdp"]
viewport_path = NodePath("SubViewport")
[sub_resource type="Resource" id="Resource_6d4gl"]
@@ -177,7 +177,6 @@ collision_layer = 16
collision_mask = 273
script = ExtResource("1_ha67n")
EnemyHeight = 2.0
LaunchProjectileAbility = ExtResource("2_rlvdp")
RKnockback = ExtResource("3_ymgar")
RMovement = ExtResource("4_0f52b")
@@ -222,7 +221,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_xabdf")
texture = SubResource("ViewportTexture_rlvdp")
[node name="CMovement" parent="." unique_id=1080640834 node_paths=PackedStringArray("WallInFrontRayCast") instance=ExtResource("10_d3cra")]
RMovement = SubResource("Resource_6d4gl")

View File

@@ -50,7 +50,8 @@ public partial class Explosion : Area3D, IProvide<CuesManager>
foreach (var body in bodies)
{
if (body is not IForgeEntity target) continue;
foreach (var ability in ForgeEntityNode.Abilities.GrantedAbilities.Where(ability => ability.CanActivate(out _, target)))
foreach (var ability in ForgeEntityNode.Abilities.GrantedAbilities.Where(ability =>
ability.CanActivate(out _, target)))
ability.Activate(out _, target, Damage);
}
QueueFree();

View File

@@ -1,6 +1,7 @@
[gd_scene format=3 uid="uid://duju3atqgltkg"]
[ext_resource type="Script" uid="uid://cnlu64l7oxvv3" path="res://scenes/explosion/Explosion.cs" id="1_82hkh"]
[ext_resource type="Script" uid="uid://cw525n4mjqgw0" path="res://addons/forge/resources/ForgeTagContainer.cs" id="3_1ve7p"]
[ext_resource type="Script" uid="uid://rpcbb54q4atx" path="res://forge/ForgeEntityNode.cs" id="3_wikc1"]
[ext_resource type="Script" uid="uid://dps0oef50noil" path="res://addons/forge/nodes/ForgeEffect.cs" id="4_f5lqq"]
[ext_resource type="Resource" uid="uid://nns16d5uhtl8" path="res://forge/resources/ability_datas/explosion_hit.tres" id="5_nphml"]
@@ -21,6 +22,11 @@ transparency = 1
cull_mode = 2
albedo_color = Color(0.9607843, 0.27058825, 0, 0.7176471)
[sub_resource type="Resource" id="Resource_nqbbv"]
script = ExtResource("3_1ve7p")
ContainerTags = []
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
[sub_resource type="Resource" id="Resource_5c2oj"]
script = ExtResource("5_nqbbv")
BaseValue = 1
@@ -71,6 +77,7 @@ surface_material_override/0 = SubResource("StandardMaterial3D_hys74")
[node name="ForgeEntityNode" type="Node3D" parent="." unique_id=806020391]
script = ExtResource("3_wikc1")
BaseTags = SubResource("Resource_nqbbv")
metadata/_custom_type_script = "uid://rpcbb54q4atx"
[node name="ForgeEffect" type="Node" parent="ForgeEntityNode" unique_id=2068515708]

View File

@@ -89,7 +89,7 @@ metadata/_custom_type_script = "uid://dpakv7agvir6y"
[sub_resource type="Resource" id="Resource_cmmfb"]
script = ExtResource("10_b0xmb")
Name = "Parry projectile"
CooldownEffects = null
CooldownEffects = []
AbilityBehavior = SubResource("Resource_xs7wf")
TriggerSource = 1
TriggerTag = SubResource("Resource_cm4e8")
@@ -307,7 +307,7 @@ debug_color = Color(0, 0.6, 0.701961, 0.341176)
[node name="HeadSystem" parent="." unique_id=1203743757 instance=ExtResource("11_rxwoh")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0)
LookSensitivity = 0.16
LookSensitivity = 0.5
CameraInclineAcceleration = 20.0
GroundedCameraIncline = 3.0
SlidingJitterAmplitude = 0.2

View File

@@ -455,6 +455,8 @@ public partial class WeaponSystem : RigidBody3D, IForgeEntity
public void PlantInEnemy(Node3D enemy)
{
// GetTree().GetRoot().RemoveChild(this);
// enemy.AddChild(this);
GetTree().GetRoot().CallDeferred(Node.MethodName.RemoveChild, this);
enemy.CallDeferred(Node.MethodName.AddChild, this);
@@ -484,8 +486,9 @@ public partial class WeaponSystem : RigidBody3D, IForgeEntity
// WeaponLocationIndicatorMaterial.StencilColor = new Color(1f, 0.2f, 0.2f);
if (PlantObject is Node3D node)
PlantInEnemy(node);
_weaponState.SendEvent("plant");
_weaponState.CallDeferred(StateChart.MethodName.SendEvent, "plant");
// _weaponState.SendEvent("plant");
CallDeferred(Node3D.MethodName.SetGlobalPosition, PlantLocation);
CallDeferred(Node3D.MethodName.LookAt, GlobalTransform.Origin + PlantNormal, Vector3.Up, true);

View File

@@ -2467,7 +2467,7 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
// else HeadSystem.OnHit();
// var streamName = isParry ? "parry" : "attacks";
_audioStream.SwitchToClipByName("dash");
IsInvincible = true;
OnHitInvincibility();
var plannedDashLocation = _targetLocation + Vector3.Down*_playerHeight/2;
// var enemySurfaceQuery = PhysicsRayQueryParameters3D.Create(HeadSystem.GlobalPosition, plannedDashLocation, DashSystem.DashCast3D.CollisionMask);
@@ -2511,7 +2511,7 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
{
disableable.Disable();
}
IsInvincible = false;
// IsInvincible = false;
_playerState.SendEvent("attack_finished");
}

View File

@@ -11,6 +11,7 @@ using Gamesmiths.Forge.Godot.Resources.Abilities;
using Gamesmiths.Forge.Statescript;
using Gamesmiths.Forge.Tags;
using Movementtests.interfaces;
using Movementtests.managers;
using Movementtests.tools;
using Node = Godot.Node;
@@ -73,6 +74,7 @@ public partial class Projectile : RigidBody3D, IForgeEntity, ITargetable, IKilla
public Node3D? Target { get; set; }
public Vector3? ImpulseDirection { get; set; }
public TokenManager.Token? Token { get; set; }
public void Init()
{
@@ -148,6 +150,7 @@ public partial class Projectile : RigidBody3D, IForgeEntity, ITargetable, IKilla
public void Kill()
{
Token?.OnUse.Invoke();
QueueFree(); // If thrown offmap
}
}

View File

@@ -1,11 +1,20 @@
using Godot;
using System;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Movementtests.managers;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_duplicate.png")]
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_duplicate.png"), Meta(typeof(IAutoNode))]
public partial class Spawner : Node3D
{
[Export(PropertyHint.NodeType)]
public override void _Notification(int what) => this.Notify(what);
[Dependency] public WaveManager WaveManager => this.DependOn<WaveManager>();
[Export(PropertyHint.NodeType)]
public PackedScene? EnemyToSpawn { get; set; }
[Export] public Godot.Collections.Array<EnemyDescription.EnemyType> SupportedEnemyTypes { get; set; } = [];
[Export]
public RMovement? MovementInputs { get; set; }
@@ -18,37 +27,56 @@ public partial class Spawner : Node3D
[Export]
public bool IsActiveOnStart { get; set; } = true;
private Timer _timer;
[Node("Timer")] private Timer SpawnTimer { get; set; }
public override void _Ready()
public void OnReady()
{
_timer = GetNode<Timer>("Timer");
_timer.WaitTime = SpawnInterval;
_timer.Timeout += Spawn;
SpawnTimer.WaitTime = SpawnInterval;
SpawnTimer.Timeout += Spawn;
if (IsActiveOnStart) StartSpawning();
}
public void OnResolved()
{
WaveManager.RegisterSpawner(this);
}
public void Spawn()
{
if (EnemyToSpawn == null || !EnemyToSpawn.CanInstantiate()) return;
if (EnemyToSpawn.Instantiate() is not Enemy spawnedInstance) return;
spawnedInstance.RequestReady();
spawnedInstance.Target = Target;
spawnedInstance.RMovement = MovementInputs;
if (MovementInputs != null)
spawnedInstance.RMovement = MovementInputs;
spawnedInstance.Init();
GetTree().GetCurrentScene().AddChild(spawnedInstance);
spawnedInstance.GlobalPosition = GlobalPosition;
}
public Enemy? SpawnEnemy(EnemyDescription description)
{
if (description.Scene.Instantiate() is not Enemy spawnedInstance) return null;
spawnedInstance.Target = Target;
if (description.MovementOverride is not null)
spawnedInstance.RMovement = description.MovementOverride;
spawnedInstance.Init();
GetTree().GetCurrentScene().AddChild(spawnedInstance);
spawnedInstance.GlobalPosition = GlobalPosition;
return spawnedInstance;
}
public void StartSpawning()
{
_timer.Start();
SpawnTimer.Start();
}
public void StopSpawning()
{
_timer.Stop();
SpawnTimer.Stop();
}
}

View File

@@ -20,9 +20,9 @@ public class MovementSystemUnitTest
var inputs = new MovementInputs(
Velocity: Vector3.Zero,
TargetLocation: new Vector3(10, 0, 0),
isOnFloor: false,
gravity: Vector3.Down * 9.8f,
delta: 1.0
IsOnFloor: false,
Gravity: Vector3.Down * 9.8f,
Delta: 1.0
);
var v = move.ComputeVelocity(inputs);

19
tools/IterableUtils.cs Normal file
View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace Movementtests.tools;
public static class IterableUtils
{
private static readonly Random Rng = new Random();
public static void Shuffle<T>(this IList<T> list)
{
var n = list.Count;
while (n > 1) {
n--;
var k = Rng.Next(n + 1);
(list[k], list[n]) = (list[n], list[k]);
}
}
}

View File

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