1
0
Fork 0

Move old set_yaw and add node on set_velocity

This commit is contained in:
jordan4ibanez 2021-04-15 11:29:18 -04:00
parent e53a193c4f
commit 9e4bf6e130
2 changed files with 34 additions and 32 deletions

View File

@ -228,6 +228,9 @@ end
-- move mob in facing direction
--this has been modified to be internal
--internal = lua (self.yaw)
--engine = c++ (self.object:get_yaw())
local set_velocity = function(self, v)
local yaw = (self.yaw or 0)
@ -271,37 +274,6 @@ local get_velocity = function(self)
return 0
end
-- set and return valid yaw
local set_yaw = function(self, yaw, delay, dtime)
if not yaw or yaw ~= yaw then
yaw = 0
end
delay = delay or 0
if delay == 0 then
if self.shaking and dtime then
yaw = yaw + (math_random() * 2 - 1) * 5 * dtime
end
self.yaw(yaw)
update_roll(self)
return yaw
end
self.target_yaw = yaw
self.delay = delay
return self.target_yaw
end
-- global function to set mob yaw
function mobs:yaw(self, yaw, delay, dtime)
set_yaw(self, yaw, delay, dtime)
end
-- set defined animation
local set_animation = function(self, anim, fixed_frame)
if not self.animation or not anim then

View File

@ -3266,4 +3266,34 @@ local create_mob_on_rightclick = function(on_rightclick)
on_rightclick(self, clicker)
end
end
end
end
-- set and return valid yaw
local set_yaw = function(self, yaw, delay, dtime)
if not yaw or yaw ~= yaw then
yaw = 0
end
delay = delay or 0
if delay == 0 then
if self.shaking and dtime then
yaw = yaw + (math_random() * 2 - 1) * 5 * dtime
end
self.yaw(yaw)
update_roll(self)
return yaw
end
self.target_yaw = yaw
self.delay = delay
return self.target_yaw
end
-- global function to set mob yaw
function mobs:yaw(self, yaw, delay, dtime)
set_yaw(self, yaw, delay, dtime)
end