41 lines
800 B
C#
41 lines
800 B
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using Godot;
|
|
using Godot.Bridge;
|
|
using Godot.NativeInterop;
|
|
|
|
[ScriptPath("res://Scripts/Envirioment/Chain.cs")]
|
|
public partial class Chain : Node2D
|
|
{
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D[] chains;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D matchPos;
|
|
|
|
[Export(PropertyHint.None, "")]
|
|
private Node2D target;
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
if (matchPos != null)
|
|
{
|
|
CallDeferred("SetPos");
|
|
}
|
|
}
|
|
|
|
private void SetPos()
|
|
{
|
|
base.GlobalPosition = matchPos.GlobalPosition;
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
for (int i = 0; i < chains.Length; i++)
|
|
{
|
|
chains[i].GlobalPosition = base.GlobalPosition.Lerp(target.GlobalPosition, (float)(i + 1) / (float)(chains.Length + 1));
|
|
}
|
|
}
|
|
|
|
}
|