add rotation_offset
support
This commit is contained in:
parent
e339d405a6
commit
a932670ce5
15
build.lua
15
build.lua
@ -69,6 +69,17 @@ local function check_free(mapblock_pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function apply_rotation_offset(building_def, rotation)
|
||||||
|
if building_def.rotation_offset then
|
||||||
|
rotation = rotation + building_def.rotation_offset
|
||||||
|
while rotation >= 360 do
|
||||||
|
rotation = rotation - 360
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return rotation
|
||||||
|
end
|
||||||
|
|
||||||
function building_lib.can_build(mapblock_pos, building_name, rotation)
|
function building_lib.can_build(mapblock_pos, building_name, rotation)
|
||||||
local building_def = building_lib.get_building(building_name)
|
local building_def = building_lib.get_building(building_name)
|
||||||
if not building_def then
|
if not building_def then
|
||||||
@ -78,6 +89,8 @@ function building_lib.can_build(mapblock_pos, building_name, rotation)
|
|||||||
-- check placement definition
|
-- check placement definition
|
||||||
local placement = building_lib.get_placement(building_def.placement)
|
local placement = building_lib.get_placement(building_def.placement)
|
||||||
|
|
||||||
|
rotation = apply_rotation_offset(building_def, rotation)
|
||||||
|
|
||||||
-- check the conditions on every mapblock the building would occupy
|
-- check the conditions on every mapblock the building would occupy
|
||||||
local size, message = placement.get_size(placement, mapblock_pos, building_def, rotation)
|
local size, message = placement.get_size(placement, mapblock_pos, building_def, rotation)
|
||||||
if not size then
|
if not size then
|
||||||
@ -126,6 +139,8 @@ function building_lib.do_build(mapblock_pos, building_name, rotation, callback)
|
|||||||
local building_def = building_lib.get_building(building_name)
|
local building_def = building_lib.get_building(building_name)
|
||||||
assert(building_def)
|
assert(building_def)
|
||||||
|
|
||||||
|
rotation = apply_rotation_offset(building_def, rotation)
|
||||||
|
|
||||||
-- place into world
|
-- place into world
|
||||||
local placement = building_lib.get_placement(building_def.placement)
|
local placement = building_lib.get_placement(building_def.placement)
|
||||||
local size = placement.get_size(placement, mapblock_pos, building_def, rotation)
|
local size = placement.get_size(placement, mapblock_pos, building_def, rotation)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user