//----------------------------------------------------------------------------- // Copyright(c), HL Rally: Source, 2004, All rights reserved. // The contents of this file may only be used / distributed in accordance // with the conditions listed in the supplied license, or with written // permission of the respective authors listed. //----------------------------------------------------------------------------- #include "cbase.h" #include "CheckpointManagerABC.h" #include "EntityInfoCheckpoint.h" #include "PlayerRally.h" // Disable warnings for assignments in conditionals #pragma warning (disable : 4706) template<> CCheckpointManagerABC *CSingletonABC::ms_pInstance = NULL; /** * Constructor */ CCheckpointManagerABC::CCheckpointManagerABC() { } /** * Destructor */ CCheckpointManagerABC::~CCheckpointManagerABC() { } /** * Resets all checkpoints to erase touch information */ void CCheckpointManagerABC::ResetAllCheckpoints() { CEntityInfoCheckpoint *pEntity = NULL; while(pEntity = (CEntityInfoCheckpoint *)gEntList.FindEntityByClassname(pEntity, "info_checkpoint")) pEntity->Reset(); } /** * Returns the first checkpoint in the map * @todo Implement */ CEntityInfoCheckpoint *CCheckpointManagerABC::GetCheckpointFirst() { return NULL; } /** * Returns the last checkpoint in the map */ CEntityInfoCheckpoint *CCheckpointManagerABC::GetCheckpointLast() { CEntityInfoCheckpoint *pEntity = NULL; CEntityInfoCheckpoint *pResult = NULL; while(pEntity = (CEntityInfoCheckpoint *)gEntList.FindEntityByClassname(pEntity, "info_checkpoint")) { if(!pResult || pEntity->GetTouchOrder() > pResult->GetTouchOrder()) pResult = pEntity; } return pResult; } /** * Returns the checkpoint at a numbered index */ CEntityInfoCheckpoint *CCheckpointManagerABC::GetCheckpointAtTouchOrder(int iTouchOrder) { CEntityInfoCheckpoint *pEntity = NULL; while(pEntity = (CEntityInfoCheckpoint *)gEntList.FindEntityByClassname(pEntity, "info_checkpoint")) { if(pEntity->GetTouchOrder() == iTouchOrder) return pEntity; } return NULL; } /** * Returns the checkpoint before a numbered index */ CEntityInfoCheckpoint *CCheckpointManagerABC::GetCheckpointBeforeTouchOrder(int iTouchOrder) { CEntityInfoCheckpoint *pEntity = NULL; CEntityInfoCheckpoint *pResult = NULL; while(pEntity = (CEntityInfoCheckpoint *)gEntList.FindEntityByClassname(pEntity, "info_checkpoint")) { if(pEntity->GetTouchOrder() < iTouchOrder && (!pResult || pEntity->GetTouchOrder() > pResult->GetTouchOrder())) pResult = pEntity; } return pResult; } /** * Returns the checkpoint after a numbered index */ CEntityInfoCheckpoint *CCheckpointManagerABC::GetCheckpointAfterTouchOrder(int iTouchOrder) { CEntityInfoCheckpoint *pEntity = NULL; CEntityInfoCheckpoint *pResult = NULL; while(pEntity = (CEntityInfoCheckpoint *)gEntList.FindEntityByClassname(pEntity, "info_checkpoint")) { if(pEntity->GetTouchOrder() > iTouchOrder && (!pResult || pEntity->GetTouchOrder() < pResult->GetTouchOrder())) pResult = pEntity; } return pResult; } void CCheckpointManagerABC::CheckpointTouchCorrect(CEntityInfoCheckpoint *pCheckpoint, CPlayerRally *pPlayer) { ClientPrint(pPlayer, HUD_PRINTCENTER, "Checkpoint!"); pPlayer->EmitSound("HLRally.CheckpointCorrect"); pPlayer->SetLastCheckpointTouched(pCheckpoint); } void CCheckpointManagerABC::CheckpointTouchWrong(CEntityInfoCheckpoint *pCheckpoint, CPlayerRally *pPlayer) { ClientPrint(pPlayer, HUD_PRINTCENTER, "Wrong Checkpoint - Go Back!"); pPlayer->EmitSound("HLRally.CheckpointWrong"); } void CCheckpointManagerABC::CheckpointTouchFirstPlayerThrough(CEntityInfoCheckpoint *pCheckpoint, CPlayerRally *pPlayer) { } void CCheckpointManagerABC::CheckpointTouchLastPlayerThrough(CEntityInfoCheckpoint *pCheckpoint, CPlayerRally *pPlayer) { } void CCheckpointManagerABC::CheckpointPlayerFinishesLap(CPlayerRally *pPlayer) { } void CCheckpointManagerABC::CheckpointPlayerFinishesRace(CPlayerRally *pPlayer) { }