3#include <simplesquirrel/simplesquirrel.hpp>
22void PixelWorldModule::expose(ssq::Table& table) {
23 auto module = table.addClass(name, PixelWorldModule::create, false);
27 "PixelWorld", std::function<PixelWorld*()>([]() ->
PixelWorld* {
return nullptr; }),
true);
28 world.addFunc(
"getMaterial", [](PixelWorld* self,
int x,
int y) {
return self->getMaterial(
x,
y); });
29 world.addFunc(
"setMaterial", [](PixelWorld* self,
int x,
int y,
const std::string&
material) {
32 world.addFunc(
"paintCircle", [](PixelWorld* self,
int x,
int y,
int radius,
const std::string&
material) {
35 world.addFunc(
"step", [](PixelWorld* self) {
36 return int(self->step().cellsMoved);
38 world.addFunc(
"clear", [](PixelWorld* self) { self->clear(); });
39 world.addFunc(
"getSeed", [](PixelWorld* self) {
return std::int64_t(self->seed()); });
40 world.addFunc(
"getRevision", [](PixelWorld* self) {
return std::int64_t(self->revision()); });
41 world.addFunc(
"getTick", [](PixelWorld* self) {
return std::int64_t(self->tickValue()); });
42 world.addFunc(
"getLastEditSequence", [](PixelWorld* self) {
43 return std::int64_t(self->lastEditSequence());
45 world.addFunc(
"getChunkCount", [](PixelWorld* self) {
return self->chunkCount(); });
46 world.addFunc(
"getActiveChunkCount", [](PixelWorld* self) {
return self->activeChunkCount(); });
47 world.addFunc(
"getChangedChunkCountSince", [](PixelWorld* self,
int revision) {
50 world.addFunc(
"explode", [](PixelWorld* self,
int x,
int y,
int radius,
int strength,
int heat) {
52 std::int16_t(std::clamp(heat, -32768, 32767))).cellsRemoved);
56void PixelWorldModule::expose(ssq::Class&
cls) {
58 return self->newWorld(std::uint64_t(std::uint32_t(
seed)));
#define Module_IMPL(ModuleName, newExpr)
std::array< uint32_t, 16 > material
Script-facing owner/factory for deterministic pixel material worlds.
PixelWorldModule()
Pixel world module.
PixelWorld * newWorld(std::uint64_t seed=1)
Create a caller-owned world using the supplied deterministic seed.
~PixelWorldModule() override
Pixel world module.
Sparse, chunked, deterministic 2D falling-material world.
void unregisterPixelWorldAutomation()
void registerPixelWorldAutomation()