block tick interval
This commit is contained in:
parent
e969d4fea2
commit
7b0e31951b
@ -212,6 +212,10 @@ void ContentLoader::loadBlock(Block& def, std::string name, fs::path file) {
|
|||||||
root->str("script-name", def.scriptName);
|
root->str("script-name", def.scriptName);
|
||||||
root->str("ui-layout", def.uiLayout);
|
root->str("ui-layout", def.uiLayout);
|
||||||
root->num("inventory-size", def.inventorySize);
|
root->num("inventory-size", def.inventorySize);
|
||||||
|
root->num("tick-interval", def.tickInterval);
|
||||||
|
if (def.tickInterval == 0) {
|
||||||
|
def.tickInterval = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (def.hidden && def.pickingItem == def.name+BLOCK_ITEM_SUFFIX) {
|
if (def.hidden && def.pickingItem == def.name+BLOCK_ITEM_SUFFIX) {
|
||||||
def.pickingItem = CORE_EMPTY;
|
def.pickingItem = CORE_EMPTY;
|
||||||
|
|||||||
@ -113,8 +113,9 @@ void BlocksController::onBlocksTick(int tickid, int parts) {
|
|||||||
if ((id + tickid) % parts != 0)
|
if ((id + tickid) % parts != 0)
|
||||||
continue;
|
continue;
|
||||||
auto def = indices->getBlockDef(id);
|
auto def = indices->getBlockDef(id);
|
||||||
if (def->rt.funcsset.onblockstick) {
|
auto interval = def->tickInterval;
|
||||||
scripting::on_blocks_tick(def, tickRate);
|
if (def->rt.funcsset.onblockstick && tickid / parts % interval == 0) {
|
||||||
|
scripting::on_blocks_tick(def, tickRate / interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,6 +162,9 @@ public:
|
|||||||
/// @brief Block inventory size. 0 - no inventory
|
/// @brief Block inventory size. 0 - no inventory
|
||||||
uint inventorySize = 0;
|
uint inventorySize = 0;
|
||||||
|
|
||||||
|
// @brief Block tick interval (1 - 20tps, 2 - 10tps)
|
||||||
|
uint tickInterval = 1;
|
||||||
|
|
||||||
/// @brief Runtime indices (content indexing results)
|
/// @brief Runtime indices (content indexing results)
|
||||||
struct {
|
struct {
|
||||||
/// @brief block runtime integer id
|
/// @brief block runtime integer id
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user