using System; using System.Collections.Generic; using System.ComponentModel; using Godot; using Godot.Bridge; using Godot.NativeInterop; [ScriptPath("res://Scripts/Bullets/PenniltonPush.cs")] public partial class PenniltonPush : Node2D { [Export(PropertyHint.None, "")] private Blank one; private float speed; private float cd; private const float max = 180f; public override void _EnterTree() { Blank blank = one; blank.onShot = (Action)Delegate.Combine(blank.onShot, new Action(Push)); } public override void _Process(double delta) { if (cd > 0f) { cd -= Main.deltaTime; } if (speed > -1f) { speed -= Main.deltaTime * 0.05f; } one.Position = new Vector2(Mathf.Clamp(one.Position.X + speed, 0f, 180f), 0f); one.Modulate = one.Modulate.Lerp(Main.colorYellow, Main.deltaTime * 0.05f); } public void Push(Node node) { if (speed < 1f) { one.Modulate = Main.colorWhite; speed += ((cd <= 0f) ? 1f : 0.75f); cd = 5f; } } public override void _ExitTree() { Blank blank = one; blank.onShot = (Action)Delegate.Remove(blank.onShot, new Action(Push)); } }