Add Ghost actually being removed correctly

This commit is contained in:
Sofia 2024-08-20 02:28:22 +03:00
parent 8eb56b39e1
commit 611612892c
5 changed files with 24 additions and 5 deletions

View File

@ -136,6 +136,11 @@ release_block={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(224, 40),"global_position":Vector2(238, 110),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null) "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(224, 40),"global_position":Vector2(238, 110),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
] ]
} }
place_block={
"deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(202, 14),"global_position":Vector2(216, 84),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}
[internationalization] [internationalization]

View File

@ -53,8 +53,9 @@ size = Vector3(43.3174, 26.5295, 43.4319)
[node name="Player" parent="." instance=ExtResource("10_3xiy2")] [node name="Player" parent="." instance=ExtResource("10_3xiy2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.332064, 1.5426, 3.65156) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.332064, 1.5426, 3.65156)
[node name="table" parent="." node_paths=PackedStringArray("TrenchbroomMap") instance=ExtResource("11_7trvw")] [node name="table" parent="." node_paths=PackedStringArray("Hud", "TrenchbroomMap") instance=ExtResource("11_7trvw")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 2.83695, 0, -4.36558) transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 2.83695, 0, -4.36558)
Hud = NodePath("../HUD")
TrenchbroomMap = NodePath("../DemoMap") TrenchbroomMap = NodePath("../DemoMap")
RelativeScale = 0.005 RelativeScale = 0.005

View File

@ -7,6 +7,8 @@ namespace Gmtk24 {
public Player Player; public Player Player;
[Export] [Export]
public RichTextLabel HoverText; public RichTextLabel HoverText;
[Export]
public bool InteractionPaused = false;
private Interactible Hovered; private Interactible Hovered;
@ -24,7 +26,7 @@ namespace Gmtk24 {
} }
if (collider is Interactible interactible) { if (!InteractionPaused && collider is Interactible interactible) {
if (interactible != Hovered) { if (interactible != Hovered) {
Hovered?.SetHovered(false); Hovered?.SetHovered(false);
interactible.SetHovered(true); interactible.SetHovered(true);
@ -48,6 +50,7 @@ namespace Gmtk24 {
public override void _UnhandledInput(InputEvent @event) { public override void _UnhandledInput(InputEvent @event) {
if (@event.IsAction("interact") && Hovered != null) { if (@event.IsAction("interact") && Hovered != null) {
Hovered.HandleInput(@event); Hovered.HandleInput(@event);
GetViewport().SetInputAsHandled();
} }
} }
} }

View File

@ -62,11 +62,15 @@ namespace Gmtk24 {
CurrentPitch = Mathf.Clamp(CurrentPitch, -Mathf.Pi * 0.49f, 0); CurrentPitch = Mathf.Clamp(CurrentPitch, -Mathf.Pi * 0.49f, 0);
} }
if (@event.IsActionPressed("release_block")) { if (HeldBlock != null) {
if (HeldBlock != null) { if (@event.IsActionPressed("release_block")) {
EmitSignal(SignalName.BlockRelease, HeldBlock, (uint)BlockReleaseType.Throw); EmitSignal(SignalName.BlockRelease, HeldBlock, (uint)BlockReleaseType.Throw);
HeldBlock = null; HeldBlock = null;
} }
if (@event.IsActionPressed("place_block")) {
EmitSignal(SignalName.BlockRelease, HeldBlock, (uint)BlockReleaseType.Place);
HeldBlock = null;
}
} }
} }

View File

@ -3,6 +3,9 @@ using System.Linq;
namespace Gmtk24 { namespace Gmtk24 {
public partial class Table : Interactible { public partial class Table : Interactible {
[Export]
public Hud Hud;
[Export(PropertyHint.NodeType, "FuncGodotMap")] [Export(PropertyHint.NodeType, "FuncGodotMap")]
public Node3D TrenchbroomMap; public Node3D TrenchbroomMap;
[ExportCategory("SpawnOptions")] [ExportCategory("SpawnOptions")]
@ -86,9 +89,13 @@ namespace Gmtk24 {
Mode = BuildingBlock.BlockMode.NonPhysical, Mode = BuildingBlock.BlockMode.NonPhysical,
}; };
AddChild(GhostBlock); AddChild(GhostBlock);
// Hud.InteractionPaused = true;
} }
public void OnBlockRelease(BuildingBlock block, uint typeUint) { public void OnBlockRelease(BuildingBlock block, uint typeUint) {
// Hud.InteractionPaused = false;
if (GhostBlock != null) { if (GhostBlock != null) {
GhostBlock.QueueFree(); GhostBlock.QueueFree();
GhostBlock = null; GhostBlock = null;
@ -97,7 +104,6 @@ namespace Gmtk24 {
BlockReleaseType type = (BlockReleaseType)typeUint; BlockReleaseType type = (BlockReleaseType)typeUint;
switch (type) { switch (type) {
case BlockReleaseType.Throw: { case BlockReleaseType.Throw: {
block.SetMode(BuildingBlock.BlockMode.Physical); block.SetMode(BuildingBlock.BlockMode.Physical);
block.Reparent(this); block.Reparent(this);
var normal = Orbit.Camera.ProjectRayNormal(Orbit.Camera.GetViewport().GetMousePosition()); var normal = Orbit.Camera.ProjectRayNormal(Orbit.Camera.GetViewport().GetMousePosition());