handle primary action inputs
This commit is contained in:
parent
635a832ec8
commit
8708540770
5 changed files with 7 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ public partial class DroppableItem : Area2D
|
||||||
{
|
{
|
||||||
if (@event.IsActionPressed("primary_action"))
|
if (@event.IsActionPressed("primary_action"))
|
||||||
{
|
{
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
PickUp();
|
PickUp();
|
||||||
EmitSignal(SignalName.PickedUp);
|
EmitSignal(SignalName.PickedUp);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,14 @@ public partial class DragAction : Node
|
||||||
toggle = false;
|
toggle = false;
|
||||||
can_end = false;
|
can_end = false;
|
||||||
EmitSignal(SignalName.DragBegin);
|
EmitSignal(SignalName.DragBegin);
|
||||||
GetTree().CreateTimer(0.2,ignoreTimeScale:true).Timeout += OnToggleTimeout;
|
GetTree().CreateTimer(0.2, ignoreTimeScale: true).Timeout += OnToggleTimeout;
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
}
|
}
|
||||||
if (dragging && can_end && (toggle == false && @event.IsActionReleased("primary_action") || (toggle == true && @event.IsActionPressed("primary_action"))))
|
if (dragging && can_end && (toggle == false && @event.IsActionReleased("primary_action") || (toggle == true && @event.IsActionPressed("primary_action"))))
|
||||||
{
|
{
|
||||||
dragging = false;
|
dragging = false;
|
||||||
EmitSignal(SignalName.DragEnd);
|
EmitSignal(SignalName.DragEnd);
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void OnToggleTimeout()
|
public void OnToggleTimeout()
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ public partial class ShovelButton : TextureButton
|
||||||
Disabled = true;
|
Disabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
hoveredEntity?.GetNode<FlashShaderController>("FlashController").Deselect();
|
hoveredEntity?.GetNode<FlashShaderController>("FlashController").Deselect();
|
||||||
hoveredEntity = null;
|
hoveredEntity = null;
|
||||||
ButtonPressed = false;
|
ButtonPressed = false;
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ public partial class PlantField : Node2D
|
||||||
|
|
||||||
if (@event.IsActionPressed("primary_action") && _previousCanPlace)
|
if (@event.IsActionPressed("primary_action") && _previousCanPlace)
|
||||||
{
|
{
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
var plant = _resource.Scene.Instantiate<RuntimePlantData>();
|
var plant = _resource.Scene.Instantiate<RuntimePlantData>();
|
||||||
PoolContainer.Instance.Plants.AddChild(plant);
|
PoolContainer.Instance.Plants.AddChild(plant);
|
||||||
plant.GlobalPosition = (_plantSetter.GlobalPosition / FieldParams.Tile).Ceil() * FieldParams.Tile - new Vector2(20, 14);
|
plant.GlobalPosition = (_plantSetter.GlobalPosition / FieldParams.Tile).Ceil() * FieldParams.Tile - new Vector2(20, 14);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ public partial class Sun : Area2D
|
||||||
|
|
||||||
if (@event.IsActionPressed("primary_action"))
|
if (@event.IsActionPressed("primary_action"))
|
||||||
{
|
{
|
||||||
|
GetViewport().SetInputAsHandled();
|
||||||
ScoreSun();
|
ScoreSun();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue