mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
aligning placed units' height with the surface
This commit is contained in:
@@ -513,14 +513,21 @@ namespace battleship{
|
||||
|
||||
//TODO select only the closest cells based on unit size
|
||||
void Unit::placeAt(Vector3 p){
|
||||
Map *map = Map::getSingleton();
|
||||
|
||||
if(type == UnitType::LAND){
|
||||
vector<RayCaster::CollisionResult> res = RayCaster::cast(Vector3(p.x, 100, p.z), -Vector3::VEC_J, vector<Node*>{map->getNodeParent()->getChild(0)}, 0, 20);
|
||||
p.y = res[0].pos.y;
|
||||
}
|
||||
|
||||
ActiveGameState *activeState = (ActiveGameState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::ACTIVE_STATE);
|
||||
|
||||
//check twice in case the unit is warped over a long distance
|
||||
if(activeState) Map::getSingleton()->blockCells(this);
|
||||
if(activeState) map->blockCells(this);
|
||||
GameObject::placeAt(p);
|
||||
|
||||
if(activeState){
|
||||
Map::getSingleton()->blockCells(this);
|
||||
map->blockCells(this);
|
||||
|
||||
if(activeState->getPlayer())
|
||||
Map::Minimap::getSingleton()->updateImage();
|
||||
|
||||
+1
-1
@@ -255,7 +255,7 @@ namespace battleship{
|
||||
|
||||
int dest = map->getCellId(destPos);
|
||||
|
||||
if(type != UnitType::UNDERWATER && fabs(destPos.y - cells[dest].pos.y) > .1) return;
|
||||
if(type != UnitType::UNDERWATER && type == UnitType::SEA_LEVEL && fabs(destPos.y - cells[dest].pos.y) > .1) return;
|
||||
|
||||
if(cells[dest].blockedBy){
|
||||
vector<int> surrCellIds = map->getSurroundingCells(cells[dest].pos, 1);
|
||||
|
||||
Reference in New Issue
Block a user