mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Weather support
This commit is contained in:
parent
e65d8ad655
commit
3aedfac968
23 changed files with 552 additions and 91 deletions
|
@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "content_mapnode.h" // For mapnode_translate_*_internal
|
||||
#include "serialization.h" // For ser_ver_supported
|
||||
#include "util/serialize.h"
|
||||
#include "log.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -359,9 +360,23 @@ std::vector<aabb3f> MapNode::getSelectionBoxes(INodeDefManager *nodemgr) const
|
|||
return transformNodeBox(*this, f.selection_box, nodemgr);
|
||||
}
|
||||
|
||||
u8 MapNode::getMaxLevel(INodeDefManager *nodemgr) const
|
||||
{
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
// todo: after update in all games leave only if (f.param_type_2 ==
|
||||
if( f.liquid_type == LIQUID_SOURCE
|
||||
|| f.liquid_type == LIQUID_FLOWING
|
||||
|| f.param_type_2 == CPT2_FLOWINGLIQUID)
|
||||
return LIQUID_LEVEL_MAX;
|
||||
if(f.leveled || f.param_type_2 == CPT2_LEVELED)
|
||||
return LEVELED_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 MapNode::getLevel(INodeDefManager *nodemgr) const
|
||||
{
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
// todo: after update in all games leave only if (f.param_type_2 ==
|
||||
if(f.liquid_type == LIQUID_SOURCE)
|
||||
return LIQUID_LEVEL_SOURCE;
|
||||
if (f.param_type_2 == CPT2_FLOWINGLIQUID)
|
||||
|
@ -377,6 +392,37 @@ u8 MapNode::getLevel(INodeDefManager *nodemgr) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
u8 MapNode::addLevel(INodeDefManager *nodemgr, s8 add)
|
||||
{
|
||||
s8 level = getLevel(nodemgr);
|
||||
u8 rest = 0;
|
||||
if (add == 0) level = 1;
|
||||
level += add;
|
||||
if (level < 1) {
|
||||
setContent(CONTENT_AIR);
|
||||
return 0;
|
||||
}
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
if ( f.param_type_2 == CPT2_FLOWINGLIQUID
|
||||
|| f.liquid_type == LIQUID_FLOWING
|
||||
|| f.liquid_type == LIQUID_SOURCE) {
|
||||
if (level >= LIQUID_LEVEL_MAX) {
|
||||
rest = level - LIQUID_LEVEL_MAX;
|
||||
setContent(nodemgr->getId(f.liquid_alternative_source));
|
||||
} else {
|
||||
setContent(nodemgr->getId(f.liquid_alternative_flowing));
|
||||
setParam2(level & LIQUID_LEVEL_MASK);
|
||||
}
|
||||
} else if (f.leveled || f.param_type_2 == CPT2_LEVELED) {
|
||||
if (level > LEVELED_MAX) {
|
||||
rest = level - LEVELED_MAX;
|
||||
level = LEVELED_MAX;
|
||||
}
|
||||
setParam2(level & LEVELED_MASK);
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
|
||||
u32 MapNode::serializedLength(u8 version)
|
||||
{
|
||||
if(!ser_ver_supported(version))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue