Ruined
This commit is contained in:
+33
-11
@@ -1,6 +1,6 @@
|
||||
-- Species/niche policy only. Succession owns the one fixed-eight scheduler.
|
||||
return function(hearth, api)
|
||||
local D = {species_order={"oak","birch","pine","willow","alder","beech","aspen","rowan","hazel","spruce"},
|
||||
local D = {species_order={"oak","birch","pine","willow","alder","beech","aspen","rowan","hazel","spruce","crab_apple","wild_cherry","field_maple"},
|
||||
plants={"clover","nettle","heather","bluebell","sedge","bulrush","moss","lichen"},
|
||||
grounds={grass=true,soil=true,forest_floor=true,podzol=true,alluvium=true,peat=true,alpine_turf=true},
|
||||
rocks={stone=true,granite=true,basalt=true,limestone=true,slate=true,sandstone=true,scree=true}}
|
||||
@@ -14,19 +14,23 @@ return function(hearth, api)
|
||||
for _, plant in ipairs(D.plants) do flora[plant]=true end
|
||||
function D.tree_info(value)
|
||||
local k=kind(value)
|
||||
local s,stage=(k or ""):match("^([a-z]+)_([a-z]+)$")
|
||||
local s,stage=(k or ""):match("^([a-z_]+)_([a-z]+)$")
|
||||
if species[s] and ({seedling=true,young=true,mature=true})[stage] then return s,stage end
|
||||
end
|
||||
function D.family(value)
|
||||
local k=kind(value)
|
||||
local s,stage=D.tree_info(k)
|
||||
if s then return ({seedling="tree_seedling",young="young_tree",mature="mature_tree"})[stage] end
|
||||
local wood,part=(k or ""):match("^([a-z]+)_(leaves)$")
|
||||
local wood,part=(k or ""):match("^([a-z_]+)_(leaves)$")
|
||||
if species[wood] then return part end
|
||||
wood,part=(k or ""):match("^([a-z]+)_(log)$")
|
||||
wood,part=(k or ""):match("^([a-z_]+)_(log)$")
|
||||
return species[wood] and part or k
|
||||
end
|
||||
function D.is_worldgen_flora(value) return flora[kind(value)]==true or D.tree_info(value)~=nil end
|
||||
function D.is_worldgen_flora(value)
|
||||
return flora[kind(value)]==true or D.tree_info(value)~=nil
|
||||
or (hearth.botany and hearth.botany.kind(value)~=nil and D.family(value)~="log" and D.family(value)~="leaves"
|
||||
and not (kind(value) or ""):match("_planks$")) or false
|
||||
end
|
||||
function D.is_ground(value) return D.grounds[kind(value)]==true end
|
||||
function D.is_rock(value) return D.rocks[kind(value)]==true end
|
||||
function D.supports_ground(value, support)
|
||||
@@ -39,7 +43,9 @@ return function(hearth, api)
|
||||
alder={alluvium=true,peat=true,forest_floor=true},
|
||||
beech={grass=true,soil=true,forest_floor=true}, aspen={grass=true,forest_floor=true,alluvium=true},
|
||||
rowan={grass=true,forest_floor=true,podzol=true,alpine_turf=true},
|
||||
hazel={grass=true,soil=true,forest_floor=true}, spruce={podzol=true,forest_floor=true,alpine_turf=true}}
|
||||
hazel={grass=true,soil=true,forest_floor=true}, spruce={podzol=true,forest_floor=true,alpine_turf=true},
|
||||
crab_apple={grass=true,soil=true,forest_floor=true},wild_cherry={grass=true,soil=true,forest_floor=true},
|
||||
field_maple={grass=true,soil=true,forest_floor=true}}
|
||||
function D.supports_species(s, support)
|
||||
if not species[s] then return false end
|
||||
local b=hearth.biomes
|
||||
@@ -86,9 +92,9 @@ return function(hearth, api)
|
||||
choices=(h.ground=="peat" or (p.x+p.z)%2~=0) and {"alder","willow"} or {"willow","alder"}
|
||||
elseif h.ground=="forest_floor" and (h.canopy or 0)>=0.5 then choices={"oak","birch"}
|
||||
else choices={"birch","oak"} end
|
||||
-- Retain the old pioneer niches at the origin while admitting all ten
|
||||
-- Retain the old pioneer niches at the origin while admitting all thirteen
|
||||
-- species deterministically; no random reroll or extra world scan.
|
||||
local extra=({"beech","aspen","rowan","hazel","spruce"})[math.abs(p.x*7+p.z*11)%10]
|
||||
local extra=({"beech","aspen","rowan","hazel","spruce","crab_apple","wild_cherry","field_maple"})[math.abs(p.x*7+p.z*11)%13]
|
||||
if extra and D.suitable(extra.."_seedling",h) then return extra.."_seedling" end
|
||||
for _,s in ipairs(choices) do if D.suitable(s.."_seedling",h) then return s.."_seedling" end end
|
||||
end
|
||||
@@ -150,15 +156,24 @@ return function(hearth, api)
|
||||
local current=api.get_node_or_nil(p)
|
||||
if not current or (n and current.name~=n.name) then return false end
|
||||
n=current
|
||||
-- Only fallen logs join the existing flora adoption policy; generic
|
||||
-- litter/fungi and standing log/leaves trees are not newly adopted.
|
||||
if not n or not (D.is_worldgen_flora(n) or n.name=="hearth:deadwood") or not unmarked(p) then return false end
|
||||
local root_species=kind(n) and kind(n):match("^([a-z_]+)_log$")
|
||||
local block_root=(species[root_species] or kind(n)=="log") and hearth.botany~=nil
|
||||
if not n or not (D.is_worldgen_flora(n) or block_root or n.name=="hearth:deadwood") or not unmarked(p) then return false end
|
||||
local below={x=p.x,y=p.y-1,z=p.z}
|
||||
local support=api.get_node_or_nil(below)
|
||||
if not support or not D.supports_ground(n,support) or not unmarked(below) then return false end
|
||||
if block_root and not D.is_ground(support) then return false end
|
||||
local m=api.get_meta(p)
|
||||
if m:get_string("succ_natural")=="1" then return false end
|
||||
m:set_string("succ_natural","1")
|
||||
if block_root then
|
||||
m:set_string("succ_component",p.x..":"..p.y..":"..p.z)
|
||||
m:set_string("succ_worldgen_stage","mature")
|
||||
m:set_string("succ_species",root_species or "generic")
|
||||
end
|
||||
-- Succession adopts a known displayed stage on its first bounded visit;
|
||||
-- bootstrap does not backdate an invented historical birthday.
|
||||
if block_root or (hearth.botany and hearth.botany.kind(n)) then m:set_string("succ_pending_origin","worldgen_established") end
|
||||
return true
|
||||
end
|
||||
local seasons=hearth.seasons
|
||||
@@ -220,7 +235,14 @@ return function(hearth, api)
|
||||
groups={snappy=3,flora=1,flammable=2,hearth_ecosystem=1},drop="",after_place_node=placed})
|
||||
end
|
||||
local names={"hearth:deadwood"}
|
||||
if hearth.botany then
|
||||
names[#names+1]="hearth:log"
|
||||
for _,s in ipairs(D.species_order) do names[#names+1]="hearth:"..s.."_log" end
|
||||
end
|
||||
for k in pairs(flora) do names[#names+1]="hearth:"..k end
|
||||
if hearth.botany then for _,r in ipairs(hearth.botany.list()) do
|
||||
if r.group~="trees" and not flora[r.id] then names[#names+1]=r.node end
|
||||
end end
|
||||
for _,s in ipairs(D.species_order) do for _,stage in ipairs({"seedling","young","mature"}) do names[#names+1]="hearth:"..s.."_"..stage end end
|
||||
if seasons then for _,n in ipairs(seasons.names()) do if D.is_worldgen_flora(n) then names[#names+1]=n end end end
|
||||
api.register_lbm({name="hearth:diversity_natural_flora",label="Mark unmodified species worldgen flora",
|
||||
|
||||
Reference in New Issue
Block a user