From abef6da56913f1c55528103e60a50451a39628b1 Mon Sep 17 00:00:00 2001 From: WlodekM Date: Sun, 16 Jun 2024 10:35:45 +0300 Subject: initial commit --- src/BlockPhysics.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/BlockPhysics.h (limited to 'src/BlockPhysics.h') diff --git a/src/BlockPhysics.h b/src/BlockPhysics.h new file mode 100644 index 0000000..9bd8126 --- /dev/null +++ b/src/BlockPhysics.h @@ -0,0 +1,29 @@ +#ifndef CC_BLOCKPHYSICS_H +#define CC_BLOCKPHYSICS_H +#include "Core.h" +/* Implements simple block physics. + Copyright 2014-2023 ClassiCube | Licensed under BSD-3 +*/ +typedef void (*PhysicsHandler)(int index, BlockID block); + +CC_VAR extern struct Physics_ { + /* Whether block physics are enabled at all. */ + cc_bool Enabled; + /* Called when block is activated by a neighbouring block change. */ + /* e.g. trigger sand falling, water flooding */ + PhysicsHandler OnActivate[256]; + /* Called when this block is randomly activated. */ + /* e.g. grass eventually fading to dirt in darkness */ + PhysicsHandler OnRandomTick[256]; + /* Called when user manually places a block. */ + PhysicsHandler OnPlace[256]; + /* Called when user manually deletes a block. */ + PhysicsHandler OnDelete[256]; +} Physics; + +void Physics_SetEnabled(cc_bool enabled); +void Physics_OnBlockChanged(int x, int y, int z, BlockID old, BlockID now); +void Physics_Init(void); +void Physics_Free(void); +void Physics_Tick(void); +#endif -- cgit 1.4.1-2-gfad0