parent
4f312209b3
commit
d4b7c0bf45
@ -0,0 +1,16 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Babushka.scripts.CSharp.Common;
|
||||||
|
|
||||||
|
public partial class CameraController : Camera2D
|
||||||
|
{
|
||||||
|
[Export] private float _multiplier = 1.0f;
|
||||||
|
[Export] private Node2D _followNode;
|
||||||
|
|
||||||
|
|
||||||
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
this.Position = _followNode.Transform.Origin * _multiplier;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
uid://b4h7k5w0jsjri
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Babushka.scripts.CSharp.Common;
|
||||||
|
|
||||||
|
public partial class CameraPivot : Node3D
|
||||||
|
{
|
||||||
|
[Export] private bool _canPitch;
|
||||||
|
[Export] private bool _canYaw;
|
||||||
|
[Export] private float _rotateSpeed = 0.003f;
|
||||||
|
[Export] private Node3D _subPivot;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event)
|
||||||
|
{
|
||||||
|
if(@event.IsActionPressed("click"))
|
||||||
|
{
|
||||||
|
if (Input.MouseMode == Input.MouseModeEnum.Visible)
|
||||||
|
{
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("ui_cancel"))
|
||||||
|
{
|
||||||
|
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@event is InputEventMouseMotion test)
|
||||||
|
{
|
||||||
|
if (Input.MouseMode != Input.MouseModeEnum.Captured)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_canYaw)
|
||||||
|
_subPivot.RotateX(test.Relative.Y * -_rotateSpeed);
|
||||||
|
if(_canPitch)
|
||||||
|
this.RotateY(test.Relative.X * -_rotateSpeed);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
uid://c81bn1w8o0n2n
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Babushka.scripts.CSharp.Common;
|
||||||
|
|
||||||
|
public partial class InteractionArea : Node3D
|
||||||
|
{
|
||||||
|
[Export] private Area3D _area;
|
||||||
|
[Export] private Label3D _label;
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void InteractedEventHandler();
|
||||||
|
|
||||||
|
public override void _Process(double d)
|
||||||
|
{
|
||||||
|
if (_area.HasOverlappingBodies())
|
||||||
|
_label.Show();
|
||||||
|
else
|
||||||
|
_label.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event)
|
||||||
|
{
|
||||||
|
if(@event.IsAction("interact") && @event.IsPressed() && _area.HasOverlappingBodies())
|
||||||
|
EmitSignal(SignalName.Interacted);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1 @@
|
|||||||
|
uid://cgkea4bmd6a8f
|
||||||
@ -1,17 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common;
|
|
||||||
|
|
||||||
public partial class test : Node2D
|
|
||||||
{
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
public override void _Process(double delta)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
namespace Babushka.scripts.CSharp.Common;
|
|
||||||
|
|
||||||
public class test2
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue