代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
一二七.用岩石种海洋(建造护城河)
用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/inv_rocks.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容:
local function ondeploy(inst, pt, deployer)
local ground = GetWorld()
if ground then
local original_tile_type = ground.Map:GetTileAtPoint(pt.x, pt.y, pt.z)
local x, y = ground.Map:GetTileCoordsAtPoint(pt.x, pt.y, pt.z)
if x and y then
ground.Map:SetTile(x,y, GROUND.IMPASSABLE)
ground.Map:RebuildLayer( original_tile_type, x, y )
ground.Map:RebuildLayer( GROUND.IMPASSABLE, x, y )
end
local minimap = TheSim:FindFirstEntityWithTag("minimap")
if minimap then
minimap.MiniMap:RebuildLayer( original_tile_type, x, y )
minimap.MiniMap:RebuildLayer( GROUND.IMPASSABLE, x, y )
end
end
inst.components.stackable:Get():Remove()
end
inst:AddComponent("deployable")
inst.components.deployable.ondeploy = ondeploy
inst.components.deployable.min_spacing = 0
inst.components.deployable.placer = "gridplacer"
即可用岩石种海洋,建造护城河。如果对自己建的岛不满意,也可以用岩石修改哦。岩石种过海洋后,会保留岸边的贴图,存档退出后再进入游戏就正常了。不要将海洋建在路底下