#include <src/Misc/SWTypes.h>
List of all members.
Constructor & Destructor Documentation
UnitDeliveryStateMachine::UnitDeliveryStateMachine |
( |
int |
Duration, |
|
|
CellStruct |
XY, |
|
|
SuperClass * |
pSuper, |
|
|
NewSWType * |
pSWType |
|
) |
| [inline] |
Member Function Documentation
void UnitDeliveryStateMachine::PlaceUnits |
( |
| ) |
|
{
int unitIdx = 0;
SWTypeExt::ExtData *pData = this->FindExtData();
if(!pData) {
return;
}
while(unitIdx < pData->SW_Deliverables.Count) {
TechnoTypeClass * Type = pData->SW_Deliverables[unitIdx];
TechnoClass * Item = generic_cast<TechnoClass *>(Type->CreateObject(this->Super->Owner));
BuildingClass * ItemBuilding = specific_cast<BuildingClass *>(Item);
if(ItemBuilding && pData->SW_DeliverBuildups) {
ItemBuilding->QueueMission(mission_Construction, false);
}
int cellIdx = 0;
bool Placed = false;
do {
CellStruct tmpCell = CellSpread::GetCell(cellIdx) + this->Coords;
if(MapClass::Instance->CellExists(&tmpCell)) {
CellClass *cell = MapClass::Instance->GetCellAt(&tmpCell);
CoordStruct XYZ;
cell->GetCoordsWithBridge(&XYZ);
bool validCell = true;
if(cell->OverlayTypeIndex != -1) {
OverlayTypeClass *Overlay = OverlayTypeClass::Array->GetItem(cell->OverlayTypeIndex);
validCell = !Overlay->Wall && !Overlay->IsARock && !Overlay->IsRubble;
}
if(AircraftClass * ItemAircraft = specific_cast<AircraftClass *>(Item)) {
validCell &= !cell->GetContent() && !cell->Tile_Is_Cliff()
&& !cell->Tile_Is_DestroyableCliff() && !cell->Tile_Is_Shore()
&& !cell->Tile_Is_Water() && !cell->ContainsBridge();
}
if(Type->Naval && validCell) {
validCell = (!cell->ContainsBridge() && cell->LandType != lt_Road)
|| Type->SpeedType == st_Hover;
}
if(validCell) {
Item->OnBridge = cell->ContainsBridge();
if((Placed = Item->Put(&XYZ, (cellIdx & 7))) == true) {
if(ItemBuilding) {
if (pData->SW_DeliverBuildups) {
ItemBuilding->UpdateOwner(this->Super->Owner);
ItemBuilding->unknown_bool_6DD = 1;
}
} else {
if(Type->BalloonHover || Type->JumpJet) {
Item->Scatter(0xB1CFE8, 1, 0);
}
}
}
}
}
++cellIdx;
if(cellIdx >= 100) {
cellIdx = 0;
if(!Placed) {
Item->UnInit();
}
break;
}
} while(!Placed);
++unitIdx;
}
}
void UnitDeliveryStateMachine::Update |
( |
| ) |
[virtual] |
The documentation for this class was generated from the following files: