Using Level 3 to do a big art pass and get a lot of systems set up and
cleaned up.

Add Phantom Camera addon with comprehensive 2D/3D camera system
This commit is contained in:
bigmstone committed 2026-10-04 02:21:46 -06:00
1 parent 5ce882b53d
commit 2c6a395938
1122 files changed
+42103 -40

No files matched your search

@@ -0,0 +1,234 @@
using Godot;
using PhantomCamera.Noise;
#nullable enable
namespace PhantomCamera;
public enum InactiveUpdateMode
{
Always,
Never
}
public abstract class PhantomCamera
{
protected readonly GodotObject Node;
public delegate void BecameActiveEventHandler();
public delegate void BecameInactiveEventHandler();
public delegate void FollowTargetChangedEventHandler();
public delegate void DeadZoneChangedEventHandler();
public delegate void TweenStartedEventHandler();
public delegate void IsTweeningEventHandler();
public delegate void TweenCompletedEventHandler();
public event BecameActiveEventHandler? BecameActive;
public event BecameInactiveEventHandler? BecameInactive;
public event FollowTargetChangedEventHandler? FollowTargetChanged;
public event DeadZoneChangedEventHandler? DeadZoneChanged;
public event TweenStartedEventHandler? TweenStarted;
public event IsTweeningEventHandler? IsTweening;
public event TweenCompletedEventHandler? TweenCompleted;
public int Priority
{
get => (int)Node.Call(MethodName.GetPriority);
set => Node.Call(MethodName.SetPriority, value);
}
public bool IsActive => (bool)Node.Call(MethodName.IsActive);
public bool FollowDamping
{
get => (bool)Node.Call(MethodName.GetFollowDamping);
set => Node.Call(MethodName.SetFollowDamping, value);
}
public bool IsFollowing => (bool)Node.Call(PhantomCamera.MethodName.IsFollowing);
public float DeadZoneWidth
{
get => (float)Node.Get(PropertyName.DeadZoneWidth);
set => Node.Set(PropertyName.DeadZoneWidth, value);
}
public float DeadZoneHeight
{
get => (float)Node.Get(PropertyName.DeadZoneHeight);
set => Node.Set(PropertyName.DeadZoneHeight, value);
}
public PhantomCameraTween TweenResource
{
get => new((Resource)Node.Call(MethodName.GetTweenResource));
set => Node.Call(MethodName.SetTweenResource, (GodotObject)value.Resource);
}
public bool TweenSkip
{
get => (bool)Node.Call(MethodName.GetTweenSkip);
set => Node.Call(MethodName.SetTweenSkip, value);
}
public float TweenDuration
{
get => (float)Node.Call(MethodName.GetTweenDuration);
set => Node.Call(MethodName.SetTweenDuration, value);
}
public TransitionType TweenTransition
{
get => (TransitionType)(int)Node.Call(MethodName.GetTweenTransition);
set => Node.Call(MethodName.SetTweenTransition, (int)value);
}
public EaseType TweenEase
{
get => (EaseType)(int)Node.Call(MethodName.GetTweenEase);
set => Node.Call(MethodName.SetTweenEase, (int)value);
}
public bool TweenOnLoad
{
get => (bool)Node.Call(MethodName.GetTweenOnLoad);
set => Node.Call(MethodName.SetTweenOnLoad, value);
}
public InactiveUpdateMode InactiveUpdateMode
{
get => (InactiveUpdateMode)(int)Node.Call(MethodName.GetInactiveUpdateMode);
set => Node.Call(MethodName.SetInactiveUpdateMode, (int)value);
}
public int HostLayers
{
get => (int)Node.Call(MethodName.GetHostLayers);
set => Node.Call(MethodName.SetHostLayers, value);
}
public int NoiseEmitterLayer
{
get => (int)Node.Call(MethodName.GetNoiseEmitterLayer);
set => Node.Call(MethodName.SetNoiseEmitterLayer, value);
}
public void TeleportPosition()
{
Node.Call(MethodName.TeleportPosition);
}
public void SetHostLayersValue(int layer, bool enabled)
{
Node.Call(MethodName.SetHostLayersValue, layer, enabled);
}
protected PhantomCamera(GodotObject phantomCameraNode)
{
Node = phantomCameraNode;
var callableBecameActive = Callable.From(() => BecameActive?.Invoke());
var callableBecameInactive = Callable.From(() => BecameInactive?.Invoke());
var callableFollowTargetChanged = Callable.From(() => FollowTargetChanged?.Invoke());
var callableDeadZoneChanged = Callable.From(() => DeadZoneChanged?.Invoke());
var callableTweenStarted = Callable.From(() => TweenStarted?.Invoke());
var callableIsTweening = Callable.From(() => IsTweening?.Invoke());
var callableTweenCompleted = Callable.From(() => TweenCompleted?.Invoke());
Node.Connect(SignalName.BecameActive, callableBecameActive);
Node.Connect(SignalName.BecameInactive, callableBecameInactive);
Node.Connect(SignalName.FollowTargetChanged, callableFollowTargetChanged);
Node.Connect(SignalName.DeadZoneChanged, callableDeadZoneChanged);
Node.Connect(SignalName.TweenStarted, callableTweenStarted);
Node.Connect(SignalName.IsTweening, callableIsTweening);
Node.Connect(SignalName.TweenCompleted, callableTweenCompleted);
}
public static class MethodName
{
public static readonly StringName GetFollowMode = new("get_follow_mode");
public static readonly StringName IsActive = new("is_active");
public static readonly StringName GetPriority = new("get_priority");
public static readonly StringName SetPriority = new("set_priority");
public static readonly StringName IsFollowing = new("is_following");
public static readonly StringName GetFollowTarget = new("get_follow_target");
public static readonly StringName SetFollowTarget = new("set_follow_target");
public static readonly StringName GetFollowTargets = new("get_follow_targets");
public static readonly StringName SetFollowTargets = new("set_follow_targets");
public static readonly StringName TeleportPosition = new("teleport_position");
public static readonly StringName AppendFollowTargets = new("append_follow_targets");
public static readonly StringName AppendFollowTargetsArray = new("append_follow_targets_array");
public static readonly StringName EraseFollowTargets = new("erase_follow_targets");
public static readonly StringName GetFollowPath = new("get_follow_path");
public static readonly StringName SetFollowPath = new("set_follow_path");
public static readonly StringName GetFollowOffset = new("get_follow_offset");
public static readonly StringName SetFollowOffset = new("set_follow_offset");
public static readonly StringName GetFollowDamping = new("get_follow_damping");
public static readonly StringName SetFollowDamping = new("set_follow_damping");
public static readonly StringName GetFollowDampingValue = new("get_follow_damping_value");
public static readonly StringName SetFollowDampingValue = new("set_follow_damping_value");
public static readonly StringName GetFollowAxisLock = new("get_follow_axis_lock");
public static readonly StringName SetFollowAxisLock = new("set_follow_axis_lock");
public static readonly StringName GetTweenResource = new("get_tween_resource");
public static readonly StringName SetTweenResource = new("set_tween_resource");
public static readonly StringName GetTweenSkip = new("get_tween_skip");
public static readonly StringName SetTweenSkip = new("set_tween_skip");
public static readonly StringName GetTweenDuration = new("get_tween_duration");
public static readonly StringName SetTweenDuration = new("set_tween_duration");
public static readonly StringName GetTweenTransition = new("get_tween_transition");
public static readonly StringName SetTweenTransition = new("set_tween_transition");
public static readonly StringName GetTweenEase = new("get_tween_ease");
public static readonly StringName SetTweenEase = new("set_tween_ease");
public static readonly StringName GetTweenOnLoad = new("get_tween_on_load");
public static readonly StringName SetTweenOnLoad = new("set_tween_on_load");
public static readonly StringName GetInactiveUpdateMode = new("get_inactive_update_mode");
public static readonly StringName SetInactiveUpdateMode = new("set_inactive_update_mode");
public static readonly StringName GetHostLayers = new("get_host_layers");
public static readonly StringName SetHostLayers = new("set_host_layers");
public static readonly StringName SetHostLayersValue = new("set_host_layers_value");
public static readonly StringName GetNoiseEmitterLayer = new("get_noise_emitter_layer");
public static readonly StringName SetNoiseEmitterLayer = new("set_noise_emitter_layer");
public static readonly StringName EmitNoise = new("emit_noise");
}
public static class PropertyName
{
public static readonly StringName DeadZoneWidth = new("dead_zone_width");
public static readonly StringName DeadZoneHeight = new("dead_zone_height");
}
public static class SignalName
{
public static readonly StringName BecameActive = new("became_active");
public static readonly StringName BecameInactive = new("became_inactive");
public static readonly StringName FollowTargetChanged = new("follow_target_changed");
public static readonly StringName DeadZoneChanged = new("dead_zone_changed");
public static readonly StringName DeadZoneReached = new("dead_zone_reached");
public static readonly StringName TweenStarted = new("tween_started");
public static readonly StringName IsTweening = new("is_tweening");
public static readonly StringName TweenCompleted = new("tween_completed");
public static readonly StringName TweenInterrupted = new("tween_interrupted");
public static readonly StringName NoiseEmitted = new("noise_emitted");
}
}
@@ -0,0 +1 @@
uid://d3wh0457i0i3
@@ -0,0 +1,380 @@
using System.Linq;
using Godot;
using Godot.Collections;
using PhantomCamera.Noise;
#nullable enable
namespace PhantomCamera;
public enum FollowMode2D
{
None,
Glued,
Simple,
Group,
Path,
Framed
}
public enum FollowLockAxis2D
{
None,
X,
Y,
Xy
}
public static class PhantomCamera2DExtensions
{
public static PhantomCamera2D AsPhantomCamera2D(this Node2D node2D)
{
return new PhantomCamera2D(node2D);
}
public static PhantomCameraNoiseEmitter2D AsPhantomCameraNoiseEmitter2D(this Node2D node2D)
{
return new PhantomCameraNoiseEmitter2D(node2D);
}
public static PhantomCameraNoise2D AsPhantomCameraNoise2D(this Resource resource)
{
return new PhantomCameraNoise2D(resource);
}
}
public class PhantomCamera2D : PhantomCamera
{
public Node2D Node2D => (Node2D)Node;
public delegate void TweenInterruptedEventHandler(Node2D pCam);
public delegate void DeadZoneReachedEventHandler(Vector2 side);
public delegate void NoiseEmittedEventHandler(Transform2D output);
public event TweenInterruptedEventHandler? TweenInterrupted;
public event DeadZoneReachedEventHandler? DeadZoneReached;
public event NoiseEmittedEventHandler? NoiseEmitted;
public Node2D FollowTarget
{
get => (Node2D)Node2D.Call(PhantomCamera.MethodName.GetFollowTarget);
set => Node2D.Call(PhantomCamera.MethodName.SetFollowTarget, value);
}
public Node2D[] FollowTargets
{
get => Node2D.Call(PhantomCamera.MethodName.GetFollowTargets).AsGodotArray<Node2D>().ToArray();
set => Node2D.Call(PhantomCamera.MethodName.SetFollowTargets, new Array<Node2D>(value));
}
public void AppendFollowTargets(Node2D target) => Node2D.Call(PhantomCamera.MethodName.AppendFollowTargets, target);
public void AppendFollowTargetsArray(Node2D[] targets) => Node2D.Call(PhantomCamera.MethodName.AppendFollowTargetsArray, targets);
public void EraseFollowTargets(Node2D target) => Node2D.Call(PhantomCamera.MethodName.EraseFollowTargets, target);
public FollowMode2D FollowMode => (FollowMode2D)(int)Node.Call(PhantomCamera.MethodName.GetFollowMode);
public Path2D FollowPath
{
get => (Path2D)Node2D.Call(PhantomCamera.MethodName.GetFollowPath);
set => Node2D.Call(PhantomCamera.MethodName.SetFollowPath, value);
}
public Vector2 FollowOffset
{
get => (Vector2)Node2D.Call(PhantomCamera.MethodName.GetFollowOffset);
set => Node2D.Call(PhantomCamera.MethodName.SetFollowOffset, value);
}
public Vector2 FollowDampingValue
{
get => (Vector2)Node2D.Call(PhantomCamera.MethodName.GetFollowDampingValue);
set => Node2D.Call(PhantomCamera.MethodName.SetFollowDampingValue, value);
}
public FollowLockAxis2D FollowAxisLock
{
get => (FollowLockAxis2D)(int)Node2D.Call(PhantomCamera.MethodName.GetFollowAxisLock);
set => Node2D.Call(PhantomCamera.MethodName.SetFollowAxisLock, (int)value);
}
public Vector2 Zoom
{
get => (Vector2)Node2D.Call(MethodName.GetZoom);
set => Node2D.Call(MethodName.SetZoom, value);
}
public bool SnapToPixel
{
get => (bool)Node2D.Call(MethodName.GetSnapToPixel);
set => Node2D.Call(MethodName.SetSnapToPixel, value);
}
public bool RotateWithTarget
{
get => (bool)Node2D.Call(MethodName.GetRotateWithTarget);
set => Node2D.Call(MethodName.SetRotateWithTarget, value);
}
public float RotationOffset
{
get => (float)Node2D.Call(MethodName.GetRotationOffset);
set => Node2D.Call(MethodName.SetRotationOffset, value);
}
public bool RotationDamping
{
get => (bool)Node2D.Call(MethodName.GetRotationDamping);
set => Node2D.Call(MethodName.SetRotationDamping, value);
}
public float RotationDampingValue
{
get => (float)Node2D.Call(MethodName.GetRotationDampingValue);
set => Node2D.Call(MethodName.SetRotationDampingValue, value);
}
public int LimitLeft
{
get => (int)Node2D.Call(MethodName.GetLimitLeft);
set => Node2D.Call(MethodName.SetLimitLeft, value);
}
public int LimitTop
{
get => (int)Node2D.Call(MethodName.GetLimitTop);
set => Node2D.Call(MethodName.SetLimitTop, value);
}
public int LimitRight
{
get => (int)Node2D.Call(MethodName.GetLimitRight);
set => Node2D.Call(MethodName.SetLimitRight, value);
}
public int LimitBottom
{
get => (int)Node2D.Call(MethodName.GetLimitBottom);
set => Node2D.Call(MethodName.SetLimitBottom, value);
}
public Vector4I LimitMargin
{
get => (Vector4I)Node2D.Call(MethodName.GetLimitMargin);
set => Node2D.Call(MethodName.SetLimitMargin, value);
}
public bool AutoZoom
{
get => (bool)Node2D.Call(MethodName.GetAutoZoom);
set => Node2D.Call(MethodName.SetAutoZoom, value);
}
public float AutoZoomMin
{
get => (float)Node2D.Call(MethodName.GetAutoZoomMin);
set => Node2D.Call(MethodName.SetAutoZoomMin, value);
}
public float AutoZoomMax
{
get => (float)Node2D.Call(MethodName.GetAutoZoomMax);
set => Node2D.Call(MethodName.SetAutoZoomMax, value);
}
public Vector4 AutoZoomMargin
{
get => (Vector4)Node2D.Call(MethodName.GetAutoZoomMargin);
set => Node2D.Call(MethodName.SetAutoZoomMargin, value);
}
public bool Lookahead
{
get => (bool)Node2D.Call(MethodName.GetLookahead);
set => Node2D.Call(MethodName.SetLookahead, value);
}
public Vector2 LookaheadTime
{
get => (Vector2)Node2D.Call(MethodName.GetLookaheadTime);
set => Node2D.Call(MethodName.SetLookaheadTime, value);
}
public float LookaheadAcceleration
{
get => (float)Node2D.Call(MethodName.GetLookaheadAcceleration);
set => Node2D.Call(MethodName.SetLookaheadAcceleration, value);
}
public float LookaheadDeceleration
{
get => (float)Node2D.Call(MethodName.GetLookaheadDeceleration);
set => Node2D.Call(MethodName.SetLookaheadDeceleration, value);
}
public bool LookaheadMax
{
get => (bool)Node2D.Call(MethodName.GetLookaheadMax);
set => Node2D.Call(MethodName.SetLookaheadMax, value);
}
public Vector2 LookaheadMaxValue
{
get => (Vector2)Node2D.Call(MethodName.GetLookaheadMaxValue);
set => Node2D.Call(MethodName.SetLookaheadMaxValue, value);
}
public bool DrawLimits
{
get => (bool)Node2D.Get(PropertyName.DrawLimits);
set => Node2D.Set(PropertyName.DrawLimits, value);
}
public PhantomCameraNoise2D Noise
{
get => new((Resource)Node2D.Call(MethodName.GetNoise));
set => Node2D.Call(MethodName.SetNoise, (GodotObject)value.Resource);
}
public void EmitNoise(Transform2D transform) => Node2D.Call(PhantomCamera.MethodName.EmitNoise, transform);
public NodePath LimitTarget
{
get => (NodePath)Node2D.Call(MethodName.GetLimitTarget);
set => Node2D.Call(MethodName.SetLimitTarget, value);
}
public PhantomCamera2D(GodotObject phantomCameraNode) : base(phantomCameraNode)
{
var callableTweenInterrupted = Callable.From<Node2D>(pCam => TweenInterrupted?.Invoke(pCam));
var callableDeadZoneReached = Callable.From((Vector2 side) => DeadZoneReached?.Invoke(side));
var callableNoiseEmitted = Callable.From((Transform2D output) => NoiseEmitted?.Invoke(output));
Node2D.Connect(SignalName.TweenInterrupted, callableTweenInterrupted);
Node2D.Connect(SignalName.DeadZoneReached, callableDeadZoneReached);
Node2D.Connect(SignalName.NoiseEmitted, callableNoiseEmitted);
}
public void SetLimitTarget(TileMapLayer tileMapLayer)
{
Node2D.Call(MethodName.SetLimitTarget, tileMapLayer.GetPath());
}
public void SetLimitTarget(CollisionShape2D shape2D)
{
Node2D.Call(MethodName.SetLimitTarget, shape2D.GetPath());
}
public LimitTargetQueryResult? GetLimitTarget()
{
var result = (NodePath)Node2D.Call(MethodName.GetLimitTarget);
return result.IsEmpty ? null : new LimitTargetQueryResult(Node2D.GetNode(result));
}
public void SetLimit(Side side, int value)
{
Node2D.Call(MethodName.SetLimit, (int)side, value);
}
public int GetLimit(Side side)
{
return (int)Node2D.Call(MethodName.GetLimit, (int)side);
}
public new static class MethodName
{
public static readonly StringName GetZoom = new("get_zoom");
public static readonly StringName SetZoom = new("set_zoom");
public static readonly StringName GetSnapToPixel = new("get_snap_to_pixel");
public static readonly StringName SetSnapToPixel = new("set_snap_to_pixel");
public static readonly StringName GetRotateWithTarget = new("get_rotate_with_target");
public static readonly StringName SetRotateWithTarget = new("set_rotate_with_target");
public static readonly StringName GetRotationOffset = new("get_rotation_offset");
public static readonly StringName SetRotationOffset = new("set_rotation_offset");
public static readonly StringName GetRotationDamping = new("get_rotation_damping");
public static readonly StringName SetRotationDamping = new("set_rotation_damping");
public static readonly StringName GetRotationDampingValue = new("get_rotation_damping_value");
public static readonly StringName SetRotationDampingValue = new("set_rotation_damping_value");
public static readonly StringName GetLookahead = new("get_lookahead");
public static readonly StringName SetLookahead = new("set_lookahead");
public static readonly StringName GetLookaheadTime = new("get_lookahead_time");
public static readonly StringName SetLookaheadTime = new("set_lookahead_time");
public static readonly StringName GetLookaheadAcceleration = new("get_lookahead_acceleration");
public static readonly StringName SetLookaheadAcceleration = new("set_lookahead_acceleration");
public static readonly StringName GetLookaheadDeceleration = new("get_lookahead_deceleration");
public static readonly StringName SetLookaheadDeceleration = new("set_lookahead_deceleration");
public static readonly StringName GetLookaheadMax = new("get_lookahead_max");
public static readonly StringName SetLookaheadMax = new("set_lookahead_max");
public static readonly StringName GetLookaheadMaxValue = new("get_lookahead_max_value");
public static readonly StringName SetLookaheadMaxValue = new("set_lookahead_max_value");
public static readonly StringName GetLimit = new("get_limit");
public static readonly StringName SetLimit = new("set_limit");
public static readonly StringName GetLimitLeft = new("get_limit_left");
public static readonly StringName SetLimitLeft = new("set_limit_left");
public static readonly StringName GetLimitTop = new("get_limit_top");
public static readonly StringName SetLimitTop = new("set_limit_top");
public static readonly StringName GetLimitRight = new("get_limit_right");
public static readonly StringName SetLimitRight = new("set_limit_right");
public static readonly StringName GetLimitBottom = new("get_limit_bottom");
public static readonly StringName SetLimitBottom = new("set_limit_bottom");
public static readonly StringName GetLimitTarget = new("get_limit_target");
public static readonly StringName SetLimitTarget = new("set_limit_target");
public static readonly StringName GetLimitMargin = new("get_limit_margin");
public static readonly StringName SetLimitMargin = new("set_limit_margin");
public static readonly StringName GetAutoZoom = new("get_auto_zoom");
public static readonly StringName SetAutoZoom = new("set_auto_zoom");
public static readonly StringName GetAutoZoomMin = new("get_auto_zoom_min");
public static readonly StringName SetAutoZoomMin = new("set_auto_zoom_min");
public static readonly StringName GetAutoZoomMax = new("get_auto_zoom_max");
public static readonly StringName SetAutoZoomMax = new("set_auto_zoom_max");
public static readonly StringName GetAutoZoomMargin = new("get_auto_zoom_margin");
public static readonly StringName SetAutoZoomMargin = new("set_auto_zoom_margin");
public static readonly StringName GetNoise = new("get_noise");
public static readonly StringName SetNoise = new("set_noise");
}
public new static class PropertyName
{
public static readonly StringName DrawLimits = new("draw_limits");
}
}
public class LimitTargetQueryResult(GodotObject godotObject)
{
public bool IsTileMapLayer => godotObject.IsClass("TileMapLayer");
public bool IsCollisionShape2D => godotObject.IsClass("CollisionShape2D");
public TileMapLayer? AsTileMapLayer()
{
return IsTileMapLayer ? (TileMapLayer)godotObject : null;
}
public CollisionShape2D? AsCollisionShape2D()
{
return IsCollisionShape2D ? (CollisionShape2D)godotObject : null;
}
}
@@ -0,0 +1 @@
uid://c38e5qhsf3fk3
@@ -0,0 +1,483 @@
using System.Linq;
using Godot;
using Environment = Godot.Environment;
using Godot.Collections;
using PhantomCamera.Noise;
#nullable enable
namespace PhantomCamera;
public enum LookAtMode
{
None,
Mimic,
Simple,
Group
}
public enum FollowMode3D
{
None,
Glued,
Simple,
Group,
Path,
Framed,
ThirdPerson
}
public enum FollowLockAxis3D
{
None,
X,
Y,
Z,
XY,
XZ,
YZ,
XYZ
}
public static class PhantomCamera3DExtensions
{
public static PhantomCamera3D AsPhantomCamera3D(this Node3D node3D)
{
return new PhantomCamera3D(node3D);
}
public static PhantomCameraNoiseEmitter3D AsPhantomCameraNoiseEmitter3D(this Node3D node3D)
{
return new PhantomCameraNoiseEmitter3D(node3D);
}
public static PhantomCameraNoise3D AsPhantomCameraNoise3D(this Resource resource)
{
return new PhantomCameraNoise3D(resource);
}
public static Camera3DResource AsCamera3DResource(this Resource resource)
{
return new Camera3DResource(resource);
}
public static Vector3 GetThirdPersonRotation(this PhantomCamera3D pCam3D) =>
(Vector3)pCam3D.Node3D.Call(PhantomCamera3D.MethodName.GetThirdPersonRotation);
public static void SetThirdPersonRotation(this PhantomCamera3D pCam3D, Vector3 rotation) =>
pCam3D.Node3D.Call(PhantomCamera3D.MethodName.SetThirdPersonRotation, rotation);
public static Vector3 GetThirdPersonRotationDegrees(this PhantomCamera3D pCam3D) =>
(Vector3)pCam3D.Node3D.Call(PhantomCamera3D.MethodName.GetThirdPersonRotationDegrees);
public static void SetThirdPersonRotationDegrees(this PhantomCamera3D pCam3D, Vector3 rotation) =>
pCam3D.Node3D.Call(PhantomCamera3D.MethodName.SetThirdPersonRotationDegrees, rotation);
public static Quaternion GetThirdPersonQuaternion(this PhantomCamera3D pCam3D) =>
(Quaternion)pCam3D.Node3D.Call(PhantomCamera3D.MethodName.GetThirdPersonQuaternion);
public static void SetThirdPersonQuaternion(this PhantomCamera3D pCam3D, Quaternion quaternion) =>
pCam3D.Node3D.Call(PhantomCamera3D.MethodName.SetThirdPersonQuaternion, quaternion);
}
public class PhantomCamera3D : PhantomCamera
{
public Node3D Node3D => (Node3D)Node;
public delegate void LookAtTargetChangedEventHandler();
public delegate void DeadZoneReachedEventHandler();
public delegate void Camera3DResourceChangedEventHandler();
public delegate void Camera3DResourcePropertyChangedEventHandler(StringName property, Variant value);
public delegate void TweenInterruptedEventHandler(Node3D pCam);
public delegate void NoiseEmittedEventHandler(Transform3D output);
public event LookAtTargetChangedEventHandler? LookAtTargetChanged;
public event DeadZoneReachedEventHandler? DeadZoneReached;
public event Camera3DResourceChangedEventHandler? Camera3DResourceChanged;
public event Camera3DResourcePropertyChangedEventHandler? Camera3DResourcePropertyChanged;
public event TweenInterruptedEventHandler? TweenInterrupted;
public event NoiseEmittedEventHandler? NoiseEmitted;
public Node3D FollowTarget
{
get => (Node3D)Node3D.Call(PhantomCamera.MethodName.GetFollowTarget);
set => Node3D.Call(PhantomCamera.MethodName.SetFollowTarget, value);
}
public Node3D[] FollowTargets
{
get => Node3D.Call(PhantomCamera.MethodName.GetFollowTargets).AsGodotArray<Node3D>().ToArray();
set => Node3D.Call(PhantomCamera.MethodName.SetFollowTargets, new Array<Node3D>(value));
}
public void AppendFollowTarget(Node3D target) => Node3D.Call(PhantomCamera.MethodName.AppendFollowTargets, target);
public void AppendFollowTargetArray(Node3D[] targets) => Node3D.Call(PhantomCamera.MethodName.AppendFollowTargetsArray, targets);
public void EraseFollowTarget(Node3D target) => Node3D.Call(PhantomCamera.MethodName.EraseFollowTargets, target);
public FollowMode3D FollowMode => (FollowMode3D)(int)Node.Call(PhantomCamera.MethodName.GetFollowMode);
public Path3D FollowPath
{
get => (Path3D)Node3D.Call(PhantomCamera.MethodName.GetFollowPath);
set => Node3D.Call(PhantomCamera.MethodName.SetFollowPath, value);
}
public Vector3 FollowOffset
{
get => (Vector3)Node3D.Call(PhantomCamera.MethodName.GetFollowOffset);
set => Node3D.Call(PhantomCamera.MethodName.SetFollowOffset, value);
}
public Vector3 FollowDampingValue
{
get => (Vector3)Node3D.Call(PhantomCamera.MethodName.GetFollowDampingValue);
set => Node3D.Call(PhantomCamera.MethodName.SetFollowDampingValue, value);
}
public FollowLockAxis3D FollowAxisLock
{
get => (FollowLockAxis3D)(int)Node3D.Call(PhantomCamera.MethodName.GetFollowAxisLock);
set => Node3D.Call(PhantomCamera.MethodName.SetFollowAxisLock, (int)value);
}
public LookAtMode LookAtMode => (LookAtMode)(int)Node3D.Call(MethodName.GetLookAtMode);
public Camera3DResource Camera3DResource
{
get => new((Resource)Node3D.Call(MethodName.GetCamera3DResource));
set => Node3D.Call(MethodName.SetCamera3DResource, value.Resource);
}
public float SpringLength
{
get => (float)Node3D.Call(MethodName.GetSpringLength);
set => Node3D.Call(MethodName.SetSpringLength, value);
}
public float VerticalRotationOffset
{
get => (float)Node3D.Call(MethodName.GetVerticalRotationOffset);
set => Node3D.Call(MethodName.SetVerticalRotationOffset, value);
}
public float HorizontalRotationOffset
{
get => (float)Node3D.Call(MethodName.GetHorizontalRotationOffset);
set => Node3D.Call(MethodName.SetHorizontalRotationOffset, value);
}
public float FollowDistance
{
get => (float)Node3D.Call(MethodName.GetFollowDistance);
set => Node3D.Call(MethodName.SetFollowDistance, value);
}
public bool AutoFollowDistance
{
get => (bool)Node3D.Call(MethodName.GetAutoFollowDistance);
set => Node3D.Call(MethodName.SetAutoFollowDistance, value);
}
public float AutoFollowDistanceMin
{
get => (float)Node3D.Call(MethodName.GetAutoFollowDistanceMin);
set => Node3D.Call(MethodName.SetAutoFollowDistanceMin, value);
}
public float AutoFollowDistanceMax
{
get => (float)Node3D.Call(MethodName.GetAutoFollowDistanceMax);
set => Node3D.Call(MethodName.SetAutoFollowDistanceMax, value);
}
public float AutoFollowDistanceDivisor
{
get => (float)Node3D.Call(MethodName.GetAutoFollowDistanceDivisor);
set => Node3D.Call(MethodName.SetAutoFollowDistanceDivisor, value);
}
public Node3D LookAtTarget
{
get => (Node3D)Node3D.Call(MethodName.GetLookAtTarget);
set => Node3D.Call(MethodName.SetLookAtTarget, value);
}
public Node3D[] LookAtTargets
{
get => Node3D.Call(MethodName.GetLookAtTargets).AsGodotArray<Node3D>().ToArray();
set => Node3D.Call(MethodName.SetLookAtTargets, new Array<Node3D>(value));
}
public bool IsLooking => (bool)Node3D.Call(MethodName.IsLooking);
public int CollisionMask
{
get => (int)Node3D.Call(MethodName.GetCollisionMask);
set => Node3D.Call(MethodName.SetCollisionMask, value);
}
public void SetCollisionMaskValue(int maskLayer, bool enable) =>
Node3D.Call(MethodName.SetCollisionMaskValue, maskLayer, enable);
public Shape3D Shape
{
get => (Shape3D)Node3D.Call(MethodName.GetShape);
set => Node3D.Call(MethodName.SetShape, value);
}
public float Margin
{
get => (float)Node3D.Call(MethodName.GetMargin);
set => Node3D.Call(MethodName.SetMargin, value);
}
public Vector3 LookAtOffset
{
get => (Vector3)Node3D.Call(MethodName.GetLookAtOffset);
set => Node3D.Call(MethodName.SetLookAtOffset, value);
}
public bool LookAtDamping
{
get => (bool)Node3D.Call(MethodName.GetLookAtDamping);
set => Node3D.Call(MethodName.SetLookAtDamping, value);
}
public float LookAtDampingValue
{
get => (float)Node3D.Call(MethodName.GetLookAtDampingValue);
set => Node3D.Call(MethodName.SetLookAtDampingValue, value);
}
public Vector3 Up
{
get => (Vector3)Node3D.Call(MethodName.GetUp);
set => Node3D.Call(MethodName.SetUp, value);
}
public Node3D UpTarget
{
get => (Node3D)Node3D.Call(MethodName.GetUpTarget);
set => Node3D.Call(MethodName.SetUpTarget, value);
}
public int KeepAspect
{
get => (int)Node3D.Call(MethodName.GetKeepAspect);
set => Node3D.Call(MethodName.SetKeepAspect, value);
}
public int CullMask
{
get => (int)Node3D.Call(MethodName.GetCullMask);
set => Node3D.Call(MethodName.SetCullMask, value);
}
public float HOffset
{
get => (float)Node3D.Call(MethodName.GetHOffset);
set => Node3D.Call(MethodName.SetHOffset, value);
}
public float VOffset
{
get => (float)Node3D.Call(MethodName.GetVOffset);
set => Node3D.Call(MethodName.SetVOffset, value);
}
public ProjectionType Projection
{
get => (ProjectionType)(int)Node3D.Call(MethodName.GetProjection);
set => Node3D.Call(MethodName.SetProjection, (int)value);
}
public float Fov
{
get => (float)Node3D.Call(MethodName.GetFov);
set => Node3D.Call(MethodName.SetFov, value);
}
public float Size
{
get => (float)Node3D.Call(MethodName.GetSize);
set => Node3D.Call(MethodName.SetSize, value);
}
public Vector2 FrustumOffset
{
get => (Vector2)Node3D.Call(MethodName.GetFrustumOffset);
set => Node3D.Call(MethodName.SetFrustumOffset, value);
}
public float Far
{
get => (float)Node3D.Call(MethodName.GetFar);
set => Node3D.Call(MethodName.SetFar, value);
}
public float Near
{
get => (float)Node3D.Call(MethodName.GetNear);
set => Node3D.Call(MethodName.SetNear, value);
}
public Environment Environment
{
get => (Environment)Node3D.Call(MethodName.GetEnvironment);
set => Node3D.Call(MethodName.SetEnvironment, value);
}
public CameraAttributes Attributes
{
get => (CameraAttributes)Node3D.Call(MethodName.GetAttributes);
set => Node3D.Call(MethodName.SetAttributes, value);
}
public PhantomCameraNoise3D Noise
{
get => new((Resource)Node3D.Call(MethodName.GetNoise));
set => Node3D.Call(MethodName.SetNoise, (GodotObject)value.Resource);
}
public void EmitNoise(Transform3D transform) => Node3D.Call(PhantomCamera.MethodName.EmitNoise, transform);
public PhantomCamera3D(GodotObject phantomCamera3DNode) : base(phantomCamera3DNode)
{
var callableLookAtTargetChanged = Callable.From(() => LookAtTargetChanged?.Invoke());
var callableDeadZoneReached = Callable.From(() => DeadZoneReached?.Invoke());
var callableCamera3DResourceChanged = Callable.From(() => Camera3DResourceChanged?.Invoke());
var callableCamera3DResourcePropertyChanged = Callable.From((StringName property, Variant value) =>
Camera3DResourcePropertyChanged?.Invoke(property, value));
var callableTweenInterrupted = Callable.From<Node3D>(pCam => TweenInterrupted?.Invoke(pCam));
var callableNoiseEmitted = Callable.From((Transform3D output) => NoiseEmitted?.Invoke(output));
Node3D.Connect(SignalName.LookAtTargetChanged, callableLookAtTargetChanged);
Node3D.Connect(PhantomCamera.SignalName.DeadZoneReached, callableDeadZoneReached);
Node3D.Connect(SignalName.Camera3DResourceChanged, callableCamera3DResourceChanged);
Node3D.Connect(SignalName.Camera3DResourcePropertyChanged, callableCamera3DResourcePropertyChanged);
Node3D.Connect(PhantomCamera.SignalName.TweenInterrupted, callableTweenInterrupted);
Node3D.Connect(PhantomCamera.SignalName.NoiseEmitted, callableNoiseEmitted);
}
public new static class MethodName
{
public static readonly StringName GetLookAtMode = new("get_look_at_mode");
public static readonly StringName GetCamera3DResource = new("get_camera_3d_resource");
public static readonly StringName SetCamera3DResource = new("set_camera_3d_resource");
public static readonly StringName GetThirdPersonRotation = new("get_third_person_rotation");
public static readonly StringName SetThirdPersonRotation = new("set_third_person_rotation");
public static readonly StringName GetThirdPersonRotationDegrees = new("get_third_person_rotation_degrees");
public static readonly StringName SetThirdPersonRotationDegrees = new("set_third_person_rotation_degrees");
public static readonly StringName GetThirdPersonQuaternion = new("get_third_person_quaternion");
public static readonly StringName SetThirdPersonQuaternion = new("set_third_person_quaternion");
public static readonly StringName GetVerticalRotationOffset = new("get_vertical_rotation_offset");
public static readonly StringName SetVerticalRotationOffset = new("set_vertical_rotation_offset");
public static readonly StringName GetHorizontalRotationOffset = new("get_horizontal_rotation_offset");
public static readonly StringName SetHorizontalRotationOffset = new("set_horizontal_rotation_offset");
public static readonly StringName GetSpringLength = new("get_spring_length");
public static readonly StringName SetSpringLength = new("set_spring_length");
public static readonly StringName GetFollowDistance = new("get_follow_distance");
public static readonly StringName SetFollowDistance = new("set_follow_distance");
public static readonly StringName GetAutoFollowDistance = new("get_auto_follow_distance");
public static readonly StringName SetAutoFollowDistance = new("set_auto_follow_distance");
public static readonly StringName GetAutoFollowDistanceMin = new("get_auto_follow_distance_min");
public static readonly StringName SetAutoFollowDistanceMin = new("set_auto_follow_distance_min");
public static readonly StringName GetAutoFollowDistanceMax = new("get_auto_follow_distance_max");
public static readonly StringName SetAutoFollowDistanceMax = new("set_auto_follow_distance_max");
public static readonly StringName GetAutoFollowDistanceDivisor = new("get_auto_follow_distance_divisor");
public static readonly StringName SetAutoFollowDistanceDivisor = new("set_auto_follow_distance_divisor");
public static readonly StringName GetLookAtTarget = new("get_look_at_target");
public static readonly StringName SetLookAtTarget = new("set_look_at_target");
public static readonly StringName GetLookAtTargets = new("get_look_at_targets");
public static readonly StringName SetLookAtTargets = new("set_look_at_targets");
public static readonly StringName IsLooking = new("is_looking");
public static readonly StringName GetUp = new("get_up");
public static readonly StringName SetUp = new("set_up");
public static readonly StringName GetUpTarget = new("get_up_target");
public static readonly StringName SetUpTarget = new("set_up_target");
public static readonly StringName GetCollisionMask = new("get_collision_mask");
public static readonly StringName SetCollisionMask = new("set_collision_mask");
public static readonly StringName SetCollisionMaskValue = new("set_collision_mask_value");
public static readonly StringName GetShape = new("get_shape");
public static readonly StringName SetShape = new("set_shape");
public static readonly StringName GetMargin = new("get_margin");
public static readonly StringName SetMargin = new("set_margin");
public static readonly StringName GetLookAtOffset = new("get_look_at_offset");
public static readonly StringName SetLookAtOffset = new("set_look_at_offset");
public static readonly StringName GetLookAtDamping = new("get_look_at_damping");
public static readonly StringName SetLookAtDamping = new("set_look_at_damping");
public static readonly StringName GetLookAtDampingValue = new("get_look_at_damping_value");
public static readonly StringName SetLookAtDampingValue = new("set_look_at_damping_value");
public static readonly StringName GetKeepAspect = new("get_keep_aspect");
public static readonly StringName SetKeepAspect = new("set_keep_aspect");
public static readonly StringName GetCullMask = new("get_cull_mask");
public static readonly StringName SetCullMask = new("set_cull_mask");
public static readonly StringName GetHOffset = new("get_h_offset");
public static readonly StringName SetHOffset = new("set_h_offset");
public static readonly StringName GetVOffset = new("get_v_offset");
public static readonly StringName SetVOffset = new("set_v_offset");
public static readonly StringName GetProjection = new("get_projection");
public static readonly StringName SetProjection = new("set_projection");
public static readonly StringName GetFov = new("get_fov");
public static readonly StringName SetFov = new("set_fov");
public static readonly StringName GetSize = new("get_size");
public static readonly StringName SetSize = new("set_size");
public static readonly StringName GetFrustumOffset = new("get_frustum_offset");
public static readonly StringName SetFrustumOffset = new("set_frustum_offset");
public static readonly StringName GetFar = new("get_far");
public static readonly StringName SetFar = new("set_far");
public static readonly StringName GetNear = new("get_near");
public static readonly StringName SetNear = new("set_near");
public static readonly StringName GetEnvironment = new("get_environment");
public static readonly StringName SetEnvironment = new("set_environment");
public static readonly StringName GetAttributes = new("get_attributes");
public static readonly StringName SetAttributes = new("set_attributes");
public static readonly StringName GetNoise = new("get_noise");
public static readonly StringName SetNoise = new("set_noise");
}
public new static class SignalName
{
public static readonly StringName LookAtTargetChanged = new("look_at_target_changed");
public static readonly StringName Camera3DResourceChanged = new("camera_3d_resource_changed");
public static readonly StringName Camera3DResourcePropertyChanged = new("camera_3d_resource_property_changed");
}
}
@@ -0,0 +1 @@
uid://bx3g7jxtwhi04
@@ -0,0 +1,83 @@
using Godot;
namespace PhantomCamera.Noise;
public class PhantomCameraNoiseEmitter2D(GodotObject node)
{
public Node2D Node2D = (Node2D)node;
public PhantomCameraNoise2D Noise
{
get => new((Resource)Node2D.Call(MethodName.GetNoise));
set => Node2D.Call(MethodName.SetNoise, (GodotObject)value.Resource);
}
public bool Continuous
{
get => (bool)Node2D.Call(MethodName.GetContinuous);
set => Node2D.Call(MethodName.SetContinuous, value);
}
public float GrowthTime
{
get => (float)Node2D.Call(MethodName.GetGrowthTime);
set => Node2D.Call(MethodName.SetGrowthTime, value);
}
public float Duration
{
get => (float)Node2D.Call(MethodName.GetDuration);
set => Node2D.Call(MethodName.SetDuration, value);
}
public float DecayTime
{
get => (float)Node2D.Call(MethodName.GetDecayTime);
set => Node2D.Call(MethodName.SetDecayTime, value);
}
public int NoiseEmitterLayer
{
get => (int)Node2D.Call(MethodName.GetNoiseEmitterLayer);
set => Node2D.Call(MethodName.SetNoiseEmitterLayer, value);
}
public void SetNoiseEmitterLayerValue(int layer, bool value) =>
Node2D.Call(MethodName.SetNoiseEmitterLayerValue, layer, value);
public void Emit() => Node2D.Call(MethodName.Emit);
public bool IsEmitting() => (bool)Node2D.Call(MethodName.IsEmitting);
public void Stop() => Node2D.Call(MethodName.Stop);
public void Toggle() => Node2D.Call(MethodName.Toggle);
public static class MethodName
{
public static readonly StringName GetNoise = new("get_noise");
public static readonly StringName SetNoise = new("set_noise");
public static readonly StringName GetContinuous = new("get_continuous");
public static readonly StringName SetContinuous = new("set_continuous");
public static readonly StringName GetGrowthTime = new("get_growth_time");
public static readonly StringName SetGrowthTime = new("set_growth_time");
public static readonly StringName GetDuration = new("get_duration");
public static readonly StringName SetDuration = new("set_duration");
public static readonly StringName GetDecayTime = new("get_decay_time");
public static readonly StringName SetDecayTime = new("set_decay_time");
public static readonly StringName GetNoiseEmitterLayer = new("get_noise_emitter_layer");
public static readonly StringName SetNoiseEmitterLayer = new("set_noise_emitter_layer");
public static readonly StringName SetNoiseEmitterLayerValue = new("set_noise_emitter_layer_value");
public static readonly StringName Emit = new("emit");
public static readonly StringName IsEmitting = new("is_emitting");
public static readonly StringName Stop = new("stop");
public static readonly StringName Toggle = new("toggle");
}
}
@@ -0,0 +1 @@
uid://btom8l3wlkn2j
@@ -0,0 +1,83 @@
using Godot;
namespace PhantomCamera.Noise;
public class PhantomCameraNoiseEmitter3D(GodotObject node)
{
public Node3D Node3D = (Node3D)node;
public PhantomCameraNoise3D Noise
{
get => new((Resource)Node3D.Call(MethodName.GetNoise));
set => Node3D.Call(MethodName.SetNoise, (GodotObject)value.Resource);
}
public bool Continuous
{
get => (bool)Node3D.Call(MethodName.GetContinuous);
set => Node3D.Call(MethodName.SetContinuous, value);
}
public float GrowthTime
{
get => (float)Node3D.Call(MethodName.GetGrowthTime);
set => Node3D.Call(MethodName.SetGrowthTime, value);
}
public float Duration
{
get => (float)Node3D.Call(MethodName.GetDuration);
set => Node3D.Call(MethodName.SetDuration, value);
}
public float DecayTime
{
get => (float)Node3D.Call(MethodName.GetDecayTime);
set => Node3D.Call(MethodName.SetDecayTime, value);
}
public int NoiseEmitterLayer
{
get => (int)Node3D.Call(MethodName.GetNoiseEmitterLayer);
set => Node3D.Call(MethodName.SetNoiseEmitterLayer, value);
}
public void SetNoiseEmitterLayerValue(int layer, bool value) =>
Node3D.Call(MethodName.SetNoiseEmitterLayerValue, layer, value);
public void Emit() => Node3D.Call(MethodName.Emit);
public bool IsEmitting() => (bool)Node3D.Call(MethodName.IsEmitting);
public void Stop() => Node3D.Call(MethodName.Stop);
public void Toggle() => Node3D.Call(MethodName.Toggle);
public static class MethodName
{
public static readonly StringName GetNoise = new("get_noise");
public static readonly StringName SetNoise = new("set_noise");
public static readonly StringName GetContinuous = new("get_continuous");
public static readonly StringName SetContinuous = new("set_continuous");
public static readonly StringName GetGrowthTime = new("get_growth_time");
public static readonly StringName SetGrowthTime = new("set_growth_time");
public static readonly StringName GetDuration = new("get_duration");
public static readonly StringName SetDuration = new("set_duration");
public static readonly StringName GetDecayTime = new("get_decay_time");
public static readonly StringName SetDecayTime = new("set_decay_time");
public static readonly StringName GetNoiseEmitterLayer = new("get_noise_emitter_layer");
public static readonly StringName SetNoiseEmitterLayer = new("set_noise_emitter_layer");
public static readonly StringName SetNoiseEmitterLayerValue = new("set_noise_emitter_layer_value");
public static readonly StringName Emit = new("emit");
public static readonly StringName IsEmitting = new("is_emitting");
public static readonly StringName Stop = new("stop");
public static readonly StringName Toggle = new("toggle");
}
}
@@ -0,0 +1 @@
uid://buvda14filkjx
@@ -0,0 +1,20 @@
using Godot;
namespace PhantomCamera.TweenDirector;
public class PhantomCameraTweenDirector(GodotObject node)
{
public Node Node = (Node)node;
public TweenDirectorResource TweenDirector
{
get => new((Resource)Node.Call(MethodName.GetTweenDirector));
set => Node.Call(MethodName.SetTweenDirector, (GodotObject)value.Resource);
}
public static class MethodName
{
public static readonly StringName SetTweenDirector = new("set_tween_director");
public static readonly StringName GetTweenDirector = new("get_tween_director");
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1 @@
uid://bhexx6mj1xv3q
File diff suppressed because it is too large. Load diff
@@ -0,0 +1 @@
uid://csjccrhj5wnx7
@@ -0,0 +1,29 @@
@tool
extends RefCounted
#region Constants
#const PhantomCameraHost: Script = preload("res://addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd")
const CAMERA_2D_NODE_NAME: StringName = "Camera2D"
const CAMERA_3D_NODE_NAME: StringName = "Camera3D"
const PCAM_HOST_NODE_NAME: StringName = "PhantomCameraHost"
const PCAM_MANAGER_NODE_NAME: String = "PhantomCameraManager" # TODO - Convert to StringName once https://github.com/godotengine/godot/pull/72702 is merged
const PCAM_2D_NODE_NAME: StringName = "PhantomCamera2D"
const PCAM_3D_NODE_NAME: StringName = "PhantomCamera3D"
const PCAM_HOST: StringName = "phantom_camera_host"
const COLOR_2D: Color = Color("8DA5F3")
const COLOR_3D: Color = Color("FC7F7F")
const COLOR_PCAM: Color = Color("3AB99A")
const COLOR_PCAM_33: Color = Color("3ab99a33")
const PCAM_HOST_COLOR: Color = Color("E0E0E0")
#endregion
#region Group Names
const PCAM_GROUP_NAME: StringName = "phantom_camera_group"
const PCAM_HOST_GROUP_NAME: StringName = "phantom_camera_host_group"
#endregion
@@ -0,0 +1 @@
uid://dn74j5b5hdxu
@@ -0,0 +1,264 @@
@tool
@icon("res://addons/phantom_camera/icons/phantom_camera_noise_emitter_2d.svg")
class_name PhantomCameraNoiseEmitter2D
extends Node2D
## Emits positional and rotational noise to active [PhantomCamera2D]s and its corresponding [Camera2D].
##
## Is a node meant to apply positional and rotational noise, also referred to as shake, to the [Camera2D].
## It is designed for use cases such as when hitting or when being hit, earthquakes or to add a
## bit of slight movement to the camera to make it feel less static.
## The emitter can affect multiple [PhantomCamera2D] in a given scene based on which [member noise_emitter_layer]
## are enabled by calling its [method emit] function. At least one corresponding layer has to be
## set on the [PhantomCamera2D] and the emitter node.
const _constants = preload("res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_constants.gd")
#region Exported Proerpties
## The [PhantomCameraNoise2D] resource that defines the noise pattern.
@export var noise: PhantomCameraNoise2D = null:
set = set_noise,
get = get_noise
## If true, previews the noise in the editor - can be seen in the viewfinder.
@export var preview: bool = false:
set(value):
preview = value
_play = value
get:
return preview
## If true, repeats the noise indefinitely once started. Otherwise, it will only be triggered once. [br]
@export var continuous: bool = false:
set = set_continuous,
get = get_continuous
## Determines how long the noise should take to reach full [member intensity] once started.[br]
## The value is set in [b]seconds[/b].
@export_exp_easing("positive_only", "suffix: s") var growth_time: float = 0:
set = set_growth_time,
get = get_growth_time
## Sets the duration for the camera noise if [member continuous] is set to [b]false[/b].[br][br]
## The value is set in [b]seconds[/b].
@export_range(0, 10, 0.001, "or_greater", "suffix: s") var duration: float = 1.0:
set = set_duration,
get = get_duration
## Determines how long the noise should take to come to a full stop.[br]
## The value is set in [b]seconds[/b].
@export_exp_easing("attenuation", "positive_only", "suffix: s") var decay_time: float = 0:
set = set_decay_time,
get = get_decay_time
## Enabled layers will affect [PhantomCamera2D] nodes with at least one corresponding layer enabled.[br]
## Enabling multiple corresponding layers on the same [PhantomCamera2D] causes no additional effect.
@export_flags_2d_render var noise_emitter_layer: int = 1:
set = set_noise_emitter_layer,
get = get_noise_emitter_layer
#endregion
#region Private Variables
var _play: bool = false:
set(value):
_play = value
if value:
_elasped_play_time = 0
_decay_countdown = 0
_play = true
_should_grow = true
_start_duration_countdown = false
_should_decay = false
else:
_should_decay = true
if noise.randomize_noise_seed:
noise.noise_seed = randi() & 1000
else:
noise.reset_noise_time()
get:
return _play
var _start_duration_countdown: bool = false
var _decay_countdown: float = 0
var _should_grow: bool = false
var _should_decay: bool = false
var _elasped_play_time: float = 0
var _noise_output: Transform2D = Transform2D()
# NOTE - Temp solution until Godot has better plugin autoload recognition out-of-the-box.
var _phantom_camera_manager: Node
#endregion
#region Private Functions
func _get_configuration_warnings() -> PackedStringArray:
if noise == null:
return ["Noise resource is required in order to trigger emitter."]
else:
return []
func _validate_property(property) -> void:
if property.name == "duration" and continuous:
property.usage = PROPERTY_USAGE_NO_EDITOR
func _enter_tree() -> void:
_phantom_camera_manager = get_tree().root.get_node(_constants.PCAM_MANAGER_NODE_NAME)
func _process(delta: float) -> void:
if not _play and not _should_decay: return
if noise == null:
printerr("Noise resource missing in ", name)
_play = false
return
_elasped_play_time += delta
if _should_grow:
noise.set_trauma(minf(_elasped_play_time / growth_time, 1))
if _elasped_play_time >= growth_time:
_should_grow = false
_start_duration_countdown = true
noise.set_trauma(1)
else:
noise.set_trauma(1)
if not continuous:
if _start_duration_countdown:
if _elasped_play_time >= duration + growth_time:
_should_decay = true
_start_duration_countdown = false
if _should_decay:
_decay_countdown += delta
noise.set_trauma(maxf(1 - (_decay_countdown / decay_time), 0))
if _decay_countdown >= decay_time:
noise.set_trauma(0)
_play = false
preview = false
_should_decay = false
_elasped_play_time = 0
_decay_countdown = 0
_noise_output = noise.get_noise_transform(delta)
_phantom_camera_manager.noise_2d_emitted.emit(_noise_output, noise_emitter_layer)
func _set_layer(current_layers: int, layer_number: int, value: bool) -> int:
var mask: int = current_layers
# From https://github.com/godotengine/godot/blob/51991e20143a39e9ef0107163eaf283ca0a761ea/scene/3d/camera_3d.cpp#L638
if layer_number < 1 or layer_number > 20:
printerr("Layer must be between 1 and 20.")
else:
if value:
mask |= 1 << (layer_number - 1)
else:
mask &= ~(1 << (layer_number - 1))
return mask
#endregion
#region Public Functions
## Emits noise to the [PhantomCamera2D]s that has at least one matching layers.
func emit() -> void:
if _play: _play = false
_play = true
## Returns the state for the emitter. If true, the emitter is currently emitting.
func is_emitting() -> bool:
return _play
## Stops the emitter from emitting noise.
func stop(should_decay: bool = true) -> void:
if should_decay:
_should_decay = true
else:
_play = false
## Toggles the emitter on and off.
func toggle() -> void:
_play = !_play
#endregion
#region Setter & Getter Functions
## Sets the [member noise] resource.
func set_noise(value: PhantomCameraNoise2D) -> void:
noise = value
update_configuration_warnings()
## Returns the [member noise] resource.
func get_noise() -> PhantomCameraNoise2D:
return noise
## Sets the [member continous] value.
func set_continuous(value: bool) -> void:
continuous = value
notify_property_list_changed()
## Gets the [member continous] value.
func get_continuous() -> bool:
return continuous
## Sets the [member growth_time] value.
func set_growth_time(value: float) -> void:
growth_time = value
## Returns the [member growth_time] value.
func get_growth_time() -> float:
return growth_time
## Sets the [member duration] value.
func set_duration(value: float) -> void:
duration = value
if duration == 0:
duration = 0.001
## Returns the [member duration] value.
func get_duration() -> float:
return duration
## Sets the [member decay_time] value.
func set_decay_time(value: float) -> void:
decay_time = value
## Returns the [member decay_time] value.
func get_decay_time() -> float:
return decay_time
## Sets the [member noise_emitter_layer] value.
func set_noise_emitter_layer(value: int) -> void:
noise_emitter_layer = value
## Enables or disables a given layer of [member noise_emitter_layer].
func set_noise_emitter_value(value: int, enabled: bool) -> void:
noise_emitter_layer = _set_layer(noise_emitter_layer, value, enabled)
## Returns the [member noise_emitter_layer] value.
func get_noise_emitter_layer() -> int:
return noise_emitter_layer
#endregion
@@ -0,0 +1 @@
uid://bhd4nuiu23e7l
@@ -0,0 +1,265 @@
@tool
@icon("res://addons/phantom_camera/icons/phantom_camera_noise_emitter_3d.svg")
class_name PhantomCameraNoiseEmitter3D
extends Node3D
## Emits positional and rotational noise to active [PhantomCamera3D]s and its corresponding [Camera3D].
##
## Is a node meant to apply positional and rotational noise, also referred to as shake, to the [Camera3D].
## It is designed for use cases such as when hitting or when being hit, earthquakes or to add a
## bit of slight movement to the camera to make it feel less static.
## The emitter can affect multiple [PhantomCamera3D] in a given scene based on which [member noise_emitter_layer]
## are enabled by calling its [method emit] function. At least one corresponding layer has to be
## set on the [PhantomCamera3D] and the emitter node.
const _constants = preload("res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_constants.gd")
#region Exported Properties
## The [PhantomCameraNoise3D] resource that defines the noise pattern.
@export var noise: PhantomCameraNoise3D = null:
set = set_noise,
get = get_noise
## If true, previews the noise in the Viewfinder.
@export var preview: bool = false:
set(value):
preview = value
_play = value
get:
return preview
## If true, repeats the noise indefinitely once started.Otherwise, it will only be triggered once. [br]
## [b]Note:[/b] This will always be enabled if the resource is assigned the the [PhantomCamera3D]'s
## [member PhantomCamera3D.noise] property.
@export var continuous: bool = false:
set = set_continuous,
get = get_continuous
## Determines how long the noise should take to reach full [member intensity] once started.[br]
## The value is set in [b]seconds[/b].
@export_exp_easing("positive_only", "suffix: s") var growth_time: float = 0:
set = set_growth_time,
get = get_growth_time
## Sets the duration for the camera noise if [member loop] is set to false.[br]
## If the duration is [param 0] then [member continous] becomes enabled.[br]
## The value is set in [b]seconds[/b].
@export_range(0, 10, 0.001, "or_greater", "suffix: s") var duration: float = 1.0:
set = set_duration,
get = get_duration
## Determines how long the noise should take to come to a full stop.[br]
## The value is set in [b]seconds[/b].
@export_exp_easing("attenuation", "positive_only", "suffix: s") var decay_time: float = 0:
set = set_decay_time,
get = get_decay_time
## Enabled layers will affect [PhantomCamera3D] nodes with at least one corresponding layer enabled.[br]
## Enabling multiple corresponding layers on the same [PhantomCamera3D] causes no additional effect.
@export_flags_3d_render var noise_emitter_layer: int = 1:
set = set_noise_emitter_layer,
get = get_noise_emitter_layer
#endregion
#region Private Variables
var _play: bool = false:
set(value):
_play = value
if value:
_elasped_play_time = 0
_decay_countdown = 0
_play = true
_should_grow = true
_start_duration_countdown = false
_should_decay = false
else:
_should_decay = true
if noise.randomize_noise_seed:
noise.noise_seed = randi() & 1000
else:
noise.reset_noise_time()
get:
return _play
var _start_duration_countdown: bool = false
var _decay_countdown: float = 0
var _should_grow: bool = false
var _should_decay: bool = false
var _elasped_play_time: float = 0
var _noise_output: Transform3D = Transform3D()
# NOTE - Temp solution until Godot has better plugin autoload recognition out-of-the-box.
var _phantom_camera_manager: Node
#endregion
#region Private Functions
func _get_configuration_warnings() -> PackedStringArray:
if noise == null:
return ["Noise resource is required in order to trigger emitter."]
else:
return []
func _validate_property(property) -> void:
if property.name == "duration" and continuous:
property.usage = PROPERTY_USAGE_NO_EDITOR
func _enter_tree() -> void:
_phantom_camera_manager = get_tree().root.get_node(_constants.PCAM_MANAGER_NODE_NAME)
func _process(delta: float) -> void:
if not _play and not _should_decay: return
if noise == null:
printerr("Noise resource missing in ", name)
_play = false
return
_elasped_play_time += delta
if _should_grow:
noise.set_trauma(minf(_elasped_play_time / growth_time, 1))
if _elasped_play_time >= growth_time:
_should_grow = false
_start_duration_countdown = true
noise.set_trauma(1)
if not continuous:
if _start_duration_countdown:
if _elasped_play_time >= duration + growth_time:
_should_decay = true
_start_duration_countdown = false
if _should_decay:
_decay_countdown += delta
noise.set_trauma(maxf(1 - (_decay_countdown / decay_time), 0))
if _decay_countdown >= decay_time:
noise.set_trauma(0)
_play = false
preview = false
_should_decay = false
_elasped_play_time = 0
_decay_countdown = 0
_noise_output = noise.get_noise_transform(delta)
_phantom_camera_manager.noise_3d_emitted.emit(_noise_output, noise_emitter_layer)
func _set_layer(current_layers: int, layer_number: int, value: bool) -> int:
var mask: int = current_layers
# From https://github.com/godotengine/godot/blob/51991e20143a39e9ef0107163eaf283ca0a761ea/scene/3d/camera_3d.cpp#L638
if layer_number < 1 or layer_number > 20:
printerr("Layer must be between 1 and 20.")
else:
if value:
mask |= 1 << (layer_number - 1)
else:
mask &= ~(1 << (layer_number - 1))
return mask
#endregion
#region Public Functions
## Emits noise to the [PhantomCamera3D]s that has at least one matching layers.
func emit() -> void:
if _play: _play = false
_play = true
## Returns the state for the emitter. If true, the emitter is currently emitting.
func is_emitting() -> bool:
return _play
## Stops the emitter from emitting noise.
func stop(should_decay: bool = true) -> void:
if should_decay:
_should_decay = true
else:
_play = false
## Toggles the emitter on and off.[br]
func toggle() -> void:
_play = !_play
#endregion
#region Setter & Getter Functions
## Sets the [member noise] resource.
func set_noise(value: PhantomCameraNoise3D) -> void:
noise = value
update_configuration_warnings()
## Returns the [member noise] resource.
func get_noise() -> PhantomCameraNoise3D:
return noise
## Sets the [member continous] value.
func set_continuous(value: bool) -> void:
continuous = value
notify_property_list_changed()
## Gets the [member continous] value.
func get_continuous() -> bool:
return continuous
## Sets the [member growth_time] value.
func set_growth_time(value: float) -> void:
growth_time = value
## Returns the [member growth_time] value.
func get_growth_time() -> float:
return growth_time
## Sets the [member duration] value.
func set_duration(value: float) -> void:
duration = value
if duration == 0:
duration = 0.001
## Returns the [member duration] value.
func get_duration() -> float:
return duration
## Sets the [member decay_time] value.
func set_decay_time(value: float) -> void:
decay_time = value
## Returns the [member decay_time] value.
func get_decay_time() -> float:
return decay_time
## Sets the [member noise_emitter_layer] value.
func set_noise_emitter_layer(value: int) -> void:
noise_emitter_layer = value
## Enables or disables a given layer of [member noise_emitter_layer].
func set_noise_emitter_value(value: int, enabled: bool) -> void:
noise_emitter_layer = _set_layer(noise_emitter_layer, value, enabled)
## Returns the [member noise_emitter_layer] value.
func get_noise_emitter_layer() -> int:
return noise_emitter_layer
#endregion
@@ -0,0 +1 @@
uid://ccmiitq0sdh7j
@@ -0,0 +1,60 @@
@tool
@icon("res://addons/phantom_camera/icons/phantom_camera_tween_director.svg")
class_name PhantomCameraTweenDirector
extends Node
## Conditionally overrides [PhantomCameraTween] of [param PhantomCameras].
##
## Using the [TweenDirectorResource], this node allows for custom tweens between specific [param PhantomCameras] in a scene.[br][br]
## Whenever a tween between two [param PhantomCameras] occurs, this node can override the [PhantomCameraTween] applied to the newly active
## [param PhantomCamera] if an instance on both the [b]From[/b] and [b]To[/b] lists match the previously and newly active [param PhantomCamera] respectively.
#region Constants
const _constants = preload("res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_constants.gd")
#endregion
#region Public Variables
## Override the [PhantomCameraTween] between specific [param PhantomCameras].
@export var tween_director: Array[TweenDirectorResource] = []:
set = set_tween_director,
get = get_tween_director
#endregion
#region Private Variables
var _pcam_manager: Node = null
#endregion
#region Private Functions
func _enter_tree() -> void:
_pcam_manager = Engine.get_singleton(_constants.PCAM_MANAGER_NODE_NAME)
if is_instance_valid(_pcam_manager):
_pcam_manager.pcam_tween_director_added(self)
func _exit_tree() -> void:
_pcam_manager.pcam_tween_director_removed(self)
#endregion
#region Public Functions
## Sets the [member tween_director] value.
func set_tween_director(value: Array[TweenDirectorResource]) -> void:
tween_director = value
## Returns the [member tween_director] value.
func get_tween_director() -> Array[TweenDirectorResource]:
return tween_director
#endregion
@@ -0,0 +1 @@
uid://ioirwmfgd4yu