Add layer 5 for placing blocks
This commit is contained in:
parent
611612892c
commit
e4504fbfd3
@ -86,18 +86,23 @@ namespace Gmtk24 {
|
||||
}
|
||||
|
||||
private void UpdatePhysics() {
|
||||
if (Mode != BlockMode.NonPhysical) {
|
||||
if (Mode == BlockMode.Physical || Mode == BlockMode.Dragged) {
|
||||
CollisionLayer = PhysicalModeLayer;
|
||||
CollisionMask = PhysicalModeLayer;
|
||||
CollisionMask = PhysicalModeLayer + 0b10000;
|
||||
if (Mode == BlockMode.Dragged) {
|
||||
FreezeMode = FreezeModeEnum.Kinematic;
|
||||
Freeze = true;
|
||||
} else {
|
||||
Freeze = false;
|
||||
}
|
||||
} else if (Mode == BlockMode.NonPhysical || Mode == BlockMode.Placed) {
|
||||
if (Mode == BlockMode.Placed) {
|
||||
CollisionLayer = 0b10000;
|
||||
CollisionMask = 0b10000;
|
||||
} else {
|
||||
CollisionLayer = 0;
|
||||
CollisionMask = 0;
|
||||
}
|
||||
FreezeMode = FreezeModeEnum.Static;
|
||||
Freeze = true;
|
||||
}
|
||||
@ -139,6 +144,7 @@ namespace Gmtk24 {
|
||||
Physical,
|
||||
Dragged,
|
||||
NonPhysical,
|
||||
Placed,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace Gmtk24 {
|
||||
|
||||
public override void _Process(double delta) {
|
||||
if (GhostBlock != null) {
|
||||
var res = Util.RaycastFromMouse(Orbit.Camera, 0b100);
|
||||
var res = Util.RaycastFromMouse(Orbit.Camera, 0b10100);
|
||||
if (res is RaycastResult results) {
|
||||
Vector3 Pos = results.Position - GlobalPosition;
|
||||
GhostBlock.Position = Pos * Basis;
|
||||
@ -90,22 +90,18 @@ namespace Gmtk24 {
|
||||
};
|
||||
AddChild(GhostBlock);
|
||||
|
||||
// Hud.InteractionPaused = true;
|
||||
Hud.InteractionPaused = true;
|
||||
}
|
||||
|
||||
public void OnBlockRelease(BuildingBlock block, uint typeUint) {
|
||||
// Hud.InteractionPaused = false;
|
||||
|
||||
if (GhostBlock != null) {
|
||||
GhostBlock.QueueFree();
|
||||
GhostBlock = null;
|
||||
}
|
||||
|
||||
Hud.InteractionPaused = false;
|
||||
BlockReleaseType type = (BlockReleaseType)typeUint;
|
||||
|
||||
block.Reparent(this);
|
||||
|
||||
switch (type) {
|
||||
case BlockReleaseType.Throw: {
|
||||
block.SetMode(BuildingBlock.BlockMode.Physical);
|
||||
block.Reparent(this);
|
||||
var normal = Orbit.Camera.ProjectRayNormal(Orbit.Camera.GetViewport().GetMousePosition());
|
||||
var direction = normal * 10;
|
||||
|
||||
@ -119,11 +115,17 @@ namespace Gmtk24 {
|
||||
}
|
||||
|
||||
case BlockReleaseType.Place: {
|
||||
block.SetMode(BuildingBlock.BlockMode.Placed);
|
||||
block.Transform = GhostBlock.Transform;
|
||||
break;
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (GhostBlock != null) {
|
||||
GhostBlock.QueueFree();
|
||||
GhostBlock = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user