mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
Merge pull request #173 from devZoGok/bf-107-unpause-stats
Bf 107 unpause stats
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES})
|
||||
set(STATES activeGameState.cpp inGameAppState.cpp guiAppState.cpp mapEditorAppState.cpp)
|
||||
set(UTIL util.cpp binds.h)
|
||||
set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
|
||||
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp)
|
||||
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp toggleDebugCommand.cpp)
|
||||
set(CORE gameManager.cpp game.cpp fxManager.cpp defConfigs.cpp ${CONSOLE} ${CONTROLLERS})
|
||||
set(PROJECTILES projectile.cpp cruiseMissile.cpp)
|
||||
set(VEHICLES vehicle.cpp engineer.cpp resourceRover.cpp)
|
||||
|
||||
+19
-20
@@ -6,29 +6,28 @@
|
||||
namespace battleship{
|
||||
using namespace std;
|
||||
|
||||
vector<string> AbstractCommand::explodeString(string commandStr){
|
||||
vector<int> spaceIds;
|
||||
vector<string> fullCommand;
|
||||
|
||||
for(int i = 0; i < commandStr.length(); i++)
|
||||
if(commandStr[i] == ' ')
|
||||
spaceIds.push_back(i);
|
||||
|
||||
fullCommand.push_back(commandStr.substr(0, spaceIds[0]));
|
||||
|
||||
for(int i = 0; i < spaceIds.size(); i++){
|
||||
bool lastSpace = (i == spaceIds.size() - 1);
|
||||
string argument = commandStr.substr(spaceIds[i] + 1, lastSpace ? string::npos : spaceIds[i + 1] - spaceIds[i] - 1);
|
||||
fullCommand.push_back(argument);
|
||||
}
|
||||
|
||||
return fullCommand;
|
||||
}
|
||||
|
||||
void AbstractCommand::handle(){
|
||||
if(cmdStr.find(" ") == -1)
|
||||
return;
|
||||
|
||||
arguments = explodeString(cmdStr);
|
||||
vector<int> spaceIds;
|
||||
arguments.clear();
|
||||
|
||||
for(int i = 0; i < cmdStr.length(); i++)
|
||||
if(cmdStr[i] == ' ')
|
||||
spaceIds.push_back(i);
|
||||
|
||||
arguments.push_back(cmdStr.substr(0, spaceIds[0]));
|
||||
|
||||
for(int i = 0; i < spaceIds.size(); i++){
|
||||
bool lastSpace = (i == spaceIds.size() - 1);
|
||||
string argument = cmdStr.substr(spaceIds[i] + 1, lastSpace ? string::npos : spaceIds[i + 1] - spaceIds[i] - 1);
|
||||
arguments.push_back(argument);
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractCommand::execute(){
|
||||
handle();
|
||||
validate();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -8,14 +8,12 @@ namespace battleship{
|
||||
class AbstractCommand{
|
||||
protected:
|
||||
AbstractCommand(std::string str) : cmdStr(str){}
|
||||
virtual void execute(){}
|
||||
virtual void validate(){}
|
||||
virtual void handle();
|
||||
virtual void validate(){}
|
||||
virtual void execute();
|
||||
|
||||
std::string cmdStr;
|
||||
std::vector<std::string> arguments;
|
||||
private:
|
||||
std::vector<std::string> explodeString(std::string);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,10 @@ namespace battleship{
|
||||
resourceAmmount = atoi(arguments[2].c_str());
|
||||
}
|
||||
|
||||
void AddResourceCommand::addResource(){
|
||||
void AddResourceCommand::execute(){
|
||||
AbstractCommand::execute();
|
||||
|
||||
Player *player = Game::getSingleton()->getPlayer(playerId);
|
||||
player->updateResource(ResourceType(resourceId), resourceAmmount, true);
|
||||
}
|
||||
|
||||
void AddResourceCommand::execute(){
|
||||
AbstractCommand::handle();
|
||||
validate();
|
||||
addResource();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace battleship{
|
||||
void execute();
|
||||
private:
|
||||
void validate();
|
||||
void addResource();
|
||||
|
||||
int playerId, resourceId, resourceAmmount;
|
||||
};
|
||||
|
||||
@@ -30,13 +30,8 @@ namespace battleship{
|
||||
return;
|
||||
}
|
||||
|
||||
void AddTechnologyCommand::addTechnology(){
|
||||
void AddTechnologyCommand::execute(){
|
||||
AbstractCommand::execute();
|
||||
Game::getSingleton()->getPlayer(playerId)->addTechnology(techId);
|
||||
}
|
||||
|
||||
void AddTechnologyCommand::execute(){
|
||||
AbstractCommand::handle();
|
||||
validate();
|
||||
addTechnology();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace battleship{
|
||||
void execute();
|
||||
private:
|
||||
void validate();
|
||||
void addTechnology();
|
||||
|
||||
int playerId, techId;
|
||||
};
|
||||
|
||||
+3
-7
@@ -54,14 +54,10 @@ namespace battleship{
|
||||
return;
|
||||
}
|
||||
|
||||
void AddUnitCommand::addUnit(){
|
||||
void AddUnitCommand::execute(){
|
||||
AbstractCommand::execute();
|
||||
|
||||
Player* player = Game::getSingleton()->getPlayer(playerId);
|
||||
player->addUnit(GameObjectFactory::createUnit(player, unitId, pos, rot, 100));
|
||||
}
|
||||
|
||||
void AddUnitCommand::execute(){
|
||||
AbstractCommand::handle();
|
||||
validate();
|
||||
addUnit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ namespace battleship{
|
||||
bool posEnabled, rotEnabled;
|
||||
vb01::Vector3 pos = vb01::Vector3::VEC_ZERO;
|
||||
vb01::Quaternion rot = vb01::Quaternion::QUAT_W;
|
||||
|
||||
void addUnit();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -2,13 +2,14 @@
|
||||
#include "addUnitCommand.h"
|
||||
#include "addResourceCommand.h"
|
||||
#include "addTechnologyCommand.h"
|
||||
#include "toggleDebugCommand.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace battleship{
|
||||
void Console::execute(string cmdStr) {
|
||||
int space = cmdStr.find(" ");
|
||||
string cmdName, argsStr;
|
||||
string cmdName = cmdStr, argsStr = "";
|
||||
|
||||
if(space != -1){
|
||||
cmdName = cmdStr.substr(0, space);
|
||||
@@ -21,5 +22,7 @@ namespace battleship{
|
||||
AddResourceCommand(argsStr).execute();
|
||||
else if(cmdName == "add-technology")
|
||||
AddTechnologyCommand(argsStr).execute();
|
||||
else if(cmdName == "toggle-debug")
|
||||
ToggleDebugCommand(argsStr).execute();
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
Submodule external/vb01 updated: e39f9e358d...23304a10e9
@@ -118,22 +118,24 @@ namespace battleship{
|
||||
AssetManager::getSingleton()->load(gm->getPath() + gop, true);
|
||||
AssetManager::getSingleton()->load(gm->getPath() + vfxp, true);
|
||||
|
||||
vector<GameObject*> gameObjs;
|
||||
if(debug){
|
||||
vector<GameObject*> gameObjs;
|
||||
|
||||
for(Player *pl : Game::getSingleton()->getPlayers()){
|
||||
for(Unit *u : pl->getUnits())
|
||||
gameObjs.push_back((GameObject*)u);
|
||||
for(Player *pl : Game::getSingleton()->getPlayers()){
|
||||
for(Unit *u : pl->getUnits())
|
||||
gameObjs.push_back((GameObject*)u);
|
||||
|
||||
for(Projectile *proj : pl->getProjectiles())
|
||||
gameObjs.push_back((GameObject*)proj);
|
||||
for(Projectile *proj : pl->getProjectiles())
|
||||
gameObjs.push_back((GameObject*)proj);
|
||||
|
||||
for(ResourceDeposit *dep : pl->getResourceDeposits())
|
||||
gameObjs.push_back((GameObject*)dep);
|
||||
for(ResourceDeposit *dep : pl->getResourceDeposits())
|
||||
gameObjs.push_back((GameObject*)dep);
|
||||
}
|
||||
|
||||
for(GameObject *obj : gameObjs)
|
||||
obj->reinit();
|
||||
}
|
||||
|
||||
for(GameObject *obj : gameObjs)
|
||||
obj->reinit();
|
||||
|
||||
gm->getStateManager()->attachAppState(activeState);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@ namespace battleship{
|
||||
float calcAbilFromTech(Ability::Type, std::vector<int>, int, int);
|
||||
bool isUnitUnlocked(std::vector<int>, int);
|
||||
std::vector<TradeOffer*> findTradeOffers(Player*, Player*);
|
||||
inline void setDebug(bool d){this->debug = d;}
|
||||
inline void addTradeOffer(TradeOffer *to){tradeOffers.push_back(to);}
|
||||
inline void addPlayer(Player *pl){players.push_back(pl);}
|
||||
inline bool isDebug(){return debug;}
|
||||
inline std::vector<Player*>& getPlayers(){return players;}
|
||||
inline Player* getPlayer(int id){return players[id];}
|
||||
inline int getNumPlayers(){return players.size();}
|
||||
@@ -41,7 +43,7 @@ namespace battleship{
|
||||
void endGame(bool);
|
||||
std::vector<int> parseTechTable(int, std::string, std::string, std::string);
|
||||
|
||||
bool paused = false, ended = false;
|
||||
bool paused = false, ended = false, debug = false;
|
||||
std::vector<Technology> technologies;
|
||||
std::vector<Ability> abilities;
|
||||
std::vector<Player*> players;
|
||||
|
||||
+12
-10
@@ -51,16 +51,18 @@ namespace battleship{
|
||||
|
||||
//TODO remove neccessity to create a material for an invisible mesh
|
||||
void GameObject::initHitbox(){
|
||||
Box *box = new Box(Vector3(width, height, length));
|
||||
box->setWireframe(true);
|
||||
|
||||
Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture");
|
||||
mat->addBoolUniform("texturingEnabled", false);
|
||||
mat->addBoolUniform("lightingEnabled", false);
|
||||
mat->addVec4Uniform("diffuseColor", Vector4(1, 1, 1, 1));
|
||||
|
||||
Box *box = new Box(Vector3(width, height, length));
|
||||
box->setWireframe(true);
|
||||
box->setMaterial(mat);
|
||||
|
||||
sol::table gameObjTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
||||
sol::table offsetPosTable = gameObjTable["hitboxOffset"];
|
||||
|
||||
hitbox = new Node(Vector3(offsetPosTable["x"], offsetPosTable["y"], offsetPosTable["z"]));
|
||||
hitbox->attachMesh(box);
|
||||
hitbox->setVisible(true);
|
||||
@@ -68,7 +70,6 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void GameObject::destroyHitbox(){
|
||||
hitbox->dettachMesh(0);
|
||||
model->dettachChild(hitbox);
|
||||
delete hitbox;
|
||||
}
|
||||
@@ -81,6 +82,9 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void GameObject::destroyModel(){
|
||||
if(model->getMaterial())
|
||||
delete model->getMaterial();
|
||||
|
||||
Root::getSingleton()->getRootNode()->dettachChild(model);
|
||||
delete model;
|
||||
}
|
||||
@@ -88,19 +92,17 @@ namespace battleship{
|
||||
//TODO improve DEFAULT_TEXTURE handling
|
||||
void GameObject::initModel(bool textured){
|
||||
sol::table gameObjTable = generateView()[GameObject::getGameObjTableName()][id + 1];
|
||||
string basePath = gameObjTable["basePath"];
|
||||
string meshPath = gameObjTable["meshPath"];
|
||||
|
||||
string basePath = gameObjTable["basePath"], meshPath = gameObjTable["meshPath"];
|
||||
model = new Model(basePath + meshPath);
|
||||
Root *root = Root::getSingleton();
|
||||
string libPath = root->getLibPath();
|
||||
|
||||
Material *mat = new Material(libPath + "texture");
|
||||
Root *root = Root::getSingleton();
|
||||
Material *mat = new Material(root->getLibPath() + "texture");
|
||||
|
||||
if(textured){
|
||||
string albedoPath = gameObjTable["albedoPath"].get_or(configData::DEFAULT_TEXTURE);
|
||||
string f[]{albedoPath == configData::DEFAULT_TEXTURE ? GameManager::getSingleton()->getPath() + albedoPath : basePath + albedoPath};
|
||||
Texture *diffuseTexture = new Texture(f, 1, false);
|
||||
|
||||
mat->addBoolUniform("texturingEnabled", true);
|
||||
mat->addBoolUniform("lightingEnabled", true);
|
||||
mat->addBoolUniform("constLightingEnabled", false);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "toggleDebugCommand.h"
|
||||
#include "game.h"
|
||||
|
||||
namespace battleship{
|
||||
void ToggleDebugCommand::validate(){
|
||||
if(!arguments.empty()) return;
|
||||
}
|
||||
|
||||
void ToggleDebugCommand::execute(){
|
||||
AbstractCommand::execute();
|
||||
|
||||
Game *game = Game::getSingleton();
|
||||
game->setDebug(!game->isDebug());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef TOGGLE_DEBUG_COMMAND_H
|
||||
#define TOGGLE_DEBUG_COMMAND_H
|
||||
|
||||
#include "abstractCommand.h"
|
||||
|
||||
namespace battleship{
|
||||
class ToggleDebugCommand : public AbstractCommand{
|
||||
public:
|
||||
ToggleDebugCommand(std::string str) : AbstractCommand(str){}
|
||||
void validate();
|
||||
void execute();
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -322,9 +322,11 @@ namespace battleship{
|
||||
vector<int> currTechs = player->getTechnologies();
|
||||
|
||||
string name = unitTable["name"];
|
||||
health = unitTable["health"]; health += game->calcAbilFromTech(Ability::Type::HEALTH, currTechs, (int)GameObject::type, id);
|
||||
vehicle = unitTable["isVehicle"];
|
||||
maxHealth = health;
|
||||
health += game->calcAbilFromTech(Ability::Type::HEALTH, currTechs, (int)GameObject::type, id);
|
||||
maxHealth = unitTable["health"];
|
||||
|
||||
if(health == 0) health = maxHealth;
|
||||
|
||||
lineOfSight = unitTable["lineOfSight"]; lineOfSight += game->calcAbilFromTech(Ability::Type::LINE_OF_SIGHT, currTechs, (int)GameObject::type, id);
|
||||
unitClass = (UnitClass)unitTable["unitClass"];
|
||||
@@ -441,6 +443,9 @@ namespace battleship{
|
||||
}
|
||||
|
||||
void Unit::reinit(){
|
||||
if(losLightNode)
|
||||
destroyLosLight();
|
||||
|
||||
destroyWeapons();
|
||||
destroyHitbox();
|
||||
destroyModel();
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace battleship{
|
||||
UnitType type;
|
||||
std::vector<Order> orders;
|
||||
std::string guiScreen = "";
|
||||
int health, maxHealth, playerId, lenHpBar = 200;
|
||||
int health = 0, maxHealth, playerId, lenHpBar = 200;
|
||||
vb01::s64 orderLineDispTime = 0, lastFireTime = 0;
|
||||
float lineOfSight;
|
||||
std::vector<Armor> armorTypes;
|
||||
|
||||
@@ -94,6 +94,11 @@ namespace battleship{
|
||||
garrisonCategory = unitTable["garrisonCategory"];
|
||||
}
|
||||
|
||||
void Vehicle::reinit(){
|
||||
Unit::reinit();
|
||||
initProperties();
|
||||
}
|
||||
|
||||
void Vehicle::navigate(float destOffset){
|
||||
Vector3 hypVec = (pathPoints[0] - pos);
|
||||
float hypAngle = hypVec.norm().getAngleBetween(upVec) - PI / 2;
|
||||
|
||||
Reference in New Issue
Block a user