Added a tiny bit of air control and a turnback jump trick.
Release / Export Game (push) Successful in 1m58s
Release / Export Game (push) Successful in 1m58s
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
[gd_resource type="SpriteFrames" format=3 uid="uid://trcnb1ubmx5e"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://wli5w6t8y6se" path="res://sprites/atlas/jump_point_radiates.png" id="1_3yoq3"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_aokl3"]
|
||||||
|
atlas = ExtResource("1_3yoq3")
|
||||||
|
region = Rect2(0, 32, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_xd81c"]
|
||||||
|
atlas = ExtResource("1_3yoq3")
|
||||||
|
region = Rect2(0, 64, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_u618n"]
|
||||||
|
atlas = ExtResource("1_3yoq3")
|
||||||
|
region = Rect2(0, 96, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_twrqh"]
|
||||||
|
atlas = ExtResource("1_3yoq3")
|
||||||
|
region = Rect2(32, 0, 32, 32)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_vrk17"]
|
||||||
|
atlas = ExtResource("1_3yoq3")
|
||||||
|
region = Rect2(0, 0, 32, 32)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_aokl3")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_xd81c")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_u618n")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_twrqh")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_vrk17")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 16.0
|
||||||
|
}]
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[gd_resource type="CircleShape2D" format=3 uid="uid://duhxyfwoh6ndb"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
radius = 3.0
|
||||||
File diff suppressed because one or more lines are too long
+21
-5
@@ -45,16 +45,16 @@ jump={
|
|||||||
}
|
}
|
||||||
look_up={
|
look_up={
|
||||||
"deadzone": 0.2,
|
"deadzone": 0.2,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":true,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
look_down={
|
look_down={
|
||||||
"deadzone": 0.2,
|
"deadzone": 0.2,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":true,"script":null)
|
||||||
]
|
]
|
||||||
@@ -62,7 +62,7 @@ look_down={
|
|||||||
run={
|
run={
|
||||||
"deadzone": 0.2,
|
"deadzone": 0.2,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":9,"pressure":0.0,"pressed":true,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
skip_music={
|
skip_music={
|
||||||
@@ -75,6 +75,22 @@ toggle_debug={
|
|||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":75,"key_label":0,"unicode":75,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":75,"key_label":0,"unicode":75,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
move_up={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_down={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://wli5w6t8y6se"
|
||||||
|
path="res://.godot/imported/jump_point_radiates.png-1a97dab1296f185bfc3d06015e15ec05.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://sprites/atlas/jump_point_radiates.png"
|
||||||
|
dest_files=["res://.godot/imported/jump_point_radiates.png-1a97dab1296f185bfc3d06015e15ec05.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
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
|
||||||
@@ -1,22 +1,32 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
public partial class PlayerPhysicsController : CharacterBody2D {
|
public partial class PlayerPhysicsController : CharacterBody2D {
|
||||||
// [Export]
|
// [Export]
|
||||||
// public float RunMultiplier { get; set; } = 1.84f;
|
// public float RunMultiplier { get; set; } = 1.84f;
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void OnTurnbackJumpEventHandler(bool onJumpPoint, bool isOnWall);
|
||||||
|
|
||||||
|
[ExportCategory("Accelerations and Impulses")]
|
||||||
[Export]
|
[Export]
|
||||||
public float WalkAcceleration { get; set; } = 3f;
|
public float WalkAcceleration { get; set; } = 3f;
|
||||||
[Export]
|
[Export]
|
||||||
public float StoppingDeceleration { get; set; } = 8f;
|
public float StoppingDeceleration { get; set; } = 8f;
|
||||||
[Export]
|
[Export]
|
||||||
public float CancellationAcceleration { get; set; } = 4f;
|
public float CancellationAcceleration { get; set; } = 4f;
|
||||||
|
[Export]
|
||||||
|
public float AirAcceleration { get; set; } = 0.5f;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public float JumpHeight { get; set; } = 5.5f;
|
public float JumpHeight { get; set; } = 5.5f;
|
||||||
|
|
||||||
private float PeakTime { get; set; } = 0.1f;
|
private float PeakTime { get; set; } = 0.1f;
|
||||||
|
|
||||||
|
[ExportCategory("Max Speeds")]
|
||||||
[Export]
|
[Export]
|
||||||
private float MaxFallSpeed { get; set; } = 8f;
|
private float MaxFallSpeed { get; set; } = 8f;
|
||||||
|
|
||||||
@@ -28,12 +38,17 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
[Export]
|
[Export]
|
||||||
private float MaxWalkSpeed { get; set; } = 8f;
|
private float MaxWalkSpeed { get; set; } = 8f;
|
||||||
|
|
||||||
|
[ExportCategory("Objects")]
|
||||||
[Export]
|
[Export]
|
||||||
public Label DebugTextLabel { get; set; }
|
public Label DebugTextLabel { get; set; }
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public AnimatedSprite2D Sprite { get; set; }
|
public AnimatedSprite2D Sprite { get; set; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public PredictiveCollisions Predictor { get; set; }
|
||||||
|
|
||||||
|
[ExportCategory("Physics Tweaks")]
|
||||||
[Export]
|
[Export]
|
||||||
public float Gravity { get; set; } = 30.625f;
|
public float Gravity { get; set; } = 30.625f;
|
||||||
|
|
||||||
@@ -49,6 +64,12 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
[Export]
|
[Export]
|
||||||
public float CoyoteTiming { get; set; } = 0.1f;
|
public float CoyoteTiming { get; set; } = 0.1f;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public float Deadzone { get; set; } = 0.1f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private float _lv = 0.0f;
|
private float _lv = 0.0f;
|
||||||
|
|
||||||
private void RecalculateLv() {
|
private void RecalculateLv() {
|
||||||
@@ -71,8 +92,8 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
Sprite.SpeedScale = absvel.X switch {
|
Sprite.SpeedScale = absvel.X switch {
|
||||||
< 10 => 1,
|
< 10 => 1,
|
||||||
< 150 => 2,
|
< 150 => 2,
|
||||||
< 300 => 4,
|
< 600 => 4,
|
||||||
_ => 1
|
_ => 4
|
||||||
};
|
};
|
||||||
if (!Sprite.IsPlaying())
|
if (!Sprite.IsPlaying())
|
||||||
Sprite.Play();
|
Sprite.Play();
|
||||||
@@ -95,15 +116,12 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export]
|
|
||||||
public float Deadzone { get; set; } = 0.1f;
|
|
||||||
|
|
||||||
public override void _PhysicsProcess(double delta) {
|
public override void _PhysicsProcess(double delta) {
|
||||||
var xAxis = Input.GetAxis("move_left", "move_right");
|
var xAxis = Input.GetAxis("move_left", "move_right");
|
||||||
var yAxis = Input.GetAxis("look_up", "look_down");
|
var yAxis = Input.GetAxis("move_up", "move_down");
|
||||||
|
var lookAxis = Input.GetAxis("look_up", "look_down");
|
||||||
// var jumpStrength = -Input.GetActionStrength("jump");
|
// var jumpStrength = -Input.GetActionStrength("jump");
|
||||||
|
|
||||||
var lastCollision = this.IsOnCeiling();
|
|
||||||
RecalculateLv();
|
RecalculateLv();
|
||||||
|
|
||||||
float velx = (Velocity.X / UnitToPx);
|
float velx = (Velocity.X / UnitToPx);
|
||||||
@@ -132,9 +150,45 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
if (Input.IsActionJustReleased("jump") && vely < 0) {
|
if (Input.IsActionJustReleased("jump") && vely < 0) {
|
||||||
vely *= 1/4f;
|
vely *= 1/4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Input.IsActionJustPressed("jump") && vely > 0) {
|
||||||
|
var side = velx > 0 ? PredictiveCollisions.Location.BottomRight : PredictiveCollisions.Location.BottomLeft;
|
||||||
|
if (Predictor.AnyHit(side) && !this.IsOnWall()) {
|
||||||
|
EmitSignal(SignalName.OnTurnbackJump, true, this.IsOnWall());
|
||||||
|
var hits = Predictor.GetLastCastHits(side);
|
||||||
|
_ = hits.First(x => {
|
||||||
|
if (x.Obj is null) return false;
|
||||||
|
var collider = x.AsGodotDictionary()["collider"].AsGodotObject();
|
||||||
|
if (collider.HasMeta("JumpPointAnimatable")) {
|
||||||
|
var animPath = collider.GetMeta("JumpPointAnimatable").AsNodePath();
|
||||||
|
var anim = collider.Call(MethodName.GetNode, animPath).As<AnimatedSprite2D>();
|
||||||
|
var frame = anim.Frame;
|
||||||
|
void anf() {
|
||||||
|
anim.Stop();
|
||||||
|
anim.Frame = frame;
|
||||||
|
anim.AnimationLooped -= anf;
|
||||||
|
};
|
||||||
|
anim.AnimationLooped += anf;
|
||||||
|
anim.Play();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
// has jump point
|
||||||
|
float theta = Mathf.Atan2(-yAxis, xAxis);
|
||||||
|
if (theta < 0) theta = 0;
|
||||||
|
if (theta > Mathf.Pi / 2) theta = Mathf.Pi/2;
|
||||||
|
Vector2 turnjump = new Vector2(Mathf.Cos(theta), -Mathf.Sin(theta) - 0.2f) * _lv;
|
||||||
|
velx = turnjump.X;
|
||||||
|
vely = turnjump.Y;
|
||||||
|
} else {
|
||||||
|
// does not have jump point
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
velx += xAxis * AirAcceleration * (float)delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Mathf.Abs(xAxis) < Deadzone) {
|
if (grounded && Mathf.Abs(xAxis) < Deadzone) {
|
||||||
var autostop = -Mathf.Sign(velx) * StoppingDeceleration * (float)delta;
|
var autostop = -Mathf.Sign(velx) * StoppingDeceleration * (float)delta;
|
||||||
if (Mathf.Abs(autostop) > Mathf.Abs(velx)) velx = 0f;
|
if (Mathf.Abs(autostop) > Mathf.Abs(velx)) velx = 0f;
|
||||||
else velx += autostop;
|
else velx += autostop;
|
||||||
@@ -155,7 +209,8 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
|||||||
$"grounded: {grounded}\n" +
|
$"grounded: {grounded}\n" +
|
||||||
$"vely: {vely}\n" +
|
$"vely: {vely}\n" +
|
||||||
$"velx: {velx}\n" +
|
$"velx: {velx}\n" +
|
||||||
$"lv : {_lv:F2} or {_lv/(float)delta:F2}\n";
|
$"lv : {_lv:F2} or {_lv/(float)delta:F2}\n" +
|
||||||
|
$"lcrc : {Predictor.AnyHit(PredictiveCollisions.Location.BottomLeft)}/{Predictor.AnyHit(PredictiveCollisions.Location.BottomRight)}";
|
||||||
// Force = new Vector2(0, forcey);
|
// Force = new Vector2(0, forcey);
|
||||||
Velocity = new Vector2(velx, vely);
|
Velocity = new Vector2(velx, vely);
|
||||||
Velocity *= UnitToPx;
|
Velocity *= UnitToPx;
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public partial class PredictiveCollisions : Node {
|
||||||
|
[Export]
|
||||||
|
public ShapeCast2D BottomLeft { get; set; }
|
||||||
|
[Export]
|
||||||
|
public ShapeCast2D BottomRight { get; set; }
|
||||||
|
[Export]
|
||||||
|
public ShapeCast2D TopLeft { get; set; }
|
||||||
|
[Export]
|
||||||
|
public ShapeCast2D TopRight { get; set; }
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum Location {
|
||||||
|
BottomRight = 0b01,
|
||||||
|
TopRight = 0b11,
|
||||||
|
TopLeft = 0b10,
|
||||||
|
BottomLeft = 0b00
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Godot.Collections.Array Cast(Location location) {
|
||||||
|
GetShapeCast(location).ForceShapecastUpdate();
|
||||||
|
return GetShapeCast(location).CollisionResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AnyHit(Location location)
|
||||||
|
=> (Cast(location)?.Count ?? -1) > 0;
|
||||||
|
|
||||||
|
public Godot.Collections.Array GetLastCastHits(Location location) {
|
||||||
|
return GetShapeCast(location).CollisionResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShapeCast2D GetShapeCast(Location location) => location switch {
|
||||||
|
Location.BottomLeft => BottomLeft,
|
||||||
|
Location.BottomRight => BottomRight,
|
||||||
|
Location.TopLeft => TopLeft,
|
||||||
|
Location.TopRight => TopRight,
|
||||||
|
_ => throw new Exception("Invalid location")
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://de3b068om3gsq
|
||||||
Reference in New Issue
Block a user