mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
code refactoring + test map
This commit is contained in:
@@ -9,23 +9,38 @@ numPlayers = 1,
|
||||
numSpawnPoints = 1,
|
||||
spawnPoints = {
|
||||
{x = 0.000000, y = 0.000000, z = 0.000000},
|
||||
{x = 170.000000, y = 0.000000, z = -170.000000},
|
||||
{x = -170.000000, y = 0.000000, z = 170.000000},
|
||||
},
|
||||
players = {
|
||||
{
|
||||
resourceDeposits = {
|
||||
{id = 0, pos = {x = -150.000000, y = 0.000000, z = 150.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, initAmmount = 1000},
|
||||
},
|
||||
units = {
|
||||
{id = UnitId.WAR_MECH, pos = {x = 100.000000, y = 0.000000, z = 10.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
}
|
||||
},
|
||||
{
|
||||
resourceDeposits = {},
|
||||
units = {
|
||||
{id = UnitId.ENGINEER, pos = {x = -170.000000, y = 0.000000, z = 150.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
}
|
||||
}
|
||||
{
|
||||
resourceDeposits = {
|
||||
{id = 0, pos = {x = -150.000000, y = 0.000000, z = 150.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, initAmmount = 1000},
|
||||
},
|
||||
units = {
|
||||
{id = UnitId.WAR_MECH, pos = {x = -170.000000, y = 0.000000, z = 150.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.RESOURCE_ROVER, pos = {x = -170.000000, y = 0.000000, z = 180.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.TRADE_CENTER, pos = {x = -180.000000, y = 0.000000, z = 150.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
{id = UnitId.LAB, pos = {x = -200.000000, y = 0.000000, z = 140.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
{id = UnitId.REFINERY, pos = {x = -170.000000, y = 0.000000, z = 120.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
}
|
||||
},
|
||||
{
|
||||
resourceDeposits = {},
|
||||
units = {
|
||||
{id = UnitId.POINT_DEFENSE, pos = {x = 100.000000, y = 0.000000, z = 10.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
{id = UnitId.RESOURCE_ROVER, pos = {x = 100.000000, y = 0.000000, z = -10.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}},
|
||||
{id = UnitId.TRADE_CENTER, pos = {x = 130.000000, y = 0.000000, z = 10.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
{id = UnitId.LAB, pos = {x = 100.000000, y = 0.000000, z = 20.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
{id = UnitId.REFINERY, pos = {x = 100.000000, y = 0.000000, z = 50.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
}
|
||||
},
|
||||
{
|
||||
resourceDeposits = {},
|
||||
units = {
|
||||
{id = UnitId.LAND_FACTORY, pos = {x = 170.000000, y = 0.000000, z = -170.000000}, rot = {w = 1.000000, x = 0.000000, y = 0.000000, z = 0.000000}, buildStatus = 100},
|
||||
}
|
||||
},
|
||||
},
|
||||
numCells = 3969,
|
||||
cells = {
|
||||
|
||||
+5
-16
@@ -37,7 +37,7 @@ namespace battleship{
|
||||
loadRate = unitTable["loadRate"]; loadRate += game->calcAbilFromTech(Ability::Type::LOAD_RATE, currTechs, (int)GameObject::type, id);
|
||||
}
|
||||
|
||||
void ResourceRover::handleTransfer(Structure *targStruct, float minDist, bool loadResource){
|
||||
void ResourceRover::loadResources(Structure *targStruct, float minDist, bool loadResource){
|
||||
bool closeEnough = (pos.getDistanceFrom(targStruct->getPos()) <= minDist);
|
||||
if(!closeEnough) return;
|
||||
|
||||
@@ -94,19 +94,6 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceRover::transfer(Order order, bool loadResource){
|
||||
float minDist = .5 * Map::getSingleton()->getCellSize().x;
|
||||
|
||||
if(!pathPoints.empty())
|
||||
navigate(minDist);
|
||||
else
|
||||
handleTransfer((Structure*)order.targets[0].unit, minDist, loadResource);
|
||||
}
|
||||
|
||||
void ResourceRover::load(Order order){transfer(order, true);}
|
||||
|
||||
void ResourceRover::unload(Order order){transfer(order, false);}
|
||||
|
||||
//TODO equate rover load and extractor draw rates
|
||||
void ResourceRover::collectRefineds(Order order, float minDist){
|
||||
vector<Unit*> units = player->getUnits();
|
||||
@@ -153,13 +140,15 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
|
||||
void ResourceRover::supply(Order order){
|
||||
void ResourceRover::handleResources(Order order){
|
||||
float minDist = .5 * Map::getSingleton()->getCellSize().x;
|
||||
|
||||
if(!pathPoints.empty())
|
||||
navigate(minDist);
|
||||
else
|
||||
else if(order.type == Order::TYPE::SUPPLY)
|
||||
collectRefineds(order, minDist);
|
||||
else
|
||||
loadResources((Structure*)order.targets[0].unit, minDist, order.type == Order::TYPE::LOAD);
|
||||
}
|
||||
|
||||
void ResourceRover::update(){
|
||||
|
||||
+2
-5
@@ -22,11 +22,8 @@ namespace battleship{
|
||||
private:
|
||||
void initProperties();
|
||||
void collectRefineds(Order, float);
|
||||
void supply(Order);
|
||||
void handleTransfer(Structure*, float, bool);
|
||||
void transfer(Order, bool);
|
||||
void load(Order);
|
||||
void unload(Order);
|
||||
void loadResources(Structure*, float, bool);
|
||||
void handleResources(Order);
|
||||
Unit* getClosestUnit(std::vector<Structure*>);
|
||||
|
||||
vb01::s64 lastLoadTime = 0;
|
||||
|
||||
@@ -626,14 +626,11 @@ namespace battleship{
|
||||
case Order::TYPE::LAUNCH:
|
||||
launch(order);
|
||||
break;
|
||||
case Order::TYPE::SUPPLY:
|
||||
supply(order);
|
||||
break;
|
||||
case Order::TYPE::LOAD:
|
||||
load(order);
|
||||
break;
|
||||
case Order::TYPE::SUPPLY:
|
||||
case Order::TYPE::UNLOAD:
|
||||
unload(order);
|
||||
handleResources(order);
|
||||
break;
|
||||
case Order::TYPE::HACK:
|
||||
hack(order);
|
||||
|
||||
@@ -209,9 +209,7 @@ namespace battleship{
|
||||
virtual void move(Order){}
|
||||
virtual void patrol(Order){}
|
||||
virtual void launch(Order);
|
||||
virtual void supply(Order){}
|
||||
virtual void load(Order){}
|
||||
virtual void unload(Order){}
|
||||
virtual void handleResources(Order){}
|
||||
virtual void hack(Order){}
|
||||
float calculateRotation(vb01::Vector3, float, float);
|
||||
void removeBar(vb01::Node*);
|
||||
|
||||
Reference in New Issue
Block a user