#pragma once #include "StarBiMap.hpp" #include "StarRect.hpp" #include "StarPoly.hpp" #include "StarColor.hpp" #include "StarDrawable.hpp" #include "StarGameTypes.hpp" #include "StarCollisionBlock.hpp" #include "StarLua.hpp" #include "StarPlatformerAStar.hpp" namespace Star { STAR_CLASS(World); STAR_CLASS(WorldServer); STAR_CLASS(WorldClient); STAR_CLASS(Item); STAR_CLASS(ScriptedEntity); namespace LuaBindings { typedef function CallEntityScriptFunction; LuaCallbacks makeWorldCallbacks(World* world); void addWorldDebugCallbacks(LuaCallbacks& callbacks); void addWorldEntityCallbacks(LuaCallbacks& callbacks, World* world); void addWorldEnvironmentCallbacks(LuaCallbacks& callbacks, World* world); namespace WorldCallbacks { float magnitude(World* world, Vec2F pos1, Maybe pos2); Vec2F distance(World* world, Vec2F const& arg1, Vec2F const& arg2); bool polyContains(World* world, PolyF const& poly, Vec2F const& pos); LuaValue xwrap(World* world, LuaEngine& engine, LuaValue const& positionOrX); LuaValue nearestTo(World* world, LuaEngine& engine, Variant const& sourcePositionOrX, Variant const& targetPositionOrX); bool rectCollision(World* world, RectF const& arg1, Maybe const& arg2); bool pointTileCollision(World* world, Vec2F const& arg1, Maybe const& arg2); bool lineTileCollision(World* world, Vec2F const& arg1, Vec2F const& arg2, Maybe const& arg3); Maybe> lineTileCollisionPoint(World* world, Vec2F const& start, Vec2F const& end, Maybe const& maybeCollisionSet); bool rectTileCollision(World* world, RectF const& arg1, Maybe const& arg2); bool pointCollision(World* world, Vec2F const& point, Maybe const& collisionSet); LuaTupleReturn, Maybe> lineCollision(World* world, Vec2F const& start, Vec2F const& end, Maybe const& maybeCollisionSet); bool polyCollision(World* world, PolyF const& arg1, Maybe const& arg2, Maybe const& arg3); List collisionBlocksAlongLine(World* world, Vec2F const& arg1, Vec2F const& arg2, Maybe const& arg3, Maybe const& arg4); List> liquidAlongLine(World* world, Vec2F const& start, Vec2F const& end); Maybe resolvePolyCollision(World* world, PolyF poly, Vec2F const& position, float maximumCorrection, Maybe const& collisionSet); bool tileIsOccupied(World* world, Vec2I const& arg1, Maybe const& arg2, Maybe const& arg3); bool placeObject(World* world, String const& arg1, Vec2I const& arg2, Maybe const& arg3, Json const& arg4); Maybe spawnItem(World* world, Json const& itemType, Vec2F const& worldPosition, Maybe const& inputCount, Json const& inputParameters, Maybe const& initialVelocity, Maybe const& intangibleTime); List spawnTreasure(World* world, Vec2F const& position, String const& pool, float level, Maybe seed); Maybe spawnMonster(World* world, String const& arg1, Vec2F const& arg2, Maybe const& arg3); Maybe spawnNpc(World* world, Vec2F const& arg1, String const& arg2, String const& arg3, float arg4, Maybe arg5, Json const& arg6); Maybe spawnStagehand(World* world, Vec2F const& spawnPosition, String const& typeName, Json const& overrides); Maybe spawnProjectile(World* world, String const& arg1, Vec2F const& arg2, Maybe const& arg3, Maybe const& arg4, bool arg5, Json const& arg6); Maybe spawnVehicle(World* world, String const& vehicleName, Vec2F const& pos, Json const& extraConfig); double time(World* world); uint64_t day(World* world); double timeOfDay(World* world); float dayLength(World* world); Json getProperty(World* world, String const& arg1, Json const& arg2); void setProperty(World* world, String const& arg1, Json const& arg2); Maybe liquidAt(World* world, Variant boundBoxOrPoint); float gravity(World* world, Vec2F const& arg1); bool spawnLiquid(World* world, Vec2F const& arg1, LiquidId arg2, float arg3); Maybe destroyLiquid(World* world, Vec2F const& position); bool isTileProtected(World* world, Vec2F const& position); Maybe findPlatformerPath(World* world, Vec2F const& start, Vec2F const& end, ActorMovementParameters actorMovementParameters, PlatformerAStar::Parameters searchParameters); PlatformerAStar::PathFinder platformerPathStart(World* world, Vec2F const& start, Vec2F const& end, ActorMovementParameters actorMovementParameters, PlatformerAStar::Parameters searchParameters); } namespace ClientWorldCallbacks { RectI clientWindow(WorldClient* world); } namespace ServerWorldCallbacks { String id(WorldServer* world); bool breakObject(WorldServer* world, EntityId arg1, bool arg2); bool isVisibleToPlayer(WorldServer* world, RectF const& arg1); bool loadRegion(WorldServer* world, RectF const& arg1); bool regionActive(WorldServer* world, RectF const& arg1); void setTileProtection(WorldServer* world, DungeonId arg1, bool arg2); bool isPlayerModified(WorldServer* world, RectI const& region); Maybe forceDestroyLiquid(WorldServer* world, Vec2F const& position); EntityId loadUniqueEntity(WorldServer* world, String const& uniqueId); void setUniqueId(WorldServer* world, EntityId entityId, Maybe const& uniqueId); Json takeItemDrop(World* world, EntityId entityId, Maybe const& takenBy); void setPlayerStart(World* world, Vec2F const& playerStart, Maybe respawnInWorld); List players(World* world); LuaString fidelity(World* world, LuaEngine& engine); Maybe callScriptContext(World* world, String const& contextName, String const& function, LuaVariadic const& args); } namespace WorldDebugCallbacks { void debugPoint(Vec2F const& arg1, Color const& arg2); void debugLine(Vec2F const& arg1, Vec2F const& arg2, Color const& arg3); void debugPoly(PolyF const& poly, Color const& color); void debugText(LuaEngine& engine, LuaVariadic const& args); } namespace WorldEntityCallbacks { LuaTable entityQuery(World* world, LuaEngine& engine, Vec2F const& pos1, LuaValue const& pos2, Maybe options); LuaTable monsterQuery(World* world, LuaEngine& engine, Vec2F const& pos1, LuaValue const& pos2, Maybe options); LuaTable npcQuery(World* world, LuaEngine& engine, Vec2F const& pos1, LuaValue const& pos2, Maybe options); LuaTable objectQuery(World* world, LuaEngine& engine, Vec2F const& pos1, LuaValue const& pos2, Maybe options); LuaTable itemDropQuery(World* world, LuaEngine& engine, Vec2F const& pos1, LuaValue const& pos2, Maybe options); LuaTable playerQuery(World* world, LuaEngine& engine, Vec2F const& pos1, LuaValue const& pos2, Maybe options); LuaTable loungeableQuery(World* world, LuaEngine& engine, Vec2F const& pos1, LuaValue const& pos2, Maybe options); LuaTable entityLineQuery(World* world, LuaEngine& engine, Vec2F const& pos1, Vec2F const& pos2, Maybe options); LuaTable objectLineQuery(World* world, LuaEngine& engine, Vec2F const& pos1, Vec2F const& pos2, Maybe options); LuaTable npcLineQuery(World* world, LuaEngine& engine, Vec2F const& pos1, Vec2F const& pos2, Maybe options); bool entityExists(World* world, EntityId entityId); bool entityCanDamage(World* world, EntityId sourceId, EntityId targetId); Json entityDamageTeam(World* world, EntityId entityId); bool entityAggressive(World* world, EntityId entityId); Maybe entityType(World* world, LuaEngine& engine, EntityId entityId); Maybe entityPosition(World* world, EntityId entityId); Maybe entityVelocity(World* world, EntityId entityId); Maybe entityMetaBoundBox(World* world, EntityId entityId); Maybe entityCurrency(World* world, EntityId entityId, String const& currencyType); Maybe entityHasCountOfItem(World* world, EntityId entityId, Json descriptor, Maybe exactMatch); Maybe entityHealth(World* world, EntityId entityId); Maybe entitySpecies(World* world, EntityId entityId); Maybe entityGender(World* world, EntityId entityId); Maybe entityName(World* world, EntityId entityId); Maybe entityDescription(World* world, EntityId entityId, Maybe const& species); LuaNullTermWrapper>> entityPortrait(World* world, EntityId entityId, String const& portraitMode); Maybe entityHandItem(World* world, EntityId entityId, String const& handName); Json entityHandItemDescriptor(World* world, EntityId entityId, String const& handName); LuaNullTermWrapper> entityUniqueId(World* world, EntityId entityId); Json getObjectParameter(World* world, EntityId entityId, String const& parameterName, Maybe const& defaultValue); Json getNpcScriptParameter(World* world, EntityId entityId, String const& parameterName, Maybe const& defaultValue); List objectSpaces(World* world, EntityId entityId); Maybe farmableStage(World* world, EntityId entityId); Maybe containerSize(World* world, EntityId entityId); bool containerClose(World* world, EntityId entityId); bool containerOpen(World* world, EntityId entityId); Json containerItems(World* world, EntityId entityId); Json containerItemAt(World* world, EntityId entityId, size_t offset); Maybe containerConsume(World* world, EntityId entityId, Json const& items); Maybe containerConsumeAt(World* world, EntityId entityId, size_t offset, int count); Maybe containerAvailable(World* world, EntityId entityId, Json const& items); Json containerTakeAll(World* world, EntityId entityId); Json containerTakeAt(World* world, EntityId entityId, size_t offset); Json containerTakeNumItemsAt(World* world, EntityId entityId, size_t offset, int const& count); Maybe containerItemsCanFit(World* world, EntityId entityId, Json const& items); Json containerItemsFitWhere(World* world, EntityId entityId, Json const& items); Json containerAddItems(World* world, EntityId entityId, Json const& items); Json containerStackItems(World* world, EntityId entityId, Json const& items); Json containerPutItemsAt(World* world, EntityId entityId, Json const& items, size_t offset); Json containerSwapItems(World* world, EntityId entityId, Json const& items, size_t offset); Json containerSwapItemsNoCombine(World* world, EntityId entityId, Json const& items, size_t offset); Json containerItemApply(World* world, EntityId entityId, Json const& items, size_t offset); Maybe callScriptedEntity(World* world, EntityId entityId, String const& function, LuaVariadic const& args); RpcPromise findUniqueEntity(World* world, String const& uniqueId); RpcPromise sendEntityMessage(World* world, LuaEngine& engine, LuaValue entityId, String const& message, LuaVariadic args); Maybe loungeableOccupied(World* world, EntityId entityId); bool isMonster(World* world, EntityId entityId, Maybe const& aggressive); Maybe monsterType(World* world, EntityId entityId); Maybe npcType(World* world, EntityId entityId); Maybe stagehandType(World* world, EntityId entityId); bool isNpc(World* world, EntityId entityId, Maybe const& damageTeam); } namespace WorldEnvironmentCallbacks { float lightLevel(World* world, Vec2F const& position); float windLevel(World* world, Vec2F const& position); bool breathable(World* world, Vec2F const& position); bool underground(World* world, Vec2F const& position); LuaValue material(World* world, LuaEngine& engine, Vec2F const& position, String const& layerName); LuaValue mod(World* world, LuaEngine& engine, Vec2F const& position, String const& layerName); float materialHueShift(World* world, Vec2F const& position, String const& layerName); float modHueShift(World* world, Vec2F const& position, String const& layerName); MaterialColorVariant materialColor(World* world, Vec2F const& position, String const& layerName); void setMaterialColor(World* world, Vec2F const& position, String const& layerName, MaterialColorVariant color); bool damageTiles(World* world, List const& arg1, String const& arg2, Vec2F const& arg3, String const& arg4, float arg5, Maybe const& arg6, Maybe sourceEntity); bool damageTileArea(World* world, Vec2F center, float radius, String layer, Vec2F sourcePosition, String damageType, float damage, Maybe const& harvestLevel, Maybe sourceEntity); bool placeMaterial(World* world, Vec2I const& arg1, String const& arg2, String const& arg3, Maybe const& arg4, bool arg5); bool placeMod(World* world, Vec2I const& arg1, String const& arg2, String const& arg3, Maybe const& arg4, bool arg5); } } }