2025-12-21 18:56:48 +00:00
|
|
|
using Godot;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2026-05-22 12:25:02 +00:00
|
|
|
using Rokojori.Extensions;
|
2025-12-21 18:56:48 +00:00
|
|
|
namespace Rokojori
|
|
|
|
|
{
|
|
|
|
|
public class PhysicsRayCast
|
|
|
|
|
{
|
NPC Behaviors: movement/fight classes, Smoother Quaternion fix, ThirdPersonCamera lock blend split
- New Behavior/Movements: MoveOnPath, GoToPointBehavior, FleeBehavior, HidingSpot/HideAtSpotBehavior, NavigationBehaviorMovement; BehaviorMovement gained Flee/GetGlobalPosition, CharacterBodyBehaviorMovement moved from raw duration floats to Smoothing-resource exports.
- New Behavior/Fight: FightManager/FightSlot/JoinFight/LeaveFight/IsEngagedInFight/HasAttackPermission/IsAllyAttacking/FightState, mirroring the CameraManager/CameraSlot singleton+slot pattern.
- New Conditions/IsValueBelowThreshold (generic against NumberValue).
- Fixed Smoother.SmoothWithCoefficient(Quaternion...) not renormalizing after Slerp (crashed live after sustained use) and a MathX.SmoothingCoefficient argument-order bug in all three SmoothForDuration overloads.
- ThirdPersonCamera: lock engage/release now blends yaw/pitch (fixing a hard isLocked snap), fixed a yaw-staleness regression from that change, then split the single lock blend into independent focus (lockEngageSmoothing/lockReleaseSmoothing) and orientation (lockOrientationEngageSmoothing/lockOrientationReleaseSmoothing) blends.
- Includes carried-over uncommitted state from the earlier NPC/AI/Behaviours task (Behavior/StateMachine, Receptor/ReceptorBase/ReceptorControl, related Icons) that hadn't been committed yet.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 07:51:12 +00:00
|
|
|
public static CollisionData GetFirst( PhysicsBody3D body, Vector3 from, Vector3 to )
|
2025-12-21 18:56:48 +00:00
|
|
|
{
|
|
|
|
|
var world = body.GetWorld3D();
|
|
|
|
|
var rayParameters = new PhysicsRayQueryParameters3D
|
|
|
|
|
{
|
|
|
|
|
From = from,
|
|
|
|
|
To = to,
|
|
|
|
|
CollisionMask = body.CollisionMask,
|
|
|
|
|
CollideWithAreas = false,
|
|
|
|
|
CollideWithBodies = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rayParameters.Exclude = [ body.GetRid() ];
|
|
|
|
|
var hits = CollisionData.MultiRayCast( world, rayParameters, 1 );
|
|
|
|
|
|
|
|
|
|
return hits.Count == 0 ? null : hits[ 0 ];
|
|
|
|
|
}
|
|
|
|
|
|
NPC Behaviors: movement/fight classes, Smoother Quaternion fix, ThirdPersonCamera lock blend split
- New Behavior/Movements: MoveOnPath, GoToPointBehavior, FleeBehavior, HidingSpot/HideAtSpotBehavior, NavigationBehaviorMovement; BehaviorMovement gained Flee/GetGlobalPosition, CharacterBodyBehaviorMovement moved from raw duration floats to Smoothing-resource exports.
- New Behavior/Fight: FightManager/FightSlot/JoinFight/LeaveFight/IsEngagedInFight/HasAttackPermission/IsAllyAttacking/FightState, mirroring the CameraManager/CameraSlot singleton+slot pattern.
- New Conditions/IsValueBelowThreshold (generic against NumberValue).
- Fixed Smoother.SmoothWithCoefficient(Quaternion...) not renormalizing after Slerp (crashed live after sustained use) and a MathX.SmoothingCoefficient argument-order bug in all three SmoothForDuration overloads.
- ThirdPersonCamera: lock engage/release now blends yaw/pitch (fixing a hard isLocked snap), fixed a yaw-staleness regression from that change, then split the single lock blend into independent focus (lockEngageSmoothing/lockReleaseSmoothing) and orientation (lockOrientationEngageSmoothing/lockOrientationReleaseSmoothing) blends.
- Includes carried-over uncommitted state from the earlier NPC/AI/Behaviours task (Behavior/StateMachine, Receptor/ReceptorBase/ReceptorControl, related Icons) that hadn't been committed yet.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 07:51:12 +00:00
|
|
|
public static CollisionData GetFirst( PhysicsBody3D body, Vector3 direction )
|
2025-12-21 18:56:48 +00:00
|
|
|
{
|
|
|
|
|
var from = body.GlobalPosition;
|
|
|
|
|
var to = from + direction;
|
|
|
|
|
|
|
|
|
|
return GetFirst( body, from, to );
|
|
|
|
|
}
|
|
|
|
|
|
NPC Behaviors: movement/fight classes, Smoother Quaternion fix, ThirdPersonCamera lock blend split
- New Behavior/Movements: MoveOnPath, GoToPointBehavior, FleeBehavior, HidingSpot/HideAtSpotBehavior, NavigationBehaviorMovement; BehaviorMovement gained Flee/GetGlobalPosition, CharacterBodyBehaviorMovement moved from raw duration floats to Smoothing-resource exports.
- New Behavior/Fight: FightManager/FightSlot/JoinFight/LeaveFight/IsEngagedInFight/HasAttackPermission/IsAllyAttacking/FightState, mirroring the CameraManager/CameraSlot singleton+slot pattern.
- New Conditions/IsValueBelowThreshold (generic against NumberValue).
- Fixed Smoother.SmoothWithCoefficient(Quaternion...) not renormalizing after Slerp (crashed live after sustained use) and a MathX.SmoothingCoefficient argument-order bug in all three SmoothForDuration overloads.
- ThirdPersonCamera: lock engage/release now blends yaw/pitch (fixing a hard isLocked snap), fixed a yaw-staleness regression from that change, then split the single lock blend into independent focus (lockEngageSmoothing/lockReleaseSmoothing) and orientation (lockOrientationEngageSmoothing/lockOrientationReleaseSmoothing) blends.
- Includes carried-over uncommitted state from the earlier NPC/AI/Behaviours task (Behavior/StateMachine, Receptor/ReceptorBase/ReceptorControl, related Icons) that hadn't been committed yet.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 07:51:12 +00:00
|
|
|
public static int GetAll( List<CollisionData> outputCollisionData, PhysicsBody3D body, Vector3 from, Vector3 to )
|
2025-12-21 18:56:48 +00:00
|
|
|
{
|
|
|
|
|
var world = body.GetWorld3D();
|
|
|
|
|
var rayParameters = new PhysicsRayQueryParameters3D
|
|
|
|
|
{
|
|
|
|
|
From = from,
|
|
|
|
|
To = to,
|
|
|
|
|
CollisionMask = body.CollisionMask,
|
|
|
|
|
CollideWithAreas = false,
|
|
|
|
|
CollideWithBodies = true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rayParameters.Exclude = [ body.GetRid() ];
|
|
|
|
|
return CollisionData.MultiRayCast( world, rayParameters, outputCollisionData );
|
|
|
|
|
}
|
|
|
|
|
|
NPC Behaviors: movement/fight classes, Smoother Quaternion fix, ThirdPersonCamera lock blend split
- New Behavior/Movements: MoveOnPath, GoToPointBehavior, FleeBehavior, HidingSpot/HideAtSpotBehavior, NavigationBehaviorMovement; BehaviorMovement gained Flee/GetGlobalPosition, CharacterBodyBehaviorMovement moved from raw duration floats to Smoothing-resource exports.
- New Behavior/Fight: FightManager/FightSlot/JoinFight/LeaveFight/IsEngagedInFight/HasAttackPermission/IsAllyAttacking/FightState, mirroring the CameraManager/CameraSlot singleton+slot pattern.
- New Conditions/IsValueBelowThreshold (generic against NumberValue).
- Fixed Smoother.SmoothWithCoefficient(Quaternion...) not renormalizing after Slerp (crashed live after sustained use) and a MathX.SmoothingCoefficient argument-order bug in all three SmoothForDuration overloads.
- ThirdPersonCamera: lock engage/release now blends yaw/pitch (fixing a hard isLocked snap), fixed a yaw-staleness regression from that change, then split the single lock blend into independent focus (lockEngageSmoothing/lockReleaseSmoothing) and orientation (lockOrientationEngageSmoothing/lockOrientationReleaseSmoothing) blends.
- Includes carried-over uncommitted state from the earlier NPC/AI/Behaviours task (Behavior/StateMachine, Receptor/ReceptorBase/ReceptorControl, related Icons) that hadn't been committed yet.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 07:51:12 +00:00
|
|
|
public static int GetAll( List<CollisionData> outputCollisionData, PhysicsBody3D body, Vector3 direction )
|
2025-12-21 18:56:48 +00:00
|
|
|
{
|
|
|
|
|
var from = body.GlobalPosition;
|
|
|
|
|
var to = from + direction;
|
|
|
|
|
|
|
|
|
|
return GetAll( outputCollisionData, body, from, to );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|