Re-implement random villager textures
This commit is contained in:
parent
74bbc9ce2d
commit
c53412d875
@ -239,6 +239,14 @@ These fields are available:
|
||||
* `_horny`: `true` if mob is “horny”. If another horny mob is nearby, they will mate and spawn a child soon
|
||||
* `_pregnant`: `true` if mob is pregnant and about to spawn a child
|
||||
|
||||
### Textures
|
||||
|
||||
NOTE: You must update these whenever you want to change a mob's texture. If the mob does not use a custom
|
||||
child texture, `_textures_child` can be skipped.
|
||||
|
||||
* `_textures_adult`: Stores a copy of the current mob textures table for the mob in adult form
|
||||
* `_textures_child`: Stores a copy of the current mob textures table for the mob in child form
|
||||
|
||||
### Damage
|
||||
|
||||
* `_get_node_damage`: `true` when mob can take damage from nodes (`damage_per_second`) (default: false)
|
||||
|
@ -23,6 +23,8 @@ rp_mobs.internal.add_persisted_entity_vars({
|
||||
"_dying", -- true if mob is currently dying (for animation)
|
||||
"_dying_timer", -- time since mob dying started
|
||||
"_killer_player_name", -- if mob was killed by a player, this contains their name. Otherwise nil
|
||||
"_textures_adult", -- persisted textures of mob in adult state
|
||||
"_textures_child", -- persisted textures of mob in child state
|
||||
})
|
||||
|
||||
local microtask_to_string = function(microtask)
|
||||
@ -150,8 +152,8 @@ rp_mobs.register_mob = function(mobname, def)
|
||||
mdef.entity_definition._dying_timer = 0
|
||||
if def.textures_child then
|
||||
mdef.entity_definition._textures_child = def.textures_child
|
||||
mdef.entity_definition._textures_adult = initprop.textures
|
||||
end
|
||||
mdef.entity_definition._textures_adult = initprop.textures
|
||||
if def.front_body_point then
|
||||
mdef.entity_definition._front_body_point = table.copy(def.front_body_point)
|
||||
end
|
||||
|
@ -395,6 +395,15 @@ local heal_decider = function(task_queue, mob)
|
||||
rp_mobs.add_task_to_task_queue(task_queue, task)
|
||||
end
|
||||
|
||||
local set_random_textures = function(mob)
|
||||
local r = math.random(1, 6)
|
||||
local tex = { "mobs_villager"..r..".png" }
|
||||
mob.object:set_properties({
|
||||
textures = tex,
|
||||
})
|
||||
mob._textures_adult = tex
|
||||
end
|
||||
|
||||
for _, villager_type_table in pairs(villager_types) do
|
||||
local villager_type = villager_type_table[1]
|
||||
local villager_name = villager_type_table[2]
|
||||
@ -424,7 +433,7 @@ for _, villager_type_table in pairs(villager_types) do
|
||||
selectionbox = { -0.32, -1.0, -0.22, 0.32, 0.77, 0.22, rotate=true},
|
||||
visual = "mesh",
|
||||
mesh = "mobs_villager.b3d",
|
||||
-- TODO: Random texture
|
||||
-- Texture will be overridden on first spawn
|
||||
textures = { "mobs_villager1.png" },
|
||||
makes_footstep_sound = true,
|
||||
stepheight = 0.6,
|
||||
@ -435,6 +444,11 @@ for _, villager_type_table in pairs(villager_types) do
|
||||
on_activate = function(self, staticdata)
|
||||
rp_mobs.init_mob(self)
|
||||
rp_mobs.restore_state(self, staticdata)
|
||||
if not self._textures_adult then
|
||||
set_random_textures(self)
|
||||
else
|
||||
self.object:set_properties({textures = self._textures_adult})
|
||||
end
|
||||
|
||||
rp_mobs.init_fall_damage(self, true)
|
||||
rp_mobs.init_breath(self, true, {
|
||||
|
Loading…
x
Reference in New Issue
Block a user