void Ship::fixTargetIndex() { int count = m_targetList.count(); if(count == 0) { // stop the engines m_cycleTargetList = false; m_currentTargetIndex = -1; return; } // the target is now the first unvisited target for(int i = 0; i < count; i++) { Target t = m_targetList.at(i); if(! t.visited) { m_currentTargetIndex = i; return; } } // cycle again if(m_cycleTargetList and count > 1) { m_currentTargetIndex = 0; for(Target & t : m_targetList) t.visited = false; return; } // here, there is nothing to fix removeTargets(); }
void Ship::addToFleet(const uint inFleetId) { // we don't have own targets removeTargets(); if(m_positionType == ShipPositionEnum::SP_TRASH) return; setPositionType(ShipPositionEnum::SP_IN_FLEET); m_fleetId = inFleetId; }
void Ship::setDead() { setPositionType(ShipPositionEnum::SP_TRASH); removeTargets(); if(m_shipType == ShipTypeEnum::ST_FLEET) { for(Ship *s : m_fleetShips) s->setDead(); updateFleet(); } }
void Ship::setOwner(const uint inOwner, const QColor inColor) { m_owner = inOwner; m_color = inColor; m_shape->setBrush(QBrush(Player::colorForOwner(inOwner))); removeTargets(); m_cycleTargetList = false; // if this is a fleet, do the same for all members if(m_shipType == ShipTypeEnum::ST_FLEET) for(Ship *s : m_fleetShips) s->setOwner(inOwner, inColor); }
bool SceneScriptPS10::ClickedOnExit(int exitId) { if (exitId == 1) { if (!Loop_Actor_Walk_To_Waypoint(kActorMcCoy, 6, 12, true, false)) { Game_Flag_Set(14); removeTargets(); Global_Variable_Decrement(kVariablePoliceMazeScore, kPoliceMazePS10TargetCount - Global_Variable_Query(kVariablePoliceMazePS10TargetCounter)); Global_Variable_Set(kVariablePoliceMazePS10TargetCounter, kPoliceMazePS10TargetCount); Set_Enter(kSetPS10_PS11_PS12_PS13, kScenePS11); } return true; } return false; }
void Ship::setTargetFinished() { int numTargets = m_targetList.count(); if(numTargets > 0) { m_targetList[m_currentTargetIndex].visited = true; m_currentTargetIndex++; // next target if(m_currentTargetIndex >= numTargets) { if(m_cycleTargetList) { // start from 0 again m_currentTargetIndex = 0; for(Target & t : m_targetList) t.visited = false; } else { // finished the list removeTargets(); } } } }