feat(packages): ludic.wildlife - a valley's animals: species handed in as data, ranges placed against the ground and moved with the season, the day's steering, the senses and a net alert that settles, feeding, lures and snares, birds, spawning and repopulation, its own dice, facts and a save section
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
80f3468ff8
commit
c9dc592dcc
28 changed files with 1956 additions and 0 deletions
44
packages/ludic.wildlife/system.ludic
Normal file
44
packages/ludic.wildlife/system.ludic
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# system.ludic - the wildlife as a system: its save section is this player's record (the species
|
||||
# seen and fed) and which ranges they have found; the animals themselves are respawned with the
|
||||
# valley, so a reset forgets the record and nothing else
|
||||
export function wildlife_reset() -> void {
|
||||
wl_record_reset()
|
||||
wl_found = null
|
||||
let rs = wildlife_ranges()
|
||||
for i in 0 .. len(rs) { rs[i].found = false }
|
||||
q_clear(wildlife_facts())
|
||||
}
|
||||
|
||||
export function wildlife_save() -> Val {
|
||||
let v = Value.object()
|
||||
sv_put_int(v, "seen", wl_seen)
|
||||
sv_put_int(v, "fed", wl_fed)
|
||||
sv_put_bool(v, "fed_any", wl_fed_any)
|
||||
let found = new []int
|
||||
let rs = wildlife_ranges()
|
||||
for i in 0 .. len(rs) {
|
||||
var f = 0
|
||||
if rs[i].found { f = 1 }
|
||||
push(found, f)
|
||||
}
|
||||
sv_put_ints(v, "found", found)
|
||||
return v
|
||||
}
|
||||
|
||||
export function wildlife_load(v: Val, version: int) -> void {
|
||||
wildlife_reset()
|
||||
wl_seen = sv_int(v, "seen", 0)
|
||||
wl_fed = sv_int(v, "fed", 0)
|
||||
wl_fed_any = sv_bool(v, "fed_any", false)
|
||||
wl_found = sv_ints(v, "found")
|
||||
wl_found_apply()
|
||||
}
|
||||
|
||||
# PH_SIMULATE with no tick of its own: the game steps it (wildlife_tick) where the world is owned
|
||||
export function wildlife_system() -> System {
|
||||
let s = system_new("wildlife", PH_SIMULATE)
|
||||
s.reset = fn wildlife_reset
|
||||
s.save = fn wildlife_save
|
||||
s.load = fn wildlife_load
|
||||
return s
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue