This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tool | |
extends Node2D | |
@export var show_number: bool = false: | |
set(value): | |
show_number = value | |
notify_property_list_changed() | |
@export var editable_number: bool = false: | |
set(value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name SwayComponent extends Node | |
@export var sway_distance: float = 32 | |
@export var sway_duration: float = 2 | |
@onready var start_y: float = y | |
var y: float: | |
set(value): | |
var parent := get_parent() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tool | |
class_name PDLine2D extends Node2D | |
@export var points: Array[Vector2i] = []: | |
set(value): | |
points = value | |
queue_redraw() | |
@export var color: Color = Color.WHITE: | |
set(value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name SpacePlayer extends RigidBody2D | |
const JUMP_STRENGTH: float = 200 | |
const MOVE_SPEED: float = 200 | |
func _process(_delta: float) -> void: | |
update_input() | |
func update_input() -> void: | |
if !_is_on_ground(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Log AutoLoad | |
extends Node | |
const nil = StringName("<NIL>") | |
func print(message: Variant, m2: Variant = nil, m3: Variant = nil, m4: Variant = nil, m5: Variant = nil, m6: Variant = nil) -> void: | |
print(build_message(message, m2, m3, m4, m5, m6)) | |
func prints(message: Variant, m2: Variant = nil, m3: Variant = nil, m4: Variant = nil, m5: Variant = nil, m6: Variant = nil) -> void: | |
print(build_message(message, m2, m3, m4, m5, m6, " ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class_name ClassUtil | |
static func is_class_name(object: Object, classname: String) -> bool: | |
if object.is_class(classname): | |
return true | |
return is_global_class_name(object, classname) | |
static func is_exact_class_name(object: Object, classname: String) -> bool: | |
if !has_global_class_name(object): | |
return object.get_class() == classname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Godot; | |
public static class NodeExtensions | |
{ | |
public static void RemoveAndFree(this Node node) | |
{ | |
Node parent = node.GetParent(); | |
if (!GodotObject.IsInstanceValid(parent)) | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Benchmark(Action callable, string tag = null) | |
{ | |
var start = Time.GetTicksMsec(); | |
callable(); | |
var duration = Time.GetTicksMsec() - start; | |
if (tag != null) | |
GD.PrintT(tag, duration); | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Godot; | |
using System.Collections.Generic; | |
public partial class SoundManager : Node | |
{ | |
private const int MaxSimultaneousSounds = 32; | |
private const int SuppressSoundTimeMs = 100; | |
private readonly List<AudioStreamPlayer2D> _inactiveAudioPlayers = new(); | |
private readonly List<AudioStreamPlayer2D> _activeAudioPlayers = new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Godot; | |
using System; | |
public partial class Camera : Camera2D | |
{ | |
public enum ShakeStrengthType | |
{ | |
Low, | |
Medium, | |
High |
NewerOlder