From 0a4b7ae08e4379b47367f60d7d9653de2e307788 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Tue, 17 Oct 2023 19:46:16 +0300 Subject: [PATCH] Transport vehicle class --- Assets/Scripts/unitData.lua | 1 + CMakeLists.txt | 4 ++-- gameObjectFactory.cpp | 4 +++- garrisonable.cpp | 10 ++++++++++ garrisonable.h | 24 ++++++++++++++++++++++++ transport.cpp | 8 ++++++++ transport.h | 17 +++++++++++++++++ vehicle.cpp | 4 ++++ vehicle.h | 6 +++++- 9 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 garrisonable.cpp create mode 100644 garrisonable.h create mode 100644 transport.cpp create mode 100644 transport.h diff --git a/Assets/Scripts/unitData.lua b/Assets/Scripts/unitData.lua index cb2493e..233cb74 100644 --- a/Assets/Scripts/unitData.lua +++ b/Assets/Scripts/unitData.lua @@ -36,6 +36,7 @@ units = { cost = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}, range = {15, 15, 14, 14, 13, 13, 12, 12, 15, 25}, rateOfFire = {50, 100, 100, 100, 100, 100, 100}, + garrisonCapacity = {0, 0, 3, 0, 0, 0, 0}, unitCornerPoints = { { diff --git a/CMakeLists.txt b/CMakeLists.txt index 5412af5..9bc9719 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,8 @@ set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceComman set(CORE gameManager.cpp game.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS}) set(PROJECTILES projectile.cpp) set(FX fx.cpp) -set(VEHICLES vehicle.cpp engineer.cpp) -set(UNITS gameObjectFactory.cpp unit.cpp structure.cpp ${VEHICLES}) +set(VEHICLES vehicle.cpp engineer.cpp transport.cpp) +set(UNITS gameObjectFactory.cpp unit.cpp structure.cpp garrisonable.cpp ${VEHICLES}) set(CONTENT player.cpp pathfinder.cpp map.cpp gameObject.cpp gameObjectFrame.h resourceDeposit.cpp ${UNITS} ${PROJECTILES} ${FX}) set(GAME_SRC ${STATES} ${GUI} ${CORE} ${CONTENT} ${UTIL}) diff --git a/gameObjectFactory.cpp b/gameObjectFactory.cpp index 3565b60..715ae4b 100644 --- a/gameObjectFactory.cpp +++ b/gameObjectFactory.cpp @@ -1,7 +1,7 @@ #include "gameObjectFactory.h" #include "player.h" -#include "vehicle.h" #include "engineer.h" +#include "transport.h" #include "projectile.h" #include "resourceDeposit.h" #include "defConfigs.h" @@ -22,6 +22,8 @@ namespace battleship{ switch((UnitClass)unitClass){ case UnitClass::ENGINEER: return new Engineer(player, id, pos, rot); + case UnitClass::TRANSPORT: + return new Transport(player, id, pos, rot); default: return new Vehicle(player, id, pos, rot); } diff --git a/garrisonable.cpp b/garrisonable.cpp new file mode 100644 index 0000000..5ce32d4 --- /dev/null +++ b/garrisonable.cpp @@ -0,0 +1,10 @@ +#include "garrisonable.h" + +#include + +namespace battleship{ + using namespace vb01; + + void Garrisonable::ejectVehicle(int id){ + } +} diff --git a/garrisonable.h b/garrisonable.h new file mode 100644 index 0000000..f4e6e13 --- /dev/null +++ b/garrisonable.h @@ -0,0 +1,24 @@ +#ifndef GARRISONABLE_H +#define GARRISONABLE_H + +#include + +namespace vb01{ + class Node; +} + +namespace battleship{ + class Vehicle; + + class Garrisonable{ + public: + Garrisonable(){} + void ejectVehicle(int); + protected: + int capacity; + std::vector garrisonedVehicles; + std::vector garrisonSlotForegrounds, garrisonSlotBackgrounds; + }; +} + +#endif diff --git a/transport.cpp b/transport.cpp new file mode 100644 index 0000000..8fa2651 --- /dev/null +++ b/transport.cpp @@ -0,0 +1,8 @@ +#include "transport.h" +#include "player.h" + +namespace battleship{ + using namespace vb01; + + Transport::Transport(Player *player, int id, Vector3 pos, Quaternion rot) : Vehicle(player, id, pos, rot), Garrisonable(){} +} diff --git a/transport.h b/transport.h new file mode 100644 index 0000000..747ba08 --- /dev/null +++ b/transport.h @@ -0,0 +1,17 @@ +#ifndef TRANSPORT_H +#define TRANSPORT_H + +#include "vehicle.h" +#include "garrisonable.h" + +namespace battleship{ + class Player; + + class Transport : public Vehicle, Garrisonable{ + public: + Transport(Player*, int, vb01::Vector3, vb01::Quaternion); + private: + }; +} + +#endif diff --git a/vehicle.cpp b/vehicle.cpp index d95f080..1547e47 100644 --- a/vehicle.cpp +++ b/vehicle.cpp @@ -10,6 +10,7 @@ #include "vehicle.h" #include "pathfinder.h" +#include "garrisonable.h" #include "map.h" using namespace gameBase; @@ -151,6 +152,9 @@ namespace battleship{ removeOrder(0); } + void Vehicle::garrison(Garrisonable *garrisonable){ + } + //TODO add hover unit type //TODO cleanup debug pathpoint removal void Vehicle::preparePathpoints(Order order){ diff --git a/vehicle.h b/vehicle.h index d099c9a..7c0339c 100644 --- a/vehicle.h +++ b/vehicle.h @@ -8,13 +8,17 @@ namespace vb01{ } namespace battleship{ + class Garrisonable; + class Vehicle : public Unit{ public: Vehicle(Player*, int, vb01::Vector3, vb01::Quaternion); ~Vehicle(); void move(Order); + void garrison(Garrisonable*); + bool isGarrisoned(){return garrisoned;} private: - bool pursuingTarget = false; + bool pursuingTarget = false, garrisoned = false; int patrolPointId = 0; float speed, maxTurnAngle, anglePrecision; vb01::Material *debugMat = nullptr;