break/place only when not paused
This commit is contained in:
parent
1e74665abc
commit
08e08000a6
@ -273,32 +273,34 @@ func (g *Game) Update(win *glfw.Window, delta time.Duration) {
|
|||||||
render.Framewire.PushBox(r.GrowEven(itype.Vec3d{0.03125, 0.03125, 0.03125}).Offset(bc.ToFloat64()).ToFloat32(), color.White)
|
render.Framewire.PushBox(r.GrowEven(itype.Vec3d{0.03125, 0.03125, 0.03125}).Offset(bc.ToFloat64()).ToFloat32(), color.White)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Break/Place block
|
if !g.paused {
|
||||||
if win.GetMouseButton(glfw.MouseButtonLeft) == glfw.Press && g.runtime-time.Duration(g.player.DatasetI("LastBreak")) >= PlayerBreakCooldown {
|
// Break/Place block
|
||||||
// Break
|
if win.GetMouseButton(glfw.MouseButtonLeft) == glfw.Press && g.runtime-time.Duration(g.player.DatasetI("LastBreak")) >= PlayerBreakCooldown {
|
||||||
g.world.Break(bc)
|
// Break
|
||||||
g.player.SetDatasetI("LastBreak", int64(g.runtime))
|
g.world.Break(bc)
|
||||||
} else if win.GetMouseButton(glfw.MouseButtonRight) == glfw.Press && g.runtime-time.Duration(g.player.DatasetI("LastPlace")) >= PlayerBreakCooldown {
|
g.player.SetDatasetI("LastBreak", int64(g.runtime))
|
||||||
// Place
|
} else if win.GetMouseButton(glfw.MouseButtonRight) == glfw.Press && g.runtime-time.Duration(g.player.DatasetI("LastPlace")) >= PlayerBreakCooldown {
|
||||||
// Check hitbox
|
// Place
|
||||||
tobehit := world.GetBlockBehaviour(placeId[placei]).Appearance(bc.Add(itype.DirectionVeci[dir]), 0, nil, g.world).Hitbox
|
// Check hitbox
|
||||||
if len(tobehit) == 0 {
|
tobehit := world.GetBlockBehaviour(placeId[placei]).Appearance(bc.Add(itype.DirectionVeci[dir]), 0, nil, g.world).Hitbox
|
||||||
tobehit = []itype.Boxd{{OffX: 0, OffY: 0, OffZ: 0, SizeX: 1, SizeY: 1, SizeZ: 1}}
|
if len(tobehit) == 0 {
|
||||||
}
|
tobehit = []itype.Boxd{{OffX: 0, OffY: 0, OffZ: 0, SizeX: 1, SizeY: 1, SizeZ: 1}}
|
||||||
canplace := true
|
}
|
||||||
outer:
|
canplace := true
|
||||||
for _, pb := range g.player.WorldHitbox() {
|
outer:
|
||||||
for _, b := range tobehit {
|
for _, pb := range g.player.WorldHitbox() {
|
||||||
if ok, _ := b.Offset(bc.Add(itype.DirectionVeci[dir]).ToFloat64()).Intersect(pb); ok {
|
for _, b := range tobehit {
|
||||||
canplace = false
|
if ok, _ := b.Offset(bc.Add(itype.DirectionVeci[dir]).ToFloat64()).Intersect(pb); ok {
|
||||||
break outer
|
canplace = false
|
||||||
|
break outer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if canplace {
|
if canplace {
|
||||||
g.world.SetBlock(bc.Add(itype.DirectionVeci[dir]), placeId[placei], 0, nil)
|
g.world.SetBlock(bc.Add(itype.DirectionVeci[dir]), placeId[placei], 0, nil)
|
||||||
g.player.SetDatasetI("LastPlace", int64(g.runtime))
|
g.player.SetDatasetI("LastPlace", int64(g.runtime))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user