alter vatter

This commit is contained in:
2026-07-29 18:50:14 +02:00
parent 59a9516d99
commit 9824b30435
53 changed files with 1054 additions and 69 deletions

View File

@@ -11,7 +11,11 @@ public partial class MeetingControl : Control
[Export]
public MeetingPhysicsBox MeetingPhysicsBox;
public bool InSlot { get; set; }
private MeetingControl otherMeetingControl;
public bool DragIsHandled { get; set; }
public bool ForceDragged { get; set; }
public override void _Ready()
{
@@ -25,34 +29,69 @@ public partial class MeetingControl : Control
SetDragPreview(preview);
Visible = false;
InSlot = false;
DragIsHandled = false;
ForceDragged = false;
return Variant.From(new MeetingControlDragData(this));
}
public override bool _CanDropData(Vector2 atPosition, Variant data)
{
return data.VariantType == Variant.Type.Object
&& data.AsGodotObject() is MeetingControlDragData;
}
public override void _DropData(Vector2 atPosition, Variant data)
{
var meetingData = (MeetingControlDragData)data;
otherMeetingControl = meetingData.MeetingControl;
var otherParent = otherMeetingControl.GetParent();
otherMeetingControl.Reparent(GetParent(), false);
Reparent(otherParent, false);
otherMeetingControl.Visible = true;
otherMeetingControl.DragIsHandled = true;
if (otherMeetingControl.ForceDragged)
{
RespawnPhysicsBoxFromSpawn();
otherMeetingControl.ForceDragged = false;
}
}
public void StartDrag()
{
var preview = CreatePreview();
var data = Variant.From(new MeetingControlDragData(this));
ForceDrag(data, preview);
DragIsHandled = false;
ForceDragged = true;
}
public override void _Notification(int what)
{
// Notfall respawn
if (what == NotificationDragEnd)
{
if (InSlot)
{
if (DragIsHandled)
return;
}
FindParent("Main").AddChild(MeetingPhysicsBox);
MeetingPhysicsBox.Position = GetGlobalMousePosition();
QueueFree();
RespawnPhysicsBoxFromSpawn();
}
}
private void RespawnPhysicsBoxFromSpawn()
{
var main = (Main)FindParent("Main");
main.AddChild(MeetingPhysicsBox);
MeetingPhysicsBox.Position = main.MeetingSpawn.GlobalPosition;
QueueFree();
}
private Control CreatePreview()
{
var copy = Duplicate() as MeetingControl;