Metal666.GodotUtilities.SourceGenerators
0.0.8
Prefix Reserved
dotnet add package Metal666.GodotUtilities.SourceGenerators --version 0.0.8
NuGet\Install-Package Metal666.GodotUtilities.SourceGenerators -Version 0.0.8
<PackageReference Include="Metal666.GodotUtilities.SourceGenerators" Version="0.0.8" />
<PackageVersion Include="Metal666.GodotUtilities.SourceGenerators" Version="0.0.8" />
<PackageReference Include="Metal666.GodotUtilities.SourceGenerators" />
paket add Metal666.GodotUtilities.SourceGenerators --version 0.0.8
#r "nuget: Metal666.GodotUtilities.SourceGenerators, 0.0.8"
#:package Metal666.GodotUtilities.SourceGenerators@0.0.8
#addin nuget:?package=Metal666.GodotUtilities.SourceGenerators&version=0.0.8
#tool nuget:?package=Metal666.GodotUtilities.SourceGenerators&version=0.0.8
GodotUtilities
A set of utilities I use my Godot projects. Available on Nuget: https://www.nuget.org/packages/Metal666.GodotUtilities.
Features
Architecture
Singletons - turn custom Nodes into Singletons by adding the
Singletonattribute.The included source generator will add the
Instanceproperty + a parameterless constructor, where it is set.State (experimental) - use the
Stateattribute to mark static classes as states.The following things will be generated for each private field in the state:
- A public property - use it to modify the field.
- An
On<Property>Changedevent - automatically invoked when the property is set. - An interface with a
On<Property>Changedmethod - implement it on any node and the method will be automatically called when the property is changed.
Invoke
- Use
Invoke.Deferred(Action action, int priority)to queue deferred calls. During idle time they will be executed usingCallable.CallDeferredin the specified (ascending) priority order.
- Use
Debugging
Draw shapes in 3D (similarly to Unity's
Debug.Draw*). Use theDebugging.Draw.Queuemethod or theDebugDrawextension method. Both methods require aDrawObjectto be provided.DrawObjectscontain the instructions and data needed for drawing. The followingDrawObjectsare included:DrawLineDrawSphereDrawQuadDrawShape(draws the suppliedShape3D)
Custom
DrawObjectscan be implemented by extending theDrawMeshInstance3D,DrawImmediateMeshorDrawObjectBaseclasses in theMetal666.GodotUtilities.Debuggingnamespace.
Logging
A modular logging system is available. In order to log a message, call the Log method on the static LogManager class. By default, the message will be processed by 2 loggers:
EditorLogger(activated when running the game from the editor)Prints the message to the Godot console using one of the
GD.PrintRich/GD.PushWarning/GD.PushError(based on the message log level).ConsoleLogger(activated when running the game standalone)Prints the message using
Console.WriteLine.
When logging, parameters such as logLevel, sourceType and indentation can be specified to format the output.
Loggers extend a base LoggerBase class. If you need to implement a custom logging solution you can extend either of the stock loggers, or the base class. Then you can override the available methods and properties to change how the message is processed and output. Finally, set the Loggers value on the LogManager class (overriding the default loggers).
Two additional logging features are available:
Extension methods
A vast selection of extension methods are available for convenient logging. For example, if you call the
LogMessageextension method, the object'sTypewill be automatically passed as thesourceTypeparameter and the log level will be set toLogLevel.Message. All extension methods are contained inside the staticLoggingclass inside theMetal666.GodotUtilities.Extensionsnamespace.LogSourceattributeAttach it to a custom node class, and specify the
Colorproperty (use HTML color names, such asred). When a log arrives with that node's type as thesourceType, the output will be colored using the specified color. TheEditorLoggerwill use the[color]BBCode, while theConsoleLoggerwill convert the color to the closestConsoleColorenum value and set theConsole.ForegroundColor.
Networking
LocalInstanceControllerThis class can be used as an alternative to the "Launch multiple instances" editor function. Use the
Initializemethod to spawn additional game instances. At the moment it is rather basic and doesn't offer much benefit over the editor functionality. I will be extending it with more features in the future.
Data
PairState(experimental) Holds 2 nullable objects of the same type. Provides convenient methods for determining the state of the pair:IsFirst,IsBoth,IsAny, ... etc.
Input
MouseContextThis is a wrapper around
Input.MouseMode. When you call theChangeMouseModemethod, the current mouse mode is added to a stack collection. You can callRevertMouseModeto go backwards through the stack and apply previous mouse modes. This is useful if you have a complex UI setup where different view/overlays/windows require different mouse modes. You can callChangeMouseModewhen a new view opens andRevertMouseModewhen it closes.Additionally, you can use the
PauseMouseModeUpdatesandResumeMouseModeUpdatesmethods to temporarily stop the mouse mode from being applied (the stack will still have values added/removed from it). This can be useful when the game is minimized or the user is alt-tabbed and you don't want to mess with their mouse. To retrieve the "intended" mouse mode use theCurrentMouseModeproperty.The
MouseContextclass can be instantiated, or you can use the staticMouseContext.Globalversion of it. You can set theLogEventsproperty totrueto enable logging.
Extension methods
Collections
ICollection<T>.AddIf(bool condition, T value),ICollection<T>.AddIf(bool condition, params IEnumerable<T> values),bool condition, Func<IEnumerable<T>> values)-ICollection.Addwith a condition.
Controls
Range.ValueF()- retrieve the value of aRangenode as afloat.Range.ValueI()- retrieve the value of aRangenode as a roundedint.Tree.SetColumn(int index, TreeColumnData treeColumnData)- a shortcut toTree.SetColumn*methods. Set all column properties with a single object.Tree.SetColumns(IEnumerable<TreeColumnData> treeColumnDatas)- sets all Tree columns using the above method.
LINQ
IEnumerable<TSource>.If(bool condition, Func<IEnumerable<TSource>, IEnumerable<TSource>> ifBranch, Func<IEnumerable<TSource>, IEnumerable<TSource>>? elseBranch = null),IEnumerable<TSource>.If(Func<IEnumerable<TSource>, bool> condition, Func<IEnumerable<TSource>, IEnumerable<TSource>> ifBranch, Func<IEnumerable<TSource>, IEnumerable<TSource>>? elseBranch = null)- branches inside LINQ chains.
Math
Constants (can be used to specify default property values):
HalfPi.Rad.
Direct shortcuts to
Mathffunctions:float.Lerp(float to, float weight),float.Lerp(float to, double weight),double.Lerp(double to, double weight).float.MoveToward(float to, float delta),float.MoveToward(float to, double delta),double.MoveToward(double to, double delta).float.LerpAngle(float to, float weight),float.LerpAngle(float to, double weight),double.LerpAngle(double to, double weight).int.Abs(),float.Abs(),double.Abs().float.Pow(float power),double.Pow(double power).int.Clamp(int min, int max),float.Clamp(float min, float max),double.Clamp(double min, double max).int.Wrap(int min, int max),float.Wrap(float min, float max),double.Wrap(double min, double max).int.PosMod(int a, int b),float.PosMod(float a, float b),double.PosMod(double a, double b).float.AngleDifference(float to),double.AngleDifference(double to).float.IsZeroApprox(),double.IsZeroApprox().float.IsEqualApprox(float to),double.IsEqualApprox(double to),float.IsEqualApprox(float to, float tolerance),double.IsEqualApprox(double to, double tolerance).int.ToDeg(),float.ToDeg(),double.ToDeg().int.ToRad(),float.ToRad(),double.ToRad().float.RoundToInt(),float.FloorToInt(),float.CeilToInt().double.RoundToInt(),double.FloorToInt(),double.CeilToInt().Vector3.ToQuaternion- callsQuaternion.FromEuler; passtrueas the second parameter if your rotation vector is in degrees.Quaternion.ToBasis- callsBasisconstructor.
Extra utilities:
float.Damp(float to, float decay, double delta),double.Damp(double to, double decay, double delta)- performs framerate-independent lerp smoothing.float.DampAngle(float to, float decay, double delta),double.DampAngle(double to, double decay, double delta)- same as above but for angles.int.Clamp(Vector2I range),float.Clamp(Vector2 range)- clamps using vector components as min/max values.float.ClampRad(float min, float max),double.ClampRad(double min, double max),float.ClampRad(Vector2 range),float.ClampDeg(float min, float max),double.ClampDeg(double min, double max),float.ClampDeg(Vector2 range)-Clampfor angles.int.Wrap360Deg(),float.Wrap360Deg(),double.Wrap360Deg()- usesPosModto ensure the angle is in range [0, 360).float.Wrap360Rad(),double.Wrap360Rad()- usesPosModto ensure the angle is in range [0,Mathf.Tau).int.SignedWrap360Deg(),float.SignedWrap360Deg(),double.SignedWrap360Deg()- usesWrapto ensure the angle is in range [-180, 180).float.SignedWrap360Rad(),double.SignedWrap360Rad()- usesWrapto ensure the angle is in range [-Mathf.Pi,Mathf.Pi).int.Wrap720Deg(),float.Wrap720Deg(),double.Wrap720Deg()- usesPosModto ensure the angle is in range [0, 720).float.Wrap720Rad(),double.Wrap720Rad()- usesPosModto ensure the angle is in range [0,Mathf.Tau * 2).int.SignedWrap720Deg(),float.SignedWrap720Deg(),double.SignedWrap720Deg()- usesWrapto ensure the angle is in range [-360, 360).float.SignedWrap720Rad(),double.SignedWrap720Rad()- usesWrapto ensure the angle is in range [-Mathf.Tau,Mathf.Tau).float.AngleDifferenceAbs(float to),double.AngleDifferenceAbs(double to)- callsAngleDifferencethenAbs.float.DifferenceAbs(float to),double.DifferenceAbs(double to)- callsAbsonvalue - to.Vector2.Get(Vector2.Axis axis),Vector3.Get(Vector3.Axis axis)- gets the vector component specified byaxis.Vector2.Midpoint(Vector2 other),Vector3.Midpoint(Vector3 other)- assuming the vectors represent coordinates: returns a midpoint on the line which connects them.Vector2.VectorTo(Vector2 finalPoint),Vector3.VectorTo(Vector3 finalPoint),Vector2I.VectorTo(Vector2I finalPoint),Vector3I.VectorTo(Vector3I finalPoint)- assuming the vectors represent coordinates: returns a vector to the other point.Vector2.IsEqualApprox(Vector2 vector, float tolerance),Vector3.IsEqualApprox(Vector3 vector, float tolerance)- compare vectors with tolerance.Vector2.CopyWith(float? x = null, float? y = null),Vector2I.CopyWith(int? x = null, int? y = null),Vector3.CopyWith(float? x = null, float? y = null, float? z = null),Vector3I.CopyWith(int? x = null, int? y = null, int? z = null)- returns a copy of the vector with the specified components replaced.Vector2.CopyWith(Vector2.Axis axis, float value),Vector2I.CopyWith(Vector2I.Axis axis, int value),Vector3.CopyWith(Vector3.Axis axis, float value),Vector3I.CopyWith(Vector3I.Axis axis, int value)- returns a copy of the vector with the component, specified by theaxis, replaced.Vector2.Damp(Vector2 to, float weight, double delta),Vector3.Damp(Vector3 to, float weight, double delta)- returns a copy of the vector with withDampperformed on each component of the vector.Vector3.Lerp(Vector3 to, double weight),Vector2.Lerp(Vector2 to, double weight)- callsvector.Lerpwithweightcast tofloat.Vector3.MoveToward(Vector3 to, double weight),Vector2.MoveToward(Vector2 to, double weight)- callsvector.MoveTowardwithdeltacast tofloat.Vector3.RotatedDeg(Vector3 axis, float angle)- callsVector3.Rotatedwithangleconverted to radians.Vector3.FlattenX(),Vector3.FlattenY(),Vector3.FlattenZ(),Vector3I.FlattenX(),Vector3I.FlattenY(),Vector3I.FlattenZ()- converts a 3D vector to a 2D one by removing the specified component.Vector2.AddXComponent(float x = 0),Vector2.AddYComponent(float y = 0),Vector2.AddZComponent(float z = 0),Vector2I.AddXComponent(int x = 0),Vector2I.AddYComponent(int y = 0),Vector2I.AddZComponent(int z = 0)- creates a 3D vector by inserting the specified component into the 2D vector.Vector2.ToDeg(),Vector3.ToDeg(),Vector2.ToRad(),Vector3.ToRad()- returns a copy of the (rotation) vector with all components converted to degrees/radians.Vector2.RoundToInt(),Vector2.FloorToInt(),Vector2.CeilToInt(),Vector3.RoundToInt(),Vector3.FloorToInt(),Vector3.CeilToInt()- returns a copy of the vector with all components rounded/floored/ceiled to integer values.Vector2.UnsignedAngleTo(Vector2 to)- callsvector.AngleTothenAbs.Vector2.Swap(),Vector2I.Swap()- returns a copy of the vector with X and Y components swapped.Vector2.FlipX(),Vector2.FlipY(),Vector2I.FlipX(),Vector2I.FlipY(),Vector3.FlipX(),Vector3.FlipY(),Vector3.FlipZ(),Vector3I.FlipX(),Vector3I.FlipY(),Vector3I.FlipZ()- returns a copy of the vector with the specified component having it's sign changed.Vector3.OverwriteXY(Vector2 with),Vector3.OverwriteXZ(Vector2 with),Vector3.OverwriteYZ(Vector2 with),Vector3I.OverwriteXY(Vector2I with),Vector3I.OverwriteXZ(Vector2I with),Vector3I.OverwriteYZ(Vector2I with)- returns a copy of the vector with the specified components replaced with the components from a 2D vector.Vector2.ElementWiseProduct(Vector2 other),Vector3.ElementWiseProduct(Vector3 other),Vector2I.ElementWiseProduct(Vector2I other),Vector3I.ElementWiseProduct(Vector3I other)- performs element-wise multiplication of the vectors.Vector3.ClampX(int min, int max),Vector3.ClampX(float min, float max),Vector3.ClampX(double min, double max),Vector3.ClampY(int min, int max),Vector3.ClampY(float min, float max),Vector3.ClampY(double min, double max),Vector3.ClampZ(int min, int max),Vector3.ClampZ(float min, float max),Vector3.ClampZ(double min, double max),Vector3I.ClampX(int min, int max),Vector3I.ClampY(int min, int max),Vector3I.ClampZ(int min, int max),Vector2.ClampX(int min, int max),Vector2.ClampX(float min, float max),Vector2.ClampX(double min, double max),Vector2.ClampY(int min, int max),Vector2.ClampY(float min, float max),Vector2.ClampY(double min, double max),Vector2I.ClampX(int min, int max),Vector2I.ClampY(int min, int max)- returns a copy of the vector with the specified component clamped between theminandmaxvalue.Curve.Sample(double offset)- castsoffsettofloat, then callsCurve.Sample.Plane.Get(Vector3.Axis axis, float coordinate1, float coordinate2),Plane.GetX(float y, float z),Plane.GetY(float x, float z),Plane.GetZ(float x, float y)- finds the value of a the missing component of a point on a plane.Basis.CopyWith(Vector3? x = null, Vector3? y = null, Vector3? z = null)- returns a copy of the basis with the specified columns replaced.Vector3.ToBasis(Vector3? up = null)- creates aBasisfrom a normal vector and an optional Up vector.
Physics
CollisionShape2D.Shape<TShape>(),CollisionShape3D.Shape<TShape>()- returnscollider.Shapecast toTShape.Shape2D.GetLength(Vector2.Axis axis = Vector2.Axis.Y),Shape3D.GetLength(Vector3.Axis axis = Vector3.Axis.Y),CollisionShape2D.GetLength(Vector2.Axis axis = Vector2.Axis.Y),CollisionShape3D.GetLength(Vector3.Axis axis = Vector3.Axis.Y)- returns the length of the shape:- For 2D shapes:
SeparationRayShape2D- theLengthproperty.RectangleShape2D- a component of theSizeproperty, specified by theaxis.CircleShape2D- theRadiusproperty.CapsuleShape2D- ifaxisis Y, returns theHeightproperty. Otherwise returns theRadiusproperty.
- For 3D shapes:
SeparationRayShape3D- theLengthproperty.BoxShape3D- a component of theSizeproperty, specified by theaxis.SphereShape3D- theRadiusproperty.CapsuleShape3D,CylinderShape3D- ifaxisis Y, returns theHeightproperty. Otherwise returns theRadiusproperty.
- For 2D shapes:
Shape2D.SetLength(float length, Vector2.Axis axis = Vector2.Axis.Y),Shape3D.SetLength(float length, Vector3.Axis axis = Vector3.Axis.Y),CollisionShape2D.SetLength(float length, Vector2.Axis axis = Vector2.Axis.Y),CollisionShape3D.SetLength(float length, Vector3.Axis axis = Vector3.Axis.Y)- sets the length of the collider; property to set is determined using the process above.World3D.RayCast(PhysicsRayQueryParameters3D parameters),World2D.RayCast(PhysicsRayQueryParameters2D parameters)- performsPhysicsDirectSpaceState3D.IntersectRay/PhysicsDirectSpaceState2D.IntersectRay. Returns a strongly typedRayCastResult3D/RayCastResult2Dobject.Node3D.RayCast(PhysicsRayQueryParameters3D parameters),Node2D.RayCast(PhysicsRayQueryParameters2D parameters)- shortcut:World3D/World2Dis retrieved from theNode3D/Node2D.Node.RayCast3D(PhysicsRayQueryParameters3D parameters),Node.RayCast2D(PhysicsRayQueryParameters2D parameters)- shortcut:World2D/World3Dis retrieved from the node's containingViewport.
Node3D.TryRayCast(PhysicsRayQueryParameters3D parameters, out RayCastResult3D result),Node2D.TryRayCast(PhysicsRayQueryParameters2D parameters, out RayCastResult2D result),Node.TryRayCast3D(PhysicsRayQueryParameters3D parameters, out RayCastResult3D result),Node.TryRayCast2D(PhysicsRayQueryParameters2D parameters, out RayCastResult2D result)- methods implementingTryGetpattern forNode3D.RayCast,Node2D.RayCast,Node.RayCast3DandNode.RayCast2D.World3D.ShapeCast(PhysicsShapeQueryParameters3D parameters, int maxResults = 32),World2D.ShapeCast(PhysicsShapeQueryParameters2D parameters, int maxResults = 32)- performsPhysicsDirectSpaceState3D.IntersectShape/PhysicsDirectSpaceState2D.IntersectShape. Returns a strongly typedShapeCastResult3D/ShapeCastResult2Dobject.Node3D.ShapeCast(PhysicsShapeQueryParameters3D parameters, int maxResults = 32),Node2D.ShapeCast(PhysicsShapeQueryParameters2D parameters, int maxResults = 32)- shortcut:World3D/World2Dis retrieved from theNode3D/Node2D.Node.ShapeCast3D(PhysicsShapeQueryParameters3D parameters, int maxResults = 32),Node.ShapeCast2D(PhysicsShapeQueryParameters2D parameters, int maxResults = 32)- shortcut:World2D/World3Dis retrieved from the node's containingViewport.
Node3D.TryShapeCast(PhysicsShapeQueryParameters3D parameters, out ShapeCastResult3D result, int maxResults = 32),Node2D.TryShapeCast(PhysicsShapeQueryParameters2D parameters, out ShapeCastResult2D result, int maxResults = 32),Node.TryShapeCast3D(PhysicsShapeQueryParameters3D parameters, out ShapeCastResult3D result, int maxResults = 32),Node.TryShapeCast2D(PhysicsShapeQueryParameters2D parameters, out ShapeCastResult2D result, int maxResults = 32)- methods implementingTryGetpattern forNode3D.ShapeCast,Node2D.ShapeCast,Node.ShapeCast3DandNode.ShapeCast2D.World3D.CastMotion(PhysicsShapeQueryParameters3D parameters, out float safeProportion, out float unsafeProportion),World2D.CastMotion(PhysicsShapeQueryParameters2D parameters, out float safeProportion, out float unsafeProportion)- performsPhysicsDirectSpaceState3D.CastMotion/PhysicsDirectSpaceState2D.CastMotion.Node3D.CastMotion(PhysicsShapeQueryParameters3D parameters, out float safeProportion, out float unsafeProportion),Node2D.CastMotion(PhysicsShapeQueryParameters2D parameters, out float safeProportion, out float unsafeProportion)- shortcut:World3D/World2Dis retrieved from theNode3D/Node2D.
Threading
Action.InvokeOnMainThread()(+ 16 overloads) - a shortcut toCallable.From(action).CallDeferred().
Transforms
Node2D.RotateDeg(int angle),Node2D.RotateDeg(float angle),Node2D.RotateDeg(double angle)- callsNode2D.Rotatewithangleconverted to radians.Node3D.RotateDeg(Vector3 axis, int angle),Node3D.RotateDeg(Vector3 axis, float angle),Node3D.RotateDeg(Vector3 axis, double angle)- callsNode3D.Rotatewithangleconverted to radians.Node3D.RotateXDeg(int angle),Node3D.RotateXDeg(float angle),Node3D.RotateXDeg(double angle),Node3D.RotateYDeg(int angle),Node3D.RotateYDeg(float angle),Node3D.RotateYDeg(double angle),Node3D.RotateZDeg(int angle),Node3D.RotateZDeg(float angle),Node3D.RotateZDeg(double angle)- callsNode3D.Rotate*withangleconverted to radians.Node3D.SetXRotation(int angle),Node3D.SetXRotation(float angle),Node3D.SetXRotation(double angle),Node3D.SetYRotation(int angle),Node3D.SetYRotation(float angle),Node3D.SetYRotation(double angle),Node3D.SetZRotation(int angle),Node3D.SetZRotation(float angle),Node3D.SetZRotation(double angle),Node3D.SetXRotationDeg(int angle),Node3D.SetXRotationDeg(float angle),Node3D.SetXRotationDeg(double angle),Node3D.SetYRotationDeg(int angle),Node3D.SetYRotationDeg(float angle),Node3D.SetYRotationDeg(double angle),Node3D.SetZRotationDeg(int angle),Node3D.SetZRotationDeg(float angle),Node3D.SetZRotationDeg(double angle),Node3D.SetXRotationGlobal(int angle),Node3D.SetXRotationGlobal(float angle),Node3D.SetXRotationGlobal(double angle),Node3D.SetYRotationGlobal(int angle),Node3D.SetYRotationGlobal(float angle),Node3D.SetYRotationGlobal(double angle),Node3D.SetZRotationGlobal(int angle),Node3D.SetZRotationGlobal(float angle),Node3D.SetZRotationGlobal(double angle),Node3D.SetXRotationDegGlobal(int angle),Node3D.SetXRotationGlobalDeg(float angle),Node3D.SetXRotationGlobalDeg(double angle),Node3D.SetYRotationGlobalDeg(int angle),Node3D.SetYRotationGlobalDeg(float angle),Node3D.SetYRotationGlobalDeg(double angle),Node3D.SetZRotationGlobalDeg(int angle),Node3D.SetZRotationGlobalDeg(float angle),Node3D.SetZRotationGlobalDeg(double angle),Node3D.SetXPosition(int angle),Node3D.SetXPosition(float angle),Node3D.SetXPosition(double angle),Node3D.SetYPosition(int angle),Node3D.SetYPosition(float angle),Node3D.SetYPosition(double angle),Node3D.SetZPosition(int angle),Node3D.SetZPosition(float angle),Node3D.SetZPosition(double angle),Node3D.SetXPositionGlobal(int angle),Node3D.SetXPositionGlobal(float angle),Node3D.SetXPositionGlobal(double angle),Node3D.SetYPositionGlobal(int angle),Node3D.SetYPositionGlobal(float angle),Node3D.SetYPositionGlobal(double angle),Node3D.SetZPositionGlobal(int angle),Node3D.SetZPositionGlobal(float angle),Node3D.SetZPositionGlobal(double angle),Node2D.SetXPosition(int angle),Node2D.SetXPosition(float angle),Node2D.SetXPosition(double angle),Node2D.SetYPosition(int angle),Node2D.SetYPosition(float angle),Node2D.SetYPosition(double angle),Node2D.SetXPositionGlobal(int angle),Node2D.SetXPositionGlobal(float angle),Node2D.SetXPositionGlobal(double angle),Node2D.SetYPositionGlobal(int angle),Node2D.SetYPositionGlobal(float angle),Node2D.SetYPositionGlobal(double angle)- ... yea... I... I think you can tell what these methods do.
Tree
Node.Unparent()- self-explanatory.SceneTree.ChangeSceneToFileDeferred(string path, Action<Error>? callback = null)- callsSceneTree.ChangeSceneToFilein deferred mode. The return value is passed tocallback(if provided).SceneTree.ChangeSceneToPackedDeferred(PackedScene packedScene, Action<Error>? callback = null)- same as above, but forSceneTree.ChangeSceneToPacked.Node.GetChildren<T>(bool includeInternal = false)- callsnode.GetChildren(includeInternal)then.OfType<T>().Node.GetChildrenOrThrow<T>(bool includeInternal = false)- callsnode.GetChildren(includeInternal)then.Cast<T>().T.AddTo<T>(Node parent, bool removeFromCurrentParent = true)- fluently reparents and returns provided node.Node.FindParentOrNull<T>(),Node.FindParent<T>()- recursively searches for a parent node of specified type.
Visual
Color.WithAlpha(float alpha)- fluent shortcut to theColor(Color, float)constructor.Color.ToRGBVector(), Color.ToRGBAVector()- creates a vector from theR,G,B,Avalues.Color.ToRGBVectorI(), Color.ToRGBAVectorI()- creates a vector from theR8,G8,B8,A8values.Color.ToHSVVector()- creates a vector from the hue, saturation and brightness values.
Additional utilities
- Access
Is.EditororIs.Standaloneto determine if the game was launched from the editor/standalone build.
Installation
Nuget: https://www.nuget.org/packages/Metal666.GodotUtilities.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Metal666.GodotUtilities.SourceGenerators:
| Package | Downloads |
|---|---|
|
Metal666.GodotUtilities
A set of utilities I use in my Godot projects. |
GitHub repositories
This package is not used by any popular GitHub repositories.