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