Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 290f79afd4 | |||
| 5408f455af | |||
| 3a21f00528 |
@@ -125,7 +125,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="addons\" />
|
||||
<Folder Include="tests\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="RustyOptions" Version="0.10.1" />
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Gamesmiths.Forge.Godot.Core;
|
||||
|
||||
public class ForgeManagers
|
||||
{
|
||||
public static ForgeManagers Instance { get; private set; } = null!;
|
||||
public static ForgeManagers Instance { get; private set; }
|
||||
|
||||
public TagsManager TagsManager { get; private set; }
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public partial class AttributeEditorProperty : EditorProperty
|
||||
private const int ButtonSize = 26;
|
||||
private const int PopupSize = 300;
|
||||
|
||||
private Label _label = null!;
|
||||
private Label _label;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Gamesmiths.Forge.Godot.Editor.Attributes;
|
||||
[Tool]
|
||||
public partial class AttributeSetClassEditorProperty : EditorProperty
|
||||
{
|
||||
private OptionButton _optionButton = null!;
|
||||
private OptionButton _optionButton;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ public partial class CueKeyEditorProperty : EditorProperty
|
||||
private const int ButtonSize = 26;
|
||||
private const int PopupSize = 300;
|
||||
|
||||
private Label _label = null!;
|
||||
private Label _label;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
@@ -15,13 +15,13 @@ public partial class TagContainerEditorProperty : EditorProperty
|
||||
{
|
||||
private readonly Dictionary<TreeItem, TagNode> _treeItemToNode = [];
|
||||
|
||||
private VBoxContainer _root = null!;
|
||||
private Button _containerButton = null!;
|
||||
private ScrollContainer _scroll = null!;
|
||||
private Tree _tree = null!;
|
||||
private VBoxContainer _root;
|
||||
private Button _containerButton;
|
||||
private ScrollContainer _scroll;
|
||||
private Tree _tree;
|
||||
|
||||
private Texture2D _checkedIcon = null!;
|
||||
private Texture2D _uncheckedIcon = null!;
|
||||
private Texture2D _checkedIcon;
|
||||
private Texture2D _uncheckedIcon;
|
||||
|
||||
private GodotStringArray _currentValue = [];
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ public partial class TagEditorProperty : EditorProperty
|
||||
{
|
||||
private readonly Dictionary<TreeItem, TagNode> _treeItemToNode = [];
|
||||
|
||||
private VBoxContainer _root = null!;
|
||||
private Button _containerButton = null!;
|
||||
private ScrollContainer _scroll = null!;
|
||||
private Tree _tree = null!;
|
||||
private VBoxContainer _root;
|
||||
private Button _containerButton;
|
||||
private ScrollContainer _scroll;
|
||||
private Tree _tree;
|
||||
|
||||
private Texture2D _checkedIcon = null!;
|
||||
private Texture2D _uncheckedIcon = null!;
|
||||
private Texture2D _checkedIcon;
|
||||
private Texture2D _uncheckedIcon;
|
||||
|
||||
private string _currentValue = string.Empty;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class TagsEditor : VBoxContainer, ISerializationListener
|
||||
{
|
||||
private readonly Dictionary<TreeItem, TagNode> _treeItemToNode = [];
|
||||
|
||||
private TagsManager _tagsManager = null!;
|
||||
private TagsManager _tagsManager;
|
||||
|
||||
private ForgeData? _forgePluginData;
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@ public partial class ForgeEntity : Node, IForgeEntity
|
||||
[Export]
|
||||
public ForgeTagContainer BaseTags { get; set; } = new();
|
||||
|
||||
public EntityAttributes Attributes { get; set; } = null!;
|
||||
public EntityAttributes Attributes { get; set; }
|
||||
|
||||
public EntityTags Tags { get; set; } = null!;
|
||||
public EntityTags Tags { get; set; }
|
||||
|
||||
public EffectsManager EffectsManager { get; set; } = null!;
|
||||
public EffectsManager EffectsManager { get; set; }
|
||||
|
||||
public EntityAbilities Abilities { get; set; } = null!;
|
||||
public EntityAbilities Abilities { get; set; }
|
||||
|
||||
public EventManager Events { get; set; } = null!;
|
||||
public EventManager Events { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
|
||||
rm -rf \"{temp_dir}\""
|
||||
dotnet/include_scripts_content=false
|
||||
dotnet/include_debug_symbols=true
|
||||
dotnet/embed_build_outputs=true
|
||||
dotnet/embed_build_outputs=false
|
||||
texture_format/bptc=true
|
||||
texture_format/s3tc=true
|
||||
texture_format/etc=false
|
||||
@@ -125,7 +125,7 @@ Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorActi
|
||||
Remove-Item -Recurse -Force '{temp_dir}'"
|
||||
dotnet/include_scripts_content=false
|
||||
dotnet/include_debug_symbols=true
|
||||
dotnet/embed_build_outputs=true
|
||||
dotnet/embed_build_outputs=false
|
||||
texture_format/bptc=true
|
||||
texture_format/s3tc=true
|
||||
texture_format/etc=false
|
||||
@@ -472,4 +472,4 @@ Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorActi
|
||||
Remove-Item -Recurse -Force '{temp_dir}'"
|
||||
dotnet/include_scripts_content=false
|
||||
dotnet/include_debug_symbols=true
|
||||
dotnet/embed_build_outputs=true
|
||||
dotnet/embed_build_outputs=false
|
||||
|
||||
@@ -7,7 +7,7 @@ using Movementtests.systems.damage;
|
||||
[GlobalClass]
|
||||
public partial class RDamageModifier : Resource, IDamageable
|
||||
{
|
||||
public event Action<IDamageable, DamageRecord> DamageTaken = null!;
|
||||
public event Action<IDamageable, DamageRecord> DamageTaken;
|
||||
|
||||
[Export]
|
||||
public EDamageTypes DamageType { get; set;}
|
||||
|
||||
@@ -5,11 +5,11 @@ using Movementtests.interfaces;
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/white/icon_heart.png")]
|
||||
public partial class CHealth : Node, IHealthable
|
||||
{
|
||||
public event Action<IHealthable, HealthChangedRecord> HealthChanged = null!;
|
||||
public event Action<IHealthable> HealthDepleted = null!;
|
||||
public event Action<IHealthable, HealthChangedRecord> HealthChanged;
|
||||
public event Action<IHealthable> HealthDepleted;
|
||||
|
||||
[Export]
|
||||
public RHealth RHealth { get; set; } = null!;
|
||||
public RHealth RHealth { get; set; }
|
||||
|
||||
public float CurrentHealth { get; set; }
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ using Movementtests.interfaces;
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_wind.png")]
|
||||
public partial class CKnockback : Node3D, IKnockbackable
|
||||
{
|
||||
[Export] public RKnockback RKnockback { get; set;} = null!;
|
||||
[Export] public RKnockback RKnockback { get; set; }
|
||||
|
||||
private KnockbackRecord _knockbackRecord = null!;
|
||||
private KnockbackRecord _knockbackRecord;
|
||||
|
||||
public void RegisterKnockback(KnockbackRecord knockbackRecord)
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace Movementtests.scenes.movement;
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_path_follow.png")]
|
||||
public partial class CGroundedMovement : Node3D, IMoveable
|
||||
{
|
||||
[Export] public RMovement RMovement { get; set; } = null!;
|
||||
[Export] public RMovement RMovement { get; set; }
|
||||
|
||||
[Export] public RayCast3D WallInFrontRayCast { get; set; } = null!;
|
||||
[Export] public RayCast3D WallInFrontRayCast { get; set; }
|
||||
|
||||
|
||||
public Vector3 ComputeVelocity(MovementInputs inputs)
|
||||
|
||||
@@ -16,37 +16,37 @@ public partial class Enemy : CharacterBody3D,
|
||||
IStunnable
|
||||
{
|
||||
// Signals and events
|
||||
public event Action<IDamageable, DamageRecord> DamageTaken = null!;
|
||||
public event Action<IHealthable, HealthChangedRecord> HealthChanged = null!;
|
||||
public event Action<IHealthable> HealthDepleted = null!;
|
||||
public event Action<IDamageable, DamageRecord> DamageTaken;
|
||||
public event Action<IHealthable, HealthChangedRecord> HealthChanged;
|
||||
public event Action<IHealthable> HealthDepleted;
|
||||
|
||||
// Public export components
|
||||
[Export]
|
||||
public Node3D Target { get; set; } = null!;
|
||||
public Node3D Target { get; set;}
|
||||
|
||||
[Export]
|
||||
public float EnemyHeight { get; set; } = 1f;
|
||||
|
||||
[ExportGroup("Health")]
|
||||
[Export]
|
||||
public RHealth RHealth { get; set; } = null!;
|
||||
public RHealth RHealth { get; set; }
|
||||
[Export]
|
||||
public RDeathEffect[] DeathEffects { get; set; } = null!;
|
||||
public IHealthable CHealth { get; set; } = null!;
|
||||
public RDeathEffect[] DeathEffects { get; set; }
|
||||
public IHealthable CHealth { get; set; }
|
||||
|
||||
[ExportGroup("Damage")]
|
||||
[Export]
|
||||
public RDamage RDamage { get; set; } = null!;
|
||||
public IDamageable CDamageable { get; set; } = null!;
|
||||
public RDamage RDamage { get; set; }
|
||||
public IDamageable CDamageable { get; set; }
|
||||
|
||||
[Export]
|
||||
public RKnockback RKnockback { get; set; } = null!;
|
||||
public IKnockbackable CKnockback { get; set; } = null!;
|
||||
public RKnockback RKnockback { get; set; }
|
||||
public IKnockbackable CKnockback { get; set; }
|
||||
|
||||
[ExportGroup("Movement")]
|
||||
[Export]
|
||||
public RMovement RMovement { get; set; } = null!;
|
||||
public IMoveable CMovement { get; set; } = null!;
|
||||
public RMovement RMovement { get; set; }
|
||||
public IMoveable CMovement { get; set; }
|
||||
|
||||
// Public stuff
|
||||
public float CurrentHealth
|
||||
@@ -56,9 +56,9 @@ public partial class Enemy : CharacterBody3D,
|
||||
}
|
||||
|
||||
// Private stuff
|
||||
private Area3D _damageBox = null!;
|
||||
internal Node3D _target = null!;
|
||||
private Healthbar _healthbar = null!;
|
||||
private Area3D _damageBox;
|
||||
private Node3D _target;
|
||||
private Healthbar _healthbar;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using Movementtests.interfaces;
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png")]
|
||||
public partial class PlayerUi : Control
|
||||
{
|
||||
internal TextureRect[] _dashIcons = new TextureRect[3];
|
||||
private TextureRect[] _dashIcons = new TextureRect[3];
|
||||
private TextureRect _enemyTarget;
|
||||
private Healthbar _healthbar;
|
||||
|
||||
|
||||
@@ -24,21 +24,21 @@ public partial class DashSystem: Node3D
|
||||
|
||||
public bool ShouldMantle { get; set; }
|
||||
public Vector3 PlannedMantleLocation { get; set; }
|
||||
public MantleSystem MantleSystem { get; set; } = null!;
|
||||
public MantleSystem MantleSystem { get; set; }
|
||||
|
||||
internal HeadSystem Head = null!;
|
||||
public ShapeCast3D DashCast3D = null!;
|
||||
internal Camera3D Camera = null!;
|
||||
internal Vector3 DashDirection = Vector3.Zero;
|
||||
private HeadSystem Head;
|
||||
public ShapeCast3D DashCast3D;
|
||||
private Camera3D Camera;
|
||||
private Vector3 DashDirection = Vector3.Zero;
|
||||
|
||||
internal ShapeCast3D DashCastDrop = null!;
|
||||
internal MeshInstance3D DashDropIndicator = null!;
|
||||
internal MeshInstance3D DashDropLocationIndicator = null!;
|
||||
internal MeshInstance3D DashTarget = null!;
|
||||
internal CpuParticles3D DashIndicator = null!;
|
||||
internal AnimationPlayer DashIndicatorAnim = null!;
|
||||
private ShapeCast3D DashCastDrop;
|
||||
private MeshInstance3D DashDropIndicator;
|
||||
private MeshInstance3D DashDropLocationIndicator;
|
||||
private MeshInstance3D DashTarget;
|
||||
private CpuParticles3D DashIndicator;
|
||||
private AnimationPlayer DashIndicatorAnim;
|
||||
|
||||
[Export] public PackedScene DashIndicatorScene { get; set; } = null!;
|
||||
[Export] public PackedScene DashIndicatorScene { get; set; }
|
||||
|
||||
[Signal]
|
||||
public delegate void DashStartedEventHandler();
|
||||
@@ -75,7 +75,7 @@ public partial class DashSystem: Node3D
|
||||
DashIndicatorAnim = GetNode<AnimationPlayer>("DashIndicator/AnimationPlayer");
|
||||
}
|
||||
|
||||
internal DashLocation ComputeDashLocation()
|
||||
private DashLocation ComputeDashLocation()
|
||||
{
|
||||
var targetLocation = DashCast3D.ToGlobal(DashCast3D.TargetPosition);
|
||||
var hasHit = DashCast3D.IsColliding();
|
||||
|
||||
@@ -39,10 +39,10 @@ public partial class HeadSystem : Node3D
|
||||
float BobbingMultiplier,
|
||||
float FovMultiplier);
|
||||
|
||||
internal Camera3D _camera;
|
||||
internal Marker3D _cameraAnchor;
|
||||
internal AnimationPlayer _animationPlayer;
|
||||
internal AnimationTree _animationTree;
|
||||
private Camera3D _camera;
|
||||
private Marker3D _cameraAnchor;
|
||||
private AnimationPlayer _animationPlayer;
|
||||
private AnimationTree _animationTree;
|
||||
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float LookSensitivity { get; set; } = 1f;
|
||||
@@ -63,11 +63,11 @@ public partial class HeadSystem : Node3D
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float SlidingJitterAmplitude { get; set; } = 0.1f;
|
||||
|
||||
internal FastNoiseLite _slidingNoise = new FastNoiseLite();
|
||||
private FastNoiseLite _slidingNoise = new FastNoiseLite();
|
||||
|
||||
[ExportGroup("Bobbing")]
|
||||
|
||||
internal float _bobbingAccumulator; // Constantly increases when player moves in X or/and Z axis
|
||||
private float _bobbingAccumulator; // Constantly increases when player moves in X or/and Z axis
|
||||
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
|
||||
public float BobbingFrequency { set; get; } = 2.4f;
|
||||
[Export(PropertyHint.Range, "0,0.4,0.01,or_greater")]
|
||||
@@ -84,11 +84,11 @@ public partial class HeadSystem : Node3D
|
||||
public float FovMaxedOutSpeed { get; set; } = 20f;
|
||||
|
||||
[ExportGroup("First Person rig")]
|
||||
internal Node3D _fpRig;
|
||||
internal Node3D _rightHandedWeapon;
|
||||
internal Node3D _leftHandedWeapon;
|
||||
internal Node3D _fpDisplacedRig;
|
||||
internal Vector3 _fpDisplacedRigInitialRotation;
|
||||
private Node3D _fpRig;
|
||||
private Node3D _rightHandedWeapon;
|
||||
private Node3D _leftHandedWeapon;
|
||||
private Node3D _fpDisplacedRig;
|
||||
private Vector3 _fpDisplacedRigInitialRotation;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
public float WeaponSway { get; set; } = 5f;
|
||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||
@@ -190,8 +190,8 @@ public partial class HeadSystem : Node3D
|
||||
EmitSignalHitboxDeactivated();
|
||||
}
|
||||
|
||||
internal bool _footstepEmitted;
|
||||
internal bool _isPlayingForcingAnim;
|
||||
private bool _footstepEmitted;
|
||||
private bool _isPlayingForcingAnim;
|
||||
|
||||
public void ResetHeadBobbing()
|
||||
{
|
||||
|
||||
@@ -22,11 +22,11 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer
|
||||
[Export(PropertyHint.Range, "0,0.2,0.01,or_greater")]
|
||||
public float StraightThrowDuration { get; set; } = 0.1f;
|
||||
|
||||
private StateChart _weaponState = null!;
|
||||
public StateChartState InHandState = null!;
|
||||
public StateChartState FlyingState = null!;
|
||||
public StateChartState PlantedState = null!;
|
||||
private ShapeCast3D _dashCast3D = null!;
|
||||
private StateChart _weaponState;
|
||||
public StateChartState InHandState;
|
||||
public StateChartState FlyingState;
|
||||
public StateChartState PlantedState;
|
||||
private ShapeCast3D _dashCast3D;
|
||||
|
||||
private Transform3D _startTransform;
|
||||
private Vector3 _startMeshRotation;
|
||||
@@ -36,9 +36,9 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer
|
||||
public Vector3 PlantNormal { get; set; }
|
||||
public Node? PlantObject { get; set; }
|
||||
|
||||
public MeshInstance3D WeaponLocationIndicator { get; set; } = null!;
|
||||
public StandardMaterial3D WeaponLocationIndicatorMaterial { get; set; } = null!;
|
||||
public MeshInstance3D WeaponMesh { get; set; } = null!;
|
||||
public MeshInstance3D WeaponLocationIndicator { get; set; }
|
||||
public StandardMaterial3D WeaponLocationIndicatorMaterial { get; set; }
|
||||
public MeshInstance3D WeaponMesh { get; set; }
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
||||
@@ -49,45 +49,45 @@ public partial class PlayerController : CharacterBody3D,
|
||||
[Signal]
|
||||
public delegate void PlayerDiedEventHandler();
|
||||
|
||||
public event Action<IDamageable, DamageRecord> DamageTaken = null!;
|
||||
public event Action<IHealthable, HealthChangedRecord> HealthChanged = null!;
|
||||
public event Action<IHealthable> HealthDepleted = null!;
|
||||
public event Action<IDamageable, DamageRecord> DamageTaken;
|
||||
public event Action<IHealthable, HealthChangedRecord> HealthChanged;
|
||||
public event Action<IHealthable> HealthDepleted;
|
||||
|
||||
///////////////////////////
|
||||
// Public stuff //
|
||||
///////////////////////////
|
||||
public HeadSystem HeadSystem = null!;
|
||||
public StairsSystem StairsSystem = null!;
|
||||
public MantleSystem MantleSystem = null!;
|
||||
public DashSystem DashSystem = null!;
|
||||
public CollisionShape3D StandingCollider = null!;
|
||||
public CollisionShape3D SlideCollider = null!;
|
||||
public WeaponSystem WeaponSystem = null!;
|
||||
public WallHugSystem WallHugSystem = null!;
|
||||
public PlayerUi PlayerUi = null!;
|
||||
public TextureRect DashIndicator = null!;
|
||||
public ColorRect PowerCooldownIndicator = null!;
|
||||
public Node3D DashIndicatorNode = null!;
|
||||
public MeshInstance3D DashIndicatorMesh = null!;
|
||||
public CylinderMesh DashIndicatorMeshCylinder = null!;
|
||||
public RayCast3D WallRunSnapper = null!;
|
||||
public ShapeCast3D GroundDetector = null!;
|
||||
public ShapeCast3D CeilingDetector = null!;
|
||||
public RayCast3D DirectGroundDetector = null!;
|
||||
public Area3D WeaponHitbox = null!;
|
||||
public AudioStreamPlayer3D SfxPlayer = null!;
|
||||
public HeadSystem HeadSystem;
|
||||
public StairsSystem StairsSystem;
|
||||
public MantleSystem MantleSystem;
|
||||
public DashSystem DashSystem;
|
||||
public CollisionShape3D StandingCollider;
|
||||
public CollisionShape3D SlideCollider;
|
||||
public WeaponSystem WeaponSystem;
|
||||
public WallHugSystem WallHugSystem;
|
||||
public PlayerUi PlayerUi;
|
||||
public TextureRect DashIndicator;
|
||||
public ColorRect PowerCooldownIndicator;
|
||||
public Node3D DashIndicatorNode;
|
||||
public MeshInstance3D DashIndicatorMesh;
|
||||
public CylinderMesh DashIndicatorMeshCylinder;
|
||||
public RayCast3D WallRunSnapper;
|
||||
public ShapeCast3D GroundDetector;
|
||||
public ShapeCast3D CeilingDetector;
|
||||
public RayCast3D DirectGroundDetector;
|
||||
public Area3D WeaponHitbox;
|
||||
public AudioStreamPlayer3D SfxPlayer;
|
||||
|
||||
public ShapeCast3D DashDamageDetector = null!;
|
||||
public Area3D SlidingEnemyDetector = null!;
|
||||
public ShapeCast3D DashDamageDetector;
|
||||
public Area3D SlidingEnemyDetector;
|
||||
|
||||
public EntityAttributes Attributes { get; set; } = null!;
|
||||
public EntityTags Tags { get; set; } = null!;
|
||||
public EffectsManager EffectsManager { get; set; } = null!;
|
||||
public EntityAbilities Abilities { get; set; } = null!;
|
||||
public EventManager Events { get; set; } = null!;
|
||||
public EntityAttributes Attributes { get; set; }
|
||||
public EntityTags Tags { get; set; }
|
||||
public EffectsManager EffectsManager { get; set; }
|
||||
public EntityAbilities Abilities { get; set; }
|
||||
public EventManager Events { get; set; }
|
||||
|
||||
// Inspector stuff
|
||||
[Export] public Marker3D TutorialWeaponTarget = null!;
|
||||
[Export] public Marker3D TutorialWeaponTarget;
|
||||
[Export] public bool TutorialDone { get; set; }
|
||||
[Export] public bool HasSword { get; set; } = true;
|
||||
[Export] public bool HasParry { get; set; } = true;
|
||||
@@ -102,9 +102,9 @@ public partial class PlayerController : CharacterBody3D,
|
||||
[Export(PropertyHint.Range, "0,10f,0.1,or_greater")]
|
||||
public float AimAssistReductionStartDistance { get; set; } = 10f;
|
||||
|
||||
[ExportGroup("Damage")] [Export] public RDamage RDamage { get; set; } = null!;
|
||||
[Export] public RKnockback? RKnockback { get; set; } = null!;
|
||||
[Export] public RHealth? RHealth { get; set; } = null!;
|
||||
[ExportGroup("Damage")] [Export] public RDamage RDamage { get; set; }
|
||||
[Export] public RKnockback? RKnockback { get; set; }
|
||||
[Export] public RHealth? RHealth { get; set; }
|
||||
|
||||
[ExportGroup("Targeting")]
|
||||
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
|
||||
@@ -114,7 +114,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
[ExportGroup("Instantiation")]
|
||||
[Export]
|
||||
public PackedScene Explosion { get; set; } = null!;
|
||||
public PackedScene Explosion { get; set; }
|
||||
|
||||
// Movement stuff
|
||||
[ExportCategory("Movement")]
|
||||
@@ -141,7 +141,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float MantleTime { get; set; } = 0.1f;
|
||||
[Export]
|
||||
public PackedScene MantlePath { get; set; } = null!;
|
||||
public PackedScene MantlePath { get; set; }
|
||||
|
||||
[Export(PropertyHint.Range, "0,50,0.1")]
|
||||
public float MantleDashStrength { get; set; } = 15f;
|
||||
@@ -266,8 +266,8 @@ public partial class PlayerController : CharacterBody3D,
|
||||
// Stairs and shit
|
||||
private float _lastFrameWasOnFloor = -Mathf.Inf;
|
||||
private const int NumOfHeadCollisionDetectors = 4;
|
||||
private RayCast3D[] _headCollisionDetectors = null!;
|
||||
private AudioStreamPlaybackInteractive _audioStream = null!;
|
||||
private RayCast3D[] _headCollisionDetectors;
|
||||
private AudioStreamPlaybackInteractive _audioStream;
|
||||
|
||||
// Basic movement
|
||||
private bool _movementEnabled = true;
|
||||
@@ -277,8 +277,8 @@ public partial class PlayerController : CharacterBody3D,
|
||||
private float _inputRotateFloorplane;
|
||||
|
||||
// Basic falling
|
||||
internal float TargetSpeed;
|
||||
internal float Gravity;
|
||||
private float TargetSpeed;
|
||||
private float Gravity;
|
||||
|
||||
// Jump stuff
|
||||
private int _currentInputBufferFrames;
|
||||
@@ -291,7 +291,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
private Path? _mantlePath;
|
||||
private bool _customMantle;
|
||||
private Transform3D _customMantleStartTransform;
|
||||
private Curve3D _customMantleCurve = null!;
|
||||
private Curve3D _customMantleCurve;
|
||||
private Vector3 _mantleStartPosition;
|
||||
private Vector3 _velocityOnMantleStarted = Vector3.Zero;
|
||||
|
||||
@@ -302,7 +302,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
private Vector3 _currentWallContactPoint = Vector3.Zero;
|
||||
|
||||
// Dash stuff
|
||||
internal bool CanDash = true;
|
||||
private bool CanDash = true;
|
||||
private bool _canDashAirborne = true;
|
||||
private float _playerHeight;
|
||||
private float _playerRadius;
|
||||
@@ -328,56 +328,56 @@ public partial class PlayerController : CharacterBody3D,
|
||||
private float _aimAssistMultiplier = 1.0f;
|
||||
|
||||
// Timers
|
||||
private Timer _timeScaleAimInAirTimer = null!;
|
||||
private Timer _weaponThrowUncatchableTimer = null!;
|
||||
private Timer _simpleDashCooldownTimer = null!;
|
||||
private Timer _airborneDashCooldownTimer = null!;
|
||||
private Timer _powerCooldownTimer = null!;
|
||||
private Timer _invincibilityTimer = null!;
|
||||
private Timer _attackCooldown = null!;
|
||||
private Timer _timeScaleAimInAirTimer;
|
||||
private Timer _weaponThrowUncatchableTimer;
|
||||
private Timer _simpleDashCooldownTimer;
|
||||
private Timer _airborneDashCooldownTimer;
|
||||
private Timer _powerCooldownTimer;
|
||||
private Timer _invincibilityTimer;
|
||||
private Timer _attackCooldown;
|
||||
|
||||
// State chart
|
||||
private StateChart _playerState = null!;
|
||||
private StateChart _playerState;
|
||||
|
||||
private StateChartState _aiming = null!;
|
||||
private StateChartState _powerExpired = null!;
|
||||
private StateChartState _powerRecharging = null!;
|
||||
private StateChartState _powerFull = null!;
|
||||
private StateChartState _aiming;
|
||||
private StateChartState _powerExpired;
|
||||
private StateChartState _powerRecharging;
|
||||
private StateChartState _powerFull;
|
||||
|
||||
private StateChartState _grounded = null!;
|
||||
private StateChartState _airborne = null!;
|
||||
private StateChartState _coyoteEnabled = null!;
|
||||
private StateChartState _jumping = null!;
|
||||
private StateChartState _simpleJump = null!;
|
||||
private StateChartState _doubleJump = null!;
|
||||
private StateChartState _mantling = null!;
|
||||
private StateChartState _simpleDash = null!;
|
||||
private StateChartState _aimedDash = null!;
|
||||
private StateChartState _weaponDash = null!;
|
||||
private StateChartState _sliding = null!;
|
||||
private StateChartState _groundSliding = null!;
|
||||
private StateChartState _airGliding = null!;
|
||||
private StateChartState _airGlidingDoubleJump = null!;
|
||||
private StateChartState _slideCanceled = null!;
|
||||
private StateChartState _slamming = null!;
|
||||
private StateChartState _onWall = null!;
|
||||
private StateChartState _onWallHugging = null!;
|
||||
private StateChartState _onWallHanging = null!;
|
||||
private StateChartState _onWallRunning = null!;
|
||||
private StateChartState _grounded;
|
||||
private StateChartState _airborne;
|
||||
private StateChartState _coyoteEnabled;
|
||||
private StateChartState _jumping;
|
||||
private StateChartState _simpleJump;
|
||||
private StateChartState _doubleJump;
|
||||
private StateChartState _mantling;
|
||||
private StateChartState _simpleDash;
|
||||
private StateChartState _aimedDash;
|
||||
private StateChartState _weaponDash;
|
||||
private StateChartState _sliding;
|
||||
private StateChartState _groundSliding;
|
||||
private StateChartState _airGliding;
|
||||
private StateChartState _airGlidingDoubleJump;
|
||||
private StateChartState _slideCanceled;
|
||||
private StateChartState _slamming;
|
||||
private StateChartState _onWall;
|
||||
private StateChartState _onWallHugging;
|
||||
private StateChartState _onWallHanging;
|
||||
private StateChartState _onWallRunning;
|
||||
|
||||
private StateChartState _attackStandard = null!;
|
||||
private StateChartState _attackDash = null!;
|
||||
private StateChartState _parryStandard = null!;
|
||||
private StateChartState _parryDash = null!;
|
||||
private StateChartState _attackStandard;
|
||||
private StateChartState _attackDash;
|
||||
private StateChartState _parryStandard;
|
||||
private StateChartState _parryDash;
|
||||
|
||||
private Transition _onJumpFromWall = null!;
|
||||
private Transition _onJumpFromWallFalling = null!;
|
||||
private Transition _onJumpFromWallRunning = null!;
|
||||
private Transition _onLeaveWallFromRun = null!;
|
||||
private Transition _onAirborneToGrounded = null!;
|
||||
private Transition _onJumpFromWall;
|
||||
private Transition _onJumpFromWallFalling;
|
||||
private Transition _onJumpFromWallRunning;
|
||||
private Transition _onLeaveWallFromRun;
|
||||
private Transition _onAirborneToGrounded;
|
||||
|
||||
private Transition _onGroundSlideJump = null!;
|
||||
private Transition _onAirGlideDoubleJump = null!;
|
||||
private Transition _onGroundSlideJump;
|
||||
private Transition _onAirGlideDoubleJump;
|
||||
|
||||
// Damage
|
||||
public CDamageable? CDamageable { get; set; }
|
||||
@@ -395,9 +395,9 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
private readonly List<IDamageable> _hitEnemies = new List<IDamageable>();
|
||||
|
||||
private ShapeCast3D _closeEnemyDetector = null!;
|
||||
private RayCast3D _aimAssisRayCast = null!;
|
||||
private Camera3D _camera = null!;
|
||||
private ShapeCast3D _closeEnemyDetector;
|
||||
private RayCast3D _aimAssisRayCast;
|
||||
private Camera3D _camera;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -2348,7 +2348,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_audioStream.SwitchToClipByName("parry");
|
||||
}
|
||||
|
||||
private PhysicsDirectSpaceState3D _spaceState = null!;
|
||||
private PhysicsDirectSpaceState3D _spaceState;
|
||||
public void StartDashAction(bool isParry)
|
||||
{
|
||||
if (isParry) HeadSystem.OnParry();
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.systems.damage;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class DamageComponentUnitTest
|
||||
{
|
||||
[TestCase]
|
||||
public void DamageModifierAppliesWhenTypeMatches()
|
||||
{
|
||||
var input = new DamageRecord(Vector3.Zero, new RDamage(10.0f, EDamageTypes.Normal));
|
||||
var modifier = new RDamageModifier(EDamageTypes.Normal, 2.0f);
|
||||
var signalTriggered = false;
|
||||
modifier.DamageTaken += (_, _) => signalTriggered = true;
|
||||
|
||||
var result = modifier.TakeDamage(input);
|
||||
|
||||
AssertFloat(result.Damage.DamageDealt).IsEqual(20.0f);
|
||||
AssertBool(signalTriggered).IsTrue();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void DamageModifierIgnoresWhenTypeDifferent()
|
||||
{
|
||||
var input = new DamageRecord(Vector3.Zero, new RDamage(10.0f, EDamageTypes.Normal));
|
||||
var modifier = new RDamageModifier(EDamageTypes.Fire, 3.0f);
|
||||
var signalTriggered = false;
|
||||
modifier.DamageTaken += (_, _) => signalTriggered = true;
|
||||
|
||||
var result = modifier.TakeDamage(input);
|
||||
|
||||
AssertFloat(result.Damage.DamageDealt).IsEqual(0.0f);
|
||||
AssertBool(signalTriggered).IsFalse(); // No damage actually taken
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void DamageableSumsAllModifiers()
|
||||
{
|
||||
var mod1 = new RDamageModifier(EDamageTypes.Normal, 1.0f);
|
||||
var mod2 = new RDamageModifier(EDamageTypes.Normal, 0.5f);
|
||||
|
||||
var damageable = new CDamageable();
|
||||
damageable.DamageModifiers = new[] { mod1, mod2 };
|
||||
var signalTriggered = false;
|
||||
damageable.DamageTaken += (_, _) => signalTriggered = true;
|
||||
|
||||
var input = new DamageRecord(Vector3.Zero, new RDamage(10.0f, EDamageTypes.Normal));
|
||||
var result = damageable.TakeDamage(input);
|
||||
|
||||
AssertFloat(result.Damage.DamageDealt).IsEqual(15.0f);
|
||||
AssertBool(signalTriggered).IsTrue();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void ComputeDamageModifierAppliesWhenTypeMatches()
|
||||
{
|
||||
var input = new DamageRecord(Vector3.Zero, new RDamage(10.0f, EDamageTypes.Normal));
|
||||
var modifier = new RDamageModifier(EDamageTypes.Normal, 2.0f);
|
||||
var signalTriggered = false;
|
||||
modifier.DamageTaken += (_, _) => signalTriggered = true;
|
||||
|
||||
var result = modifier.ComputeDamage(input);
|
||||
|
||||
AssertFloat(result.Damage.DamageDealt).IsEqual(20.0f);
|
||||
AssertBool(signalTriggered).IsFalse();
|
||||
}
|
||||
[TestCase]
|
||||
public void ComputeDamageModifierIgnoresWhenTypeDifferent()
|
||||
{
|
||||
var input = new DamageRecord(Vector3.Zero, new RDamage(10.0f, EDamageTypes.Normal));
|
||||
var modifier = new RDamageModifier(EDamageTypes.Fire, 3.0f);
|
||||
var signalTriggered = false;
|
||||
modifier.DamageTaken += (_, _) => signalTriggered = true;
|
||||
|
||||
var result = modifier.ComputeDamage(input);
|
||||
|
||||
AssertFloat(result.Damage.DamageDealt).IsEqual(0.0f);
|
||||
AssertBool(signalTriggered).IsFalse();
|
||||
}
|
||||
[TestCase]
|
||||
public void ComputeDamageableSumsAllModifiers()
|
||||
{
|
||||
var mod1 = new RDamageModifier(EDamageTypes.Normal, 1.0f);
|
||||
var mod2 = new RDamageModifier(EDamageTypes.Normal, 0.5f);
|
||||
|
||||
var cDamageable = new CDamageable();
|
||||
cDamageable.DamageModifiers = new[] { mod1, mod2 };
|
||||
var signalTriggered = false;
|
||||
cDamageable.DamageTaken += (_, _) => signalTriggered = true;
|
||||
|
||||
var input = new DamageRecord(Vector3.Zero, new RDamage(10.0f, EDamageTypes.Normal));
|
||||
var result = cDamageable.ComputeDamage(input);
|
||||
|
||||
AssertFloat(result.Damage.DamageDealt).IsEqual(15.0f);
|
||||
AssertBool(signalTriggered).IsFalse();
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://db6rva7uccppc
|
||||
@@ -1,55 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.systems.damage;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class HealthComponentUnitTest
|
||||
{
|
||||
[TestCase]
|
||||
public void ReadyInitializesCurrentHealth()
|
||||
{
|
||||
var cHealth = new CHealth();
|
||||
cHealth.RHealth = new RHealth(150.0f);
|
||||
cHealth._Ready();
|
||||
AssertFloat(cHealth.CurrentHealth).IsEqual(150.0f);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void ReduceHealthDecreasesAndDoesNotDeplete()
|
||||
{
|
||||
var cHealth = new CHealth();
|
||||
cHealth.RHealth = new RHealth(100.0f);
|
||||
cHealth.CurrentHealth = 100.0f;
|
||||
|
||||
var damage = new DamageRecord(Vector3.Zero, new RDamage(25.0f, EDamageTypes.Normal));
|
||||
var record = cHealth.ReduceHealth(source: null!, damageRecord: damage);
|
||||
|
||||
AssertFloat(cHealth.CurrentHealth).IsEqual(75.0f);
|
||||
AssertFloat(record.CurrentHealth).IsEqual(75.0f);
|
||||
AssertFloat(record.PreviousHealth).IsEqual(100.0f);
|
||||
AssertFloat(record.MaxHealth).IsEqual(100.0f);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void ReduceHealthTriggersDepletionToZero()
|
||||
{
|
||||
var cHealth = new CHealth();
|
||||
cHealth.RHealth = new RHealth(50.0f);
|
||||
cHealth.CurrentHealth = 50.0f;
|
||||
|
||||
bool depleted = false;
|
||||
cHealth.HealthDepleted += _ => depleted = true;
|
||||
|
||||
var damage = new DamageRecord(Vector3.Zero, new RDamage(100.0f, EDamageTypes.Normal));
|
||||
var record = cHealth.ReduceHealth(source: null!, damageRecord: damage);
|
||||
|
||||
AssertBool(depleted).IsTrue();
|
||||
AssertFloat(cHealth.CurrentHealth).IsEqual(0.0f);
|
||||
AssertFloat(record.CurrentHealth).IsEqual(-50.0f);
|
||||
AssertFloat(record.MaxHealth).IsEqual(50.0f);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://bd52i51hncgmf
|
||||
@@ -1,32 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.systems.damage;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class KnockbackComponentUnitTest
|
||||
{
|
||||
[TestCase]
|
||||
public void RegisterAndComputeKnockback()
|
||||
{
|
||||
var cKnock = new CKnockback();
|
||||
cKnock.RKnockback = new RKnockback(2.0f);
|
||||
cKnock.GlobalPosition = Vector3.Zero;
|
||||
|
||||
var damage = new DamageRecord(new Vector3(10, 0, 0), new RDamage(0, EDamageTypes.Normal));
|
||||
var record = new KnockbackRecord(damage, 1.5f);
|
||||
|
||||
cKnock.RegisterKnockback(record);
|
||||
var force = cKnock.ComputeKnockback();
|
||||
|
||||
// Direction from source(10,0,0) to target(0,0,0) is (-1,0,0), scaled by modifier(2) and multiplier(1.5) => (-3,0,0)
|
||||
AssertVector(force).IsEqual(new Vector3(-3, 0, 0));
|
||||
|
||||
// Second call returns zero since internal state resets
|
||||
var second = cKnock.ComputeKnockback();
|
||||
AssertVector(second).IsEqual(Vector3.Zero);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://bv0eionbgbig5
|
||||
@@ -1,32 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.scenes.movement;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class MovementSystemUnitTest
|
||||
{
|
||||
[TestCase]
|
||||
public void GroundedMovementAcceleratesAndAppliesGravity()
|
||||
{
|
||||
var move = new CGroundedMovement();
|
||||
move.RMovement = new RMovement(speed: 10.0f, acceleration: 1.0f, gravityModifier: 0.5f, targetHeight: 0.0f);
|
||||
move.WallInFrontRayCast = new RayCast3D();
|
||||
//move.GlobalPosition = Vector3.Zero;
|
||||
|
||||
var inputs = new MovementInputs(
|
||||
Velocity: Vector3.Zero,
|
||||
TargetLocation: new Vector3(10, 0, 0),
|
||||
isOnFloor: false,
|
||||
gravity: Vector3.Down * 9.8f,
|
||||
delta: 1.0
|
||||
);
|
||||
|
||||
var v = move.ComputeVelocity(inputs);
|
||||
|
||||
AssertVector(v).IsEqualApprox(new Vector3(10, -4.9f, 0), new Vector3(0.001f, 0.001f, 0.001f));
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://cofj5s4x74ay
|
||||
@@ -1,30 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.systems.damage;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class EnemyUnitTest
|
||||
{
|
||||
[TestCase]
|
||||
public void ComputeDamageNoComponent()
|
||||
{
|
||||
var enemy = new Enemy();
|
||||
var input = new DamageRecord(Vector3.Zero, new RDamage(10.0f, EDamageTypes.Normal));
|
||||
|
||||
var result = enemy.ComputeDamage(input);
|
||||
AssertFloat(result.Damage.DamageDealt).IsEqual(0.0f);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void Unstun()
|
||||
{
|
||||
var enemy = new Enemy();
|
||||
enemy.IsStunned = true;
|
||||
enemy.Unstun();
|
||||
AssertBool(enemy.IsStunned).IsFalse();
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://cojxgcs6xqqoq
|
||||
@@ -1,55 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.systems;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class DashSystemUnitTest
|
||||
{
|
||||
private DashSystem _dashSystem;
|
||||
|
||||
[BeforeTest]
|
||||
public void SetupTest()
|
||||
{
|
||||
_dashSystem = new DashSystem();
|
||||
|
||||
_dashSystem.DashCast3D = new ShapeCast3D();
|
||||
_dashSystem.AddChild(_dashSystem.DashCast3D);
|
||||
|
||||
_dashSystem.DashCastDrop = new ShapeCast3D();
|
||||
_dashSystem.AddChild(_dashSystem.DashCastDrop);
|
||||
|
||||
_dashSystem.DashTarget = new MeshInstance3D();
|
||||
_dashSystem.AddChild(_dashSystem.DashTarget);
|
||||
|
||||
_dashSystem.DashDropIndicator = new MeshInstance3D();
|
||||
_dashSystem.AddChild(_dashSystem.DashDropIndicator);
|
||||
|
||||
_dashSystem.DashDropLocationIndicator = new MeshInstance3D();
|
||||
_dashSystem.AddChild(_dashSystem.DashDropLocationIndicator);
|
||||
}
|
||||
|
||||
[AfterTest]
|
||||
public void CleanupTest()
|
||||
{
|
||||
_dashSystem?.Free();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestStopPreparingDash()
|
||||
{
|
||||
_dashSystem.CanDashThroughTarget = true;
|
||||
_dashSystem.DashTarget.Visible = true;
|
||||
_dashSystem.DashDropIndicator.Visible = true;
|
||||
_dashSystem.DashDropLocationIndicator.Visible = true;
|
||||
|
||||
_dashSystem.StopPreparingDash();
|
||||
|
||||
AssertBool(_dashSystem.CanDashThroughTarget).IsFalse();
|
||||
AssertBool(_dashSystem.DashTarget.Visible).IsFalse();
|
||||
AssertBool(_dashSystem.DashDropIndicator.Visible).IsFalse();
|
||||
AssertBool(_dashSystem.DashDropLocationIndicator.Visible).IsFalse();
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://pv570go4cxws
|
||||
@@ -1,91 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.systems;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class HeadSystemUnitTest
|
||||
{
|
||||
private HeadSystem _head;
|
||||
|
||||
[BeforeTest]
|
||||
public void SetupTest()
|
||||
{
|
||||
_head = new HeadSystem();
|
||||
_head._camera = new Camera3D();
|
||||
_head.AddChild(_head._camera);
|
||||
|
||||
_head._cameraAnchor = new Marker3D();
|
||||
_head.AddChild(_head._cameraAnchor);
|
||||
|
||||
_head._fpRig = new Node3D();
|
||||
_head.AddChild(_head._fpRig);
|
||||
|
||||
_head._fpDisplacedRig = new Node3D();
|
||||
_head.AddChild(_head._fpDisplacedRig);
|
||||
}
|
||||
|
||||
[AfterTest]
|
||||
public void CleanupTest()
|
||||
{
|
||||
_head?.Free();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestResetHeadBobbing()
|
||||
{
|
||||
_head._bobbingAccumulator = 10.0f;
|
||||
_head.ResetHeadBobbing();
|
||||
AssertFloat(_head._bobbingAccumulator).IsEqual(0.0f);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestComputeHowMuchInputForward()
|
||||
{
|
||||
Vector3 forwardInput = new Vector3(0, 0, -1);
|
||||
AssertFloat(_head.ComputeHowMuchInputForward(forwardInput)).IsEqual(1.0f);
|
||||
|
||||
Vector3 backwardInput = new Vector3(0, 0, 1);
|
||||
AssertFloat(_head.ComputeHowMuchInputForward(backwardInput)).IsEqual(-1.0f);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestComputeHowMuchInputSideways()
|
||||
{
|
||||
Vector3 rightInput = new Vector3(1, 0, 0);
|
||||
AssertFloat(_head.ComputeHowMuchInputSideways(rightInput)).IsEqual(1.0f);
|
||||
|
||||
Vector3 leftInput = new Vector3(-1, 0, 0);
|
||||
AssertFloat(_head.ComputeHowMuchInputSideways(leftInput)).IsEqual(-1.0f);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestGetForwardHorizontalVector()
|
||||
{
|
||||
Vector3 forward = _head.GetForwardHorizontalVector();
|
||||
AssertVector(forward).IsEqualApprox(Vector3.Back, new Vector3(0.001f, 0.001f, 0.001f));
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestLookAroundRotation()
|
||||
{
|
||||
var inputs = new HeadSystem.CameraParameters(
|
||||
Delta: 0.016,
|
||||
LookDir: new Vector2(1, 0),
|
||||
PlayerInput: Vector3.Zero,
|
||||
PlayerVelocity: Vector3.Zero,
|
||||
WallContactPoint: Vector3.Zero,
|
||||
SensitivitMultiplier: 1.0f,
|
||||
WithCameraJitter: false,
|
||||
WithCameraBobbing: false,
|
||||
BobbingMultiplier: 1.0f,
|
||||
FovMultiplier: 1.0f
|
||||
);
|
||||
|
||||
float initialY = _head.Rotation.Y;
|
||||
_head.LookAround(inputs);
|
||||
AssertFloat(_head.Rotation.Y).IsEqual(initialY + 1.0f);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://bp0xn8k3dmfkg
|
||||
@@ -1,149 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.systems.damage;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class PlayerControllerUnitTest
|
||||
{
|
||||
private PlayerController _player;
|
||||
|
||||
[BeforeTest]
|
||||
public void SetupTest()
|
||||
{
|
||||
_player = new PlayerController();
|
||||
_player.TargetSpeed = 7.0f;
|
||||
_player.Gravity = 9.8f;
|
||||
|
||||
var rHealth = new RHealth(100.0f);
|
||||
_player.RHealth = rHealth;
|
||||
_player.CHealth = new CHealth { RHealth = rHealth, CurrentHealth = 100.0f };
|
||||
}
|
||||
|
||||
[AfterTest]
|
||||
public void CleanupTest()
|
||||
{
|
||||
_player?.Free();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestCalculateGravityForce()
|
||||
{
|
||||
_player.Weight = 3.0f;
|
||||
// gravity is 9.8f
|
||||
AssertFloat(_player.CalculateGravityForce()).IsEqualApprox(29.4f, 0.001f);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestIsPlayerInputtingForward()
|
||||
{
|
||||
// Test Keyboard Input
|
||||
_player.InputDeviceChanged(false);
|
||||
_player.OnInputMoveKeyboard(Vector3.Forward);
|
||||
AssertBool(_player.IsPlayerInputtingForward()).IsTrue();
|
||||
|
||||
_player.OnInputMoveKeyboard(Vector3.Back);
|
||||
AssertBool(_player.IsPlayerInputtingForward()).IsFalse();
|
||||
|
||||
// Test Gamepad Input
|
||||
_player.InputDeviceChanged(true);
|
||||
_player.OnInputMove(new Vector3(0, 0, -1));
|
||||
AssertBool(_player.IsPlayerInputtingForward()).IsTrue();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestSetVerticalVelocity()
|
||||
{
|
||||
_player.Velocity = new Vector3(1, 0, 2);
|
||||
_player.SetVerticalVelocity(5.0f);
|
||||
AssertVector(_player.Velocity).IsEqual(new Vector3(1, 5, 2));
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestComputeHVelocityGround()
|
||||
{
|
||||
_player.Velocity = Vector3.Zero;
|
||||
_player.AccelerationFloor = 10.0f;
|
||||
|
||||
float delta = 0.1f;
|
||||
Vector3 newVelocity = _player.ComputeHVelocity(delta, _player.AccelerationFloor, _player.DecelerationFloor, Vector3.Forward);
|
||||
AssertVector(newVelocity).IsEqual(new Vector3(0, 0, -7.0f));
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestComputeHVelocityAir()
|
||||
{
|
||||
_player.Velocity = new Vector3(5, 0, 0);
|
||||
_player.AccelerationAir = 2.0f;
|
||||
_player.DecelerationAir = 2.0f;
|
||||
|
||||
float delta = 0.5f;
|
||||
Vector3 newVelocity = _player.ComputeHVelocity(delta, _player.AccelerationAir, _player.DecelerationAir, Vector3.Zero);
|
||||
|
||||
AssertVector(newVelocity).IsEqual(Vector3.Zero);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestReduceHealth()
|
||||
{
|
||||
var damageRecord = new DamageRecord(Vector3.Zero, new RDamage(25.0f, EDamageTypes.Normal));
|
||||
_player.ReduceHealth(_player, damageRecord);
|
||||
AssertFloat(_player.CHealth.CurrentHealth).IsEqual(75.0f);
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestEmpoweredActionsLeft()
|
||||
{
|
||||
var mockUi = new PlayerUi();
|
||||
var dashIcons = new TextureRect[3] { new TextureRect(), new TextureRect(), new TextureRect() };
|
||||
mockUi._dashIcons = dashIcons;
|
||||
|
||||
_player.PlayerUi = mockUi;
|
||||
|
||||
_player.EmpoweredActionsLeft = 2;
|
||||
AssertInt(_player.EmpoweredActionsLeft).IsEqual(2);
|
||||
AssertBool(dashIcons[0].Visible).IsTrue();
|
||||
AssertBool(dashIcons[1].Visible).IsTrue();
|
||||
AssertBool(dashIcons[2].Visible).IsFalse();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestDashCooldownTimeout()
|
||||
{
|
||||
_player.CanDash = false;
|
||||
_player.DashCooldownTimeout();
|
||||
AssertBool(_player.CanDash).IsTrue();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestGetInputLocalHDirection()
|
||||
{
|
||||
_player.InputDeviceChanged(false);
|
||||
_player.OnInputMoveKeyboard(new Vector3(1, 0, 1));
|
||||
|
||||
Vector3 expected = new Vector3(1, 0, 1).Normalized();
|
||||
AssertVector(_player.GetInputLocalHDirection()).IsEqualApprox(expected, new Vector3(0.001f, 0.001f, 0.001f));
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestComputeKnockback()
|
||||
{
|
||||
var cKnockback = new CKnockback();
|
||||
cKnockback.RKnockback = new RKnockback(10.0f);
|
||||
_player.CKnockback = cKnockback;
|
||||
|
||||
var damageRecord = new DamageRecord(new Vector3(10, 0, 0), new RDamage(0, EDamageTypes.Normal));
|
||||
var knockbackRecord = new KnockbackRecord(damageRecord, 1.0f);
|
||||
|
||||
_player.GlobalPosition = Vector3.Zero;
|
||||
cKnockback.GlobalPosition = Vector3.Zero;
|
||||
|
||||
_player.RegisterKnockback(knockbackRecord);
|
||||
|
||||
Vector3 knockback = cKnockback.ComputeKnockback();
|
||||
AssertVector(knockback).IsEqual(new Vector3(-10, 0, 0));
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://kmphtu0ovixi
|
||||
@@ -1,51 +0,0 @@
|
||||
using Godot;
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
using Movementtests.systems;
|
||||
using Movementtests.systems.damage;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class WeaponSystemUnitTest
|
||||
{
|
||||
private WeaponSystem _weapon;
|
||||
|
||||
[BeforeTest]
|
||||
public void SetupTest()
|
||||
{
|
||||
_weapon = new WeaponSystem();
|
||||
_weapon.RDamage = new RDamage(5.0f, EDamageTypes.Normal);
|
||||
|
||||
_weapon.WeaponMesh = new MeshInstance3D();
|
||||
_weapon.AddChild(_weapon.WeaponMesh);
|
||||
_weapon.WeaponLocationIndicator = new MeshInstance3D();
|
||||
_weapon.AddChild(_weapon.WeaponLocationIndicator);
|
||||
}
|
||||
|
||||
[AfterTest]
|
||||
public void CleanupTest()
|
||||
{
|
||||
_weapon?.Free();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestWeaponLeftAndBackVisibility()
|
||||
{
|
||||
_weapon.Visible = false;
|
||||
|
||||
_weapon.WeaponLeft();
|
||||
AssertBool(_weapon.Visible).IsTrue();
|
||||
|
||||
_weapon.WeaponBack();
|
||||
AssertBool(_weapon.Visible).IsFalse();
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void TestThrowWeaponOnCurveSetsUnfrozen()
|
||||
{
|
||||
_weapon.Freeze = true;
|
||||
_weapon.ThrowWeaponOnCurve();
|
||||
AssertBool(_weapon.Freeze).IsFalse();
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://vkv8aderakcb
|
||||
@@ -1,50 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Godot;
|
||||
using GodotStateCharts;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class PlayerInteractionsTest
|
||||
{
|
||||
private ISceneRunner _runner;
|
||||
private Node _scene;
|
||||
private PlayerController _player;
|
||||
|
||||
private readonly float _tolerance = 0.01f;
|
||||
private readonly Vector3 _vectorTolerance = new Vector3(0.01f, 0.01f, 0.01f);
|
||||
|
||||
[BeforeTest]
|
||||
public void SetupTest()
|
||||
{
|
||||
_runner = ISceneRunner.Load("res://tests/player/interactions/player_interactions_scene.tscn");
|
||||
|
||||
_scene = _runner.Scene()!;
|
||||
var player = _scene.FindChild("Player") as PlayerController;
|
||||
_player = player!;
|
||||
}
|
||||
[AfterTest]
|
||||
public void CleanupTest() {}
|
||||
|
||||
[TestCase("BaseLocation")]
|
||||
public async Task PlayerMoveForward(string markerName)
|
||||
{
|
||||
var marker = _scene.FindChild(markerName) as Marker3D;
|
||||
AssertObject(marker).IsNotNull();
|
||||
_player.GlobalPosition = marker!.GlobalPosition;
|
||||
await _runner.AwaitIdleFrame();
|
||||
|
||||
var startPos = _player.GlobalPosition;
|
||||
|
||||
_runner.SimulateKeyPress(Key.W);
|
||||
await _runner.AwaitMillis(300);
|
||||
_runner.SimulateKeyRelease(Key.W);
|
||||
|
||||
var endPos = _player.GlobalPosition;
|
||||
var direction = startPos.DirectionTo(endPos);
|
||||
AssertVector(direction).IsEqualApprox(Vector3.Forward, _vectorTolerance);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://denedm5b8rmhh
|
||||
@@ -1,35 +0,0 @@
|
||||
[gd_scene format=3 uid="uid://l0lflvsjbyvs"]
|
||||
|
||||
[ext_resource type="Material" uid="uid://31aulub2nqov" path="res://assets/materials/greybox/m_greybox.tres" id="1_dv0re"]
|
||||
[ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://scenes/player_controller/PlayerController.tscn" id="2_52d52"]
|
||||
|
||||
[node name="PlayerMovementScene" type="Node3D" unique_id=231040688]
|
||||
|
||||
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=241909240]
|
||||
use_collision = true
|
||||
collision_layer = 256
|
||||
collision_mask = 65553
|
||||
|
||||
[node name="Ground" type="CSGBox3D" parent="CSGCombiner3D" unique_id=432200143]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, -0.5, -3.25)
|
||||
use_collision = true
|
||||
collision_layer = 256
|
||||
collision_mask = 65553
|
||||
size = Vector3(1000, 1, 1000)
|
||||
material = ExtResource("1_dv0re")
|
||||
|
||||
[node name="Ground2" type="CSGBox3D" parent="CSGCombiner3D" unique_id=854660236]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.75, 0.5, -1.75)
|
||||
use_collision = true
|
||||
collision_layer = 256
|
||||
collision_mask = 65553
|
||||
size = Vector3(1.5, 1, 1.5)
|
||||
material = ExtResource("1_dv0re")
|
||||
|
||||
[node name="Player" parent="." unique_id=709076448 instance=ExtResource("2_52d52")]
|
||||
TutorialDone = true
|
||||
|
||||
[node name="BaseLocation" type="Marker3D" parent="." unique_id=1793710692]
|
||||
|
||||
[node name="MantleLocation1" type="Marker3D" parent="." unique_id=550080845]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.75, 0, 0)
|
||||
@@ -1,109 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using Godot;
|
||||
using GodotStateCharts;
|
||||
|
||||
namespace Movementtests.tests;
|
||||
|
||||
using GdUnit4;
|
||||
using static GdUnit4.Assertions;
|
||||
|
||||
[TestSuite, RequireGodotRuntime]
|
||||
public class PlayerMovementTest
|
||||
{
|
||||
private ISceneRunner _runner;
|
||||
private Node _scene;
|
||||
private PlayerController _player;
|
||||
|
||||
private readonly float _tolerance = 0.01f;
|
||||
private readonly Vector3 _vectorTolerance = new Vector3(0.01f, 0.01f, 0.01f);
|
||||
|
||||
[Before]
|
||||
public void Setup() {}
|
||||
[After]
|
||||
public void Cleanup() {}
|
||||
|
||||
[BeforeTest]
|
||||
public void SetupTest()
|
||||
{
|
||||
_runner = ISceneRunner.Load("res://tests/player/movement/player_movement_scene.tscn");
|
||||
|
||||
_scene = _runner.Scene()!;
|
||||
var player = _scene.FindChild("Player") as PlayerController;
|
||||
_player = player!;
|
||||
}
|
||||
[AfterTest]
|
||||
public void CleanupTest() {}
|
||||
|
||||
[TestCase("BaseLocation")]
|
||||
public async Task PlayerMoveForward(string markerName)
|
||||
{
|
||||
var marker = _scene.FindChild(markerName) as Marker3D;
|
||||
AssertObject(marker).IsNotNull();
|
||||
_player.GlobalPosition = marker!.GlobalPosition;
|
||||
await _runner.AwaitIdleFrame();
|
||||
|
||||
var startPos = _player.GlobalPosition;
|
||||
|
||||
_runner.SimulateKeyPress(Key.W);
|
||||
await _runner.AwaitMillis(100);
|
||||
_runner.SimulateKeyRelease(Key.W);
|
||||
|
||||
var endPos = _player.GlobalPosition;
|
||||
var direction = startPos.DirectionTo(endPos);
|
||||
AssertVector(direction).IsEqualApprox(Vector3.Forward, _vectorTolerance);
|
||||
}
|
||||
|
||||
[TestCase("BaseLocation")]
|
||||
public async Task PlayerJump(string markerName)
|
||||
{
|
||||
var marker = _scene.FindChild(markerName) as Marker3D;
|
||||
AssertObject(marker).IsNotNull();
|
||||
_player.GlobalPosition = marker!.GlobalPosition;
|
||||
await _runner.AwaitIdleFrame();
|
||||
|
||||
var startPos = _player.GlobalPosition;
|
||||
|
||||
_runner.SimulateKeyPress(Key.Space);
|
||||
await _runner.AwaitIdleFrame();
|
||||
|
||||
var jumping = StateChartState.Of(_player.GetNode("StateChart/Root/Movement/Jump"));
|
||||
AssertBool(jumping.Active).IsTrue();
|
||||
|
||||
_runner.SimulateKeyRelease(Key.Space);
|
||||
await _runner.AwaitIdleFrame();
|
||||
var endPos = _player.GlobalPosition;
|
||||
var direction = startPos.DirectionTo(endPos);
|
||||
AssertVector(direction).IsEqualApprox(Vector3.Up, _vectorTolerance);
|
||||
AssertVector(_player.Velocity.Normalized()).IsEqualApprox(Vector3.Up, _vectorTolerance);
|
||||
|
||||
await _runner.AwaitMillis(600);
|
||||
endPos = _player.GlobalPosition;
|
||||
AssertVector(endPos - startPos).IsEqualApprox(Vector3.Zero, _vectorTolerance);
|
||||
|
||||
var grounded = StateChartState.Of(_player.GetNode("StateChart/Root/Movement/Grounded"));
|
||||
AssertBool(grounded.Active).IsTrue();
|
||||
}
|
||||
|
||||
[TestCase("MantleLocation1")]
|
||||
public async Task PlayerMantle(string markerName)
|
||||
{
|
||||
var marker = _scene.FindChild(markerName) as Marker3D;
|
||||
AssertObject(marker).IsNotNull();
|
||||
_player.GlobalPosition = marker!.GlobalPosition;
|
||||
await _runner.AwaitMillis(100);
|
||||
|
||||
var startPos = _player.GlobalPosition;
|
||||
|
||||
_runner.SimulateKeyPress(Key.Space);
|
||||
await _runner.AwaitMillis(100);
|
||||
var mantling = StateChartState.Of(_player.GetNode("StateChart/Root/Movement/Mantling"));
|
||||
AssertBool(mantling.Active).IsTrue();
|
||||
|
||||
_runner.SimulateKeyRelease(Key.Space);
|
||||
await _runner.AwaitMillis(500);
|
||||
|
||||
var endPos = _player.GlobalPosition;
|
||||
AssertFloat((endPos - startPos).Length()).IsGreater(_tolerance);
|
||||
AssertFloat(endPos.Y).IsEqualApprox(1.0f, _tolerance);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://x5pj2ymam2gg
|
||||
@@ -1,35 +0,0 @@
|
||||
[gd_scene format=3 uid="uid://i8kb38q7bdfk"]
|
||||
|
||||
[ext_resource type="Material" uid="uid://31aulub2nqov" path="res://assets/materials/greybox/m_greybox.tres" id="1_bdfhg"]
|
||||
[ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://scenes/player_controller/PlayerController.tscn" id="1_hg1sy"]
|
||||
|
||||
[node name="PlayerMovementScene" type="Node3D" unique_id=231040688]
|
||||
|
||||
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=241909240]
|
||||
use_collision = true
|
||||
collision_layer = 256
|
||||
collision_mask = 65553
|
||||
|
||||
[node name="Ground" type="CSGBox3D" parent="CSGCombiner3D" unique_id=432200143]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, -0.5, -3.25)
|
||||
use_collision = true
|
||||
collision_layer = 256
|
||||
collision_mask = 65553
|
||||
size = Vector3(1000, 1, 1000)
|
||||
material = ExtResource("1_bdfhg")
|
||||
|
||||
[node name="Ground2" type="CSGBox3D" parent="CSGCombiner3D" unique_id=854660236]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.75, 0.5, -1.75)
|
||||
use_collision = true
|
||||
collision_layer = 256
|
||||
collision_mask = 65553
|
||||
size = Vector3(1.5, 1, 1.5)
|
||||
material = ExtResource("1_bdfhg")
|
||||
|
||||
[node name="Player" parent="." unique_id=709076448 instance=ExtResource("1_hg1sy")]
|
||||
TutorialDone = true
|
||||
|
||||
[node name="BaseLocation" type="Marker3D" parent="." unique_id=1793710692]
|
||||
|
||||
[node name="MantleLocation1" type="Marker3D" parent="." unique_id=550080845]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.75, 0, 0)
|
||||
Reference in New Issue
Block a user