Sorted header files under include
made Script base class for AIScript and eventually WeaponScript
This commit is contained in:
parent
7e7dfd97b7
commit
3075a01b3d
39 changed files with 79 additions and 26 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
find_package(SDL2_IMAGE REQUIRED)
|
find_package(SDL2_IMAGE REQUIRED)
|
||||||
|
|
||||||
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/YuppleMayham")
|
include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/YuppleMayham/include")
|
||||||
include_directories(SYSTEM "c:/sdks/glad/include")
|
include_directories(SYSTEM "c:/sdks/glad/include")
|
||||||
include_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/include")
|
include_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/include")
|
||||||
include_directories(SYSTEM "c:/sdks/glm")
|
include_directories(SYSTEM "c:/sdks/glm")
|
||||||
|
|
@ -16,13 +16,58 @@ link_directories(SYSTEM "C:/sdks/freetype-2.13.2/objs")
|
||||||
link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/lib")
|
link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/lib")
|
||||||
link_directories(SYSTEM "c:/sdks/lua-5.4.6/lib")
|
link_directories(SYSTEM "c:/sdks/lua-5.4.6/lib")
|
||||||
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/YupplyMayham/gameplay)
|
include_directories("${PROJECT_SOURCE_DIR}/YuppleMayham/include")
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/YupplyMayham/graphics)
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/YupplyMayham/gameplay/weapons)
|
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/YupplyMayham)
|
|
||||||
|
|
||||||
# Add source to this project's executable.
|
# Add source to this project's executable.
|
||||||
add_executable (YuppleMayham "src/main.cpp" "c:/sdks/glad/src/glad.c" "graphics/glwindow.h" "src/graphics/sprite.cpp" "src/graphics/mesh.cpp" "src/gameplay/entity.cpp" "src/gameplay/gameactor.cpp" "src/graphics/shader.cpp" "src/util.cpp" "gameplay/camera.h" "src/gameplay/camera.cpp" "src/utility/command.cpp" "src/gameplay/input.cpp" "utility/mousestate.h" "src/gameplay/weapons/bullet.cpp" "gameplay/weapons/bulletmanager.h" "src/gameplay/weapons/bulletmanager.cpp" "src/gameplay/scene.cpp" "gameplay/scene.h" "graphics/tile.h" "graphics/texture.h" "src/graphics/texture.cpp" "src/graphics/tile.cpp" "graphics/tiletype.h" "utility/resourcemanager.h" "src/utility/resourcemanager.cpp" "utility/xmlloader.h" "src/utility/xmlloader.cpp" "gameplay/game.h" "src/gameplay/game.cpp" "src/graphics/instancedraw.cpp" "gameplay/map.h" "src/gameplay/map.cpp" "src/gameplay/weapons/weapon.cpp" "gameplay/physics.h" "src/gameplay/physics.cpp" "utility/events.h" "utility/debugdraw.h" "src/utility/debugdraw.cpp" "utility/script.h" "src/utility/script.cpp" "gameplay/ai.h" "utility/raycaster.h" "src/gameplay/ai.cpp" "utility/ftfont.h" "src/utility/ftfont.cpp" "utility/direction.h")
|
add_executable (YuppleMayham
|
||||||
|
"src/main.cpp"
|
||||||
|
"c:/sdks/glad/src/glad.c"
|
||||||
|
"src/graphics/sprite.cpp"
|
||||||
|
"src/graphics/mesh.cpp"
|
||||||
|
"src/gameplay/entity.cpp"
|
||||||
|
"src/gameplay/gameactor.cpp"
|
||||||
|
"src/graphics/shader.cpp"
|
||||||
|
"src/util.cpp"
|
||||||
|
"src/gameplay/camera.cpp"
|
||||||
|
"src/utility/command.cpp"
|
||||||
|
"src/gameplay/input.cpp"
|
||||||
|
"src/gameplay/weapons/bullet.cpp"
|
||||||
|
"src/gameplay/weapons/bulletmanager.cpp"
|
||||||
|
"src/gameplay/scene.cpp"
|
||||||
|
"src/graphics/texture.cpp"
|
||||||
|
"src/graphics/tile.cpp"
|
||||||
|
"src/utility/resourcemanager.cpp"
|
||||||
|
"src/utility/xmlloader.cpp"
|
||||||
|
"src/gameplay/game.cpp"
|
||||||
|
"src/graphics/instancedraw.cpp"
|
||||||
|
"src/gameplay/map.cpp"
|
||||||
|
"src/gameplay/weapons/weapon.cpp"
|
||||||
|
"src/gameplay/physics.cpp"
|
||||||
|
"src/utility/debugdraw.cpp"
|
||||||
|
"src/utility/script.cpp"
|
||||||
|
"src/gameplay/ai.cpp"
|
||||||
|
"src/utility/ftfont.cpp"
|
||||||
|
"include/graphics/glwindow.h"
|
||||||
|
"include/gameplay/camera.h"
|
||||||
|
"include/utility/mousestate.h"
|
||||||
|
"include/gameplay/weapons/bulletmanager.h"
|
||||||
|
"include/gameplay/scene.h"
|
||||||
|
"include/graphics/tile.h"
|
||||||
|
"include/graphics/texture.h"
|
||||||
|
"include/graphics/tiletype.h"
|
||||||
|
"include/utility/resourcemanager.h"
|
||||||
|
"include/utility/xmlloader.h"
|
||||||
|
"include/gameplay/game.h"
|
||||||
|
"include/gameplay/map.h"
|
||||||
|
"include/gameplay/physics.h"
|
||||||
|
"include/utility/events.h"
|
||||||
|
"include/utility/debugdraw.h"
|
||||||
|
"include/utility/script.h"
|
||||||
|
"include/gameplay/ai.h"
|
||||||
|
"include/utility/raycaster.h"
|
||||||
|
"include/utility/ftfont.h"
|
||||||
|
"include/utility/direction.h"
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_command(TARGET YuppleMayham PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Resources/ $<TARGET_FILE_DIR:YuppleMayham>)
|
add_custom_command(TARGET YuppleMayham PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/Resources/ $<TARGET_FILE_DIR:YuppleMayham>)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
class GameActor;
|
class GameActor;
|
||||||
class Raycaster;
|
class Raycaster;
|
||||||
class Script;
|
class AIScript;
|
||||||
|
|
||||||
enum class AIState {
|
enum class AIState {
|
||||||
Idle,
|
Idle,
|
||||||
|
|
@ -20,7 +20,7 @@ public:
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
void setTarget(const std::shared_ptr<GameActor>& target) { this->target = target; }
|
void setTarget(const std::shared_ptr<GameActor>& target) { this->target = target; }
|
||||||
void attachBehaviourScript(const std::shared_ptr<Script>& behaviour);
|
void attachBehaviourScript(const std::shared_ptr<AIScript>& behaviour);
|
||||||
|
|
||||||
AIState getState() const { return state; }
|
AIState getState() const { return state; }
|
||||||
void setState(AIState state) { this->state = state; }
|
void setState(AIState state) { this->state = state; }
|
||||||
|
|
@ -30,7 +30,7 @@ public:
|
||||||
private:
|
private:
|
||||||
AIState state;
|
AIState state;
|
||||||
std::shared_ptr<Raycaster> raycaster;
|
std::shared_ptr<Raycaster> raycaster;
|
||||||
std::shared_ptr<Script> behaviour;
|
std::shared_ptr<AIScript> behaviour;
|
||||||
std::shared_ptr<GameActor> actor;
|
std::shared_ptr<GameActor> actor;
|
||||||
std::shared_ptr<GameActor> target;
|
std::shared_ptr<GameActor> target;
|
||||||
};
|
};
|
||||||
|
|
@ -12,6 +12,7 @@ class Sprite;
|
||||||
class Shader;
|
class Shader;
|
||||||
class Weapon;
|
class Weapon;
|
||||||
class Script;
|
class Script;
|
||||||
|
class AIScript;
|
||||||
class TileSet;
|
class TileSet;
|
||||||
class SpriteComponent;
|
class SpriteComponent;
|
||||||
|
|
||||||
|
|
@ -28,7 +29,7 @@ public:
|
||||||
std::shared_ptr<Sprite> loadSpriteAnimated (const std::string& path, float frameSize);
|
std::shared_ptr<Sprite> loadSpriteAnimated (const std::string& path, float frameSize);
|
||||||
std::shared_ptr<Sprite> loadSpriteDirAnimated (const std::string& path, float frameSize);
|
std::shared_ptr<Sprite> loadSpriteDirAnimated (const std::string& path, float frameSize);
|
||||||
std::shared_ptr<Sprite> loadSpriteStatic (const std::string& path);
|
std::shared_ptr<Sprite> loadSpriteStatic (const std::string& path);
|
||||||
std::shared_ptr<Script> loadScript(const std::string& path);
|
std::shared_ptr<AIScript> loadAIScript (const std::string& path);
|
||||||
std::shared_ptr<TileSet> loadTileSet (const std::string& path, float frameSize);
|
std::shared_ptr<TileSet> loadTileSet (const std::string& path, float frameSize);
|
||||||
|
|
||||||
std::shared_ptr<Shader> loadShader (const std::string& name, const std::string& vertexPath, const std::string& fragPath);
|
std::shared_ptr<Shader> loadShader (const std::string& name, const std::string& vertexPath, const std::string& fragPath);
|
||||||
|
|
@ -10,7 +10,6 @@ class Script {
|
||||||
public:
|
public:
|
||||||
sol::state lua;
|
sol::state lua;
|
||||||
Script(const std::string& path);
|
Script(const std::string& path);
|
||||||
Script(const Script& script);
|
|
||||||
virtual ~Script() {};
|
virtual ~Script() {};
|
||||||
private:
|
private:
|
||||||
bool loadScript(const std::string& path) {
|
bool loadScript(const std::string& path) {
|
||||||
|
|
@ -22,7 +21,16 @@ private:
|
||||||
}
|
}
|
||||||
return result.valid();
|
return result.valid();
|
||||||
}
|
}
|
||||||
void registerUserTypes();
|
virtual void registerUserTypes() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
class AIScript : public Script {
|
||||||
|
public:
|
||||||
|
AIScript(const std::string& path) : Script(path) { registerUserTypes(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
virtual void registerUserTypes() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _H_SCRIPT_H
|
#endif // _H_SCRIPT_H
|
||||||
|
|
@ -9,7 +9,7 @@ AI::AI(const std::shared_ptr<GameActor>& actor, const std::shared_ptr<Raycaster>
|
||||||
: actor(actor), raycaster(raycaster), state(AIState::Idle)
|
: actor(actor), raycaster(raycaster), state(AIState::Idle)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void AI::attachBehaviourScript(const std::shared_ptr<Script>& behaviour)
|
void AI::attachBehaviourScript(const std::shared_ptr<AIScript>& behaviour)
|
||||||
{
|
{
|
||||||
// passing out instance of raycaster this Ai into our scripting api
|
// passing out instance of raycaster this Ai into our scripting api
|
||||||
// pay special attention each ai script has control of only their own instance of ai!
|
// pay special attention each ai script has control of only their own instance of ai!
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ void Scene::loadDebugShooterScene()
|
||||||
// attach ai
|
// attach ai
|
||||||
if (!entityData.script.empty())
|
if (!entityData.script.empty())
|
||||||
{
|
{
|
||||||
auto behaviourScript = resourceManager->loadScript(entityData.script);
|
auto behaviourScript = resourceManager->loadAIScript(entityData.script);
|
||||||
auto rayCaster = std::make_shared<Raycaster>(40.f, 300.f, map->getCollisionMap(), mapData.tileSize);
|
auto rayCaster = std::make_shared<Raycaster>(40.f, 300.f, map->getCollisionMap(), mapData.tileSize);
|
||||||
auto ai = std::make_shared<AI>(entity, rayCaster);
|
auto ai = std::make_shared<AI>(entity, rayCaster);
|
||||||
ai->setTarget(player);
|
ai->setTarget(player);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "utility/debugdraw.h"
|
#include "utility/debugdraw.h"
|
||||||
|
|
||||||
// TODO: Regular clean up, make this mess readable!
|
// TODO: Regular clean up, make this mess readable!
|
||||||
|
// TODO: Attach script to weapons, create custom shoot scripts, allowing the addition of shotguns and other whacky things
|
||||||
|
|
||||||
Weapon::Weapon(const WeaponData* data, const std::shared_ptr<Shader>& weaponShader, const std::shared_ptr<Shader>& bulletShader, ResourceManager* resourceManager)
|
Weapon::Weapon(const WeaponData* data, const std::shared_ptr<Shader>& weaponShader, const std::shared_ptr<Shader>& bulletShader, ResourceManager* resourceManager)
|
||||||
:
|
:
|
||||||
|
|
@ -44,7 +45,6 @@ void Weapon::addComponent(const std::shared_ptr<Component>& comp) {
|
||||||
components.push_back(comp);
|
components.push_back(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this tangled web of garbage
|
|
||||||
void Weapon::shoot()
|
void Weapon::shoot()
|
||||||
{
|
{
|
||||||
if (wielder)
|
if (wielder)
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ std::shared_ptr<Sprite> ResourceManager::loadSpriteStatic(const std::string& pat
|
||||||
return sprite;
|
return sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Script> ResourceManager::loadScript(const std::string& path)
|
std::shared_ptr<AIScript> ResourceManager::loadAIScript(const std::string& path)
|
||||||
{
|
{
|
||||||
return std::make_shared<Script>(path.c_str());
|
return std::make_shared<AIScript>(path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TileSet> ResourceManager::loadTileSet(const std::string& path, float frameSize)
|
std::shared_ptr<TileSet> ResourceManager::loadTileSet(const std::string& path, float frameSize)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "gameplay/ai.h"
|
#include "gameplay/ai.h"
|
||||||
#include "utility/raycaster.h"
|
#include "utility/raycaster.h"
|
||||||
|
|
||||||
void Script::registerUserTypes()
|
void AIScript::registerUserTypes()
|
||||||
{
|
{
|
||||||
lua.new_usertype<glm::vec3>("vec3",
|
lua.new_usertype<glm::vec3>("vec3",
|
||||||
sol::constructors<glm::vec3(), glm::vec3(float, float, float)>(),
|
sol::constructors<glm::vec3(), glm::vec3(float, float, float)>(),
|
||||||
|
|
@ -46,6 +46,5 @@ void Script::registerUserTypes()
|
||||||
Script::Script(const std::string& path)
|
Script::Script(const std::string& path)
|
||||||
{
|
{
|
||||||
lua.open_libraries(sol::lib::base, sol::lib::math);
|
lua.open_libraries(sol::lib::base, sol::lib::math);
|
||||||
registerUserTypes();
|
|
||||||
loadScript(path);
|
loadScript(path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue