#include <src/Misc/SWTypes.h>
List of all members.
Constructor & Destructor Documentation
ChronoWarpStateMachine::ChronoWarpStateMachine |
( |
int |
Duration, |
|
|
CellStruct |
XY, |
|
|
SuperClass * |
pSuper, |
|
|
NewSWType * |
pSWType, |
|
|
DynamicVectorClass< ChronoWarpContainer > * |
Buildings |
|
) |
| [inline] |
Member Function Documentation
void ChronoWarpStateMachine::PointerGotInvalid |
( |
void * |
ptr | ) |
[virtual] |
void ChronoWarpStateMachine::Update |
( |
| ) |
[virtual] |
Reimplemented from SWStateMachine.
{
int passed = this->TimePassed();
if(passed == 1) {
for(int i=0; i<this->Buildings.Count; ++i) {
ChronoWarpContainer Container = this->Buildings.GetItem(i);
if(Container.pBld) {
Container.pBld->SetLayer(Layer::Ground);
}
}
} else if(passed == this->Duration - 1) {
DynamicVectorClass<ChronoWarpContainer> buildings;
for(int i=0; i<this->Buildings.Count; ++i) {
buildings.AddItem(this->Buildings.GetItem(i));
}
this->Buildings.Clear();
for(int i=0; i<buildings.Count; ++i) {
ChronoWarpContainer* pContainer = &buildings.Items[i];
pContainer->pBld->Remove();
pContainer->pBld->ActuallyPlacedOnMap = false;
}
for(int i=0; i<buildings.Count; ++i) {
ChronoWarpContainer pContainer = buildings.GetItem(i);
if(BuildingClass* pBld = pContainer.pBld) {
if(!pBld->TemporalTargetingMe) {
bool success = false;
int count = CellSpread::NumCells(10);
int idx = 0;
do {
CellStruct cellNew = CellSpread::GetCell(idx) + pContainer.target;
CellClass* pNewCell = MapClass::Instance->GetCellAt(&cellNew);
CoordStruct coordsNew;
pNewCell->GetCoordsWithBridge(&coordsNew);
if(pBld->Type->CanCreateHere(&cellNew, 0)) {
if(pBld->Put(&coordsNew, Direction::North)) {
success = true;
break;
}
}
++idx;
} while(pContainer.isVehicle && (idx<count));
if(!success) {
++Unsorted::IKnowWhatImDoing;
pBld->Put(&pContainer.origin, Direction::North);
pBld->Place(false);
--Unsorted::IKnowWhatImDoing;
}
pBld->BeingWarpedOut = false;
pBld->Owner->PowerBlackout = true;
pBld->Owner->ShouldRecheckTechTree = true;
pBld->EnableTemporal();
pBld->SetLayer(Layer::Ground);
BuildingExt::ExtData* pBldExt = BuildingExt::ExtMap.Find(pBld);
pBldExt->AboutToChronoshift = false;
if(!success) {
if(SWTypeExt::ExtData *pExt = SWTypeExt::ExtMap.Find(this->Super->Type)) {
if(pContainer.isVehicle || pExt->Chronosphere_BlowUnplaceable.Get()) {
int damage = pBld->Type->Strength;
pBld->ReceiveDamage(&damage, 0,
RulesClass::Instance->C4Warhead, NULL, TRUE, TRUE, this->Super->Owner);
}
}
}
}
}
}
} else if(passed == this->Duration) {
Super->Owner->PowerBlackout = true;
Super->Owner->ShouldRecheckTechTree = true;
Super->Owner->RadarBlackout = true;
}
}
Member Data Documentation
The documentation for this class was generated from the following files: