Friday, 15 August 2025 23:08:08
This commit is contained in:
82
Gameplay/Tchotchke.cs
Normal file
82
Gameplay/Tchotchke.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Tchotchke : StaticBody2D
|
||||
{
|
||||
public bool _hovered = false, _held = false;
|
||||
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
if (_held)
|
||||
{
|
||||
GlobalPosition = GetGlobalMousePosition();
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
Transform2D newTransform = GlobalTransform;
|
||||
newTransform.Origin = Position;
|
||||
GlobalTransform = newTransform;
|
||||
Drop();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_hovered)
|
||||
{
|
||||
if (Input.IsActionJustPressed("left_click"))
|
||||
{
|
||||
Hold();
|
||||
}
|
||||
if (Input.IsActionJustPressed("scroll_up"))
|
||||
{
|
||||
Rotation -= 1;
|
||||
}
|
||||
if (Input.IsActionJustPressed("scroll_down"))
|
||||
{
|
||||
Rotation += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Drop()
|
||||
{
|
||||
if (_held)
|
||||
{
|
||||
_held = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Hold()
|
||||
{
|
||||
if (_held)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_held = true;
|
||||
}
|
||||
|
||||
// Processes
|
||||
|
||||
// PRIVATE METHODS
|
||||
private void OnMouseEntered()
|
||||
{
|
||||
_hovered = true;
|
||||
}
|
||||
|
||||
private void OnMouseExited()
|
||||
{
|
||||
_hovered = false;
|
||||
}
|
||||
|
||||
private void OnBodyEntered(Node NODE)
|
||||
{
|
||||
if (NODE is Worker)
|
||||
{
|
||||
// _rotationalForce *= 0.8f;
|
||||
// Vector2 rotatedForce = LinearVelocity.Rotated(((Worker)NODE)._rotationalForce);
|
||||
|
||||
// ApplyCentralForce(rotatedForce);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user