added full support to water splash

This commit is contained in:
Alexsandro Percy 2024-08-21 20:27:59 -03:00
parent 6e8f961714
commit 572133b4c1
4 changed files with 28 additions and 7 deletions

View file

@ -60,6 +60,12 @@ if not minetest.settings:get_bool('airutils_disable_repair') then
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "airutils_repair.lua")
end
airutils.splash_texture = "airutils_splash.png"
airutils.use_water_particles = false
if minetest.settings:get_bool('airutils_enable_water_particles', false) then
airutils.use_water_particles = true
end
airutils._use_signs_api = true
if not minetest.get_modpath("signs_lib") then airutils._use_signs_api = false end
if minetest.settings:get_bool('airutils_disable_signs_api') then airutils._use_signs_api = false end
@ -78,8 +84,6 @@ dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "texture_management.lua"
dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "attach_extern_ent.lua")
if airutils._use_signs_api then dofile(minetest.get_modpath("airutils") .. DIR_DELIM .. "text.lua") end
airutils.splash_texture = "airutils_splash.png"
local is_biofuel_installed = false
if biomass then
if biomass.convertible_groups then is_biofuel_installed = true end

View file

@ -535,6 +535,19 @@ function airutils.logic(self)
if h_vel_compensation > max_pitch then h_vel_compensation = max_pitch end
--minetest.chat_send_all(h_vel_compensation)
newpitch = newpitch + (velocity.y * math.rad(max_pitch - h_vel_compensation))
if airutils.use_water_particles == true and airutils.add_splash and self._splash_x_position and self.buoyancy then
local splash_frequency = 0.15
if self._last_splash == nil then self._last_splash = 0.5 else self._last_splash = self._last_splash + self.dtime end
if longit_speed >= 2.0 and self._last_vel and self._last_splash >= splash_frequency then
self._last_splash = 0
local splash_pos = vector.new(curr_pos)
local bellow_position = self.initial_properties.collisionbox[2]
local collision_height = self.initial_properties.collisionbox[5] - bellow_position
splash_pos.y = splash_pos.y + (bellow_position + (collision_height * self.buoyancy)) - (collision_height/10)
airutils.add_splash(splash_pos, newyaw, self._splash_x_position)
end
end
end
local new_accel = accel

View file

@ -18,3 +18,7 @@ airutils_debug_log (log of entity activation) bool false
# disable the usage of signs_api by the vehicles
airutils_disable_signs_api (no names writen on vehicles surface) bool false
# enable water particles effect
airutils_enable_water_particles (enable particles on water) bool false

View file

@ -10,14 +10,14 @@ local function calculateVelocity(magnitude, angle)
return velocity
end
local function water_particle(pos, vel)
local function water_particle(pos, accell)
if airutils.splash_texture == nil then return end
if airutils.splash_texture == "" then return end
minetest.add_particle({
pos = pos,
velocity = vel, --{x = 0, y = 0, z = 0},
acceleration = {x = 0, y = 0, z = 0},
velocity = {x = 0, y = 0, z = 0},
acceleration = accell, --{x = 0, y = 0, z = 0},
expirationtime = 2.0,
size = 4.8,
collisiondetection = false,
@ -38,7 +38,7 @@ function airutils.add_splash(pos, yaw, x_pos)
spl_pos.x = spl_pos.x + move * math.cos(direction)
spl_pos.z = spl_pos.z + move * math.sin(direction)
local velocity = calculateVelocity(1.0, yaw)
local velocity = calculateVelocity(0.2, yaw)
water_particle(spl_pos, velocity)
--left
@ -47,6 +47,6 @@ function airutils.add_splash(pos, yaw, x_pos)
spl_pos.x = spl_pos.x + move * math.cos(direction)
spl_pos.z = spl_pos.z + move * math.sin(direction)
velocity = calculateVelocity(1.0, yaw - math.rad(180))
velocity = calculateVelocity(0.2, yaw - math.rad(180))
water_particle(spl_pos, velocity)
end