mirror of
https://github.com/sigonasr2/hamster.git
synced 2025-04-18 06:39:39 -05:00
Remove hashing requirement by using a set for hamster checkpoints instead.
This commit is contained in:
parent
baf7ca769c
commit
12739dcf3c
@ -56,14 +56,4 @@ public:
|
||||
static std::vector<Checkpoint>&GetCheckpoints();
|
||||
const vf2d&GetPos()const;
|
||||
void OnCheckpointCollect();
|
||||
friend const bool operator==(const Checkpoint&cp1,const Checkpoint&cp2){return cp1.pos==cp2.pos;}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct std::hash<Checkpoint>
|
||||
{
|
||||
int_fast64_t operator()(const Checkpoint&checkpoint)const
|
||||
{
|
||||
return (int_fast64_t)(*(int_fast32_t*)(&checkpoint.pos.x))<<32|*(int_fast32_t*)(&checkpoint.pos.y);
|
||||
}
|
||||
};
|
@ -356,8 +356,8 @@ void Hamster::HandleCollision(){
|
||||
}
|
||||
}
|
||||
for(Checkpoint&checkpoint:Checkpoint::GetCheckpoints()){
|
||||
if(z<=0.1f&&geom2d::overlaps(geom2d::rect<float>(checkpoint.GetPos()-vf2d{62,60},{122.f,113.f}),geom2d::circle<float>(GetPos(),collisionRadius))&&!checkpointsCollected.count(checkpoint)){
|
||||
checkpointsCollected.insert(checkpoint);
|
||||
if(z<=0.1f&&geom2d::overlaps(geom2d::rect<float>(checkpoint.GetPos()-vf2d{62,60},{122.f,113.f}),geom2d::circle<float>(GetPos(),collisionRadius))&&!checkpointsCollected.count(checkpoint.GetPos())){
|
||||
checkpointsCollected.insert(checkpoint.GetPos());
|
||||
FloatingText::CreateFloatingText(pos,std::format("{} / {}",checkpointsCollected.size(),Checkpoint::GetCheckpoints().size()),{WHITE,GREEN},{1.5f,2.f});
|
||||
checkpoint.OnCheckpointCollect();
|
||||
}
|
||||
@ -583,7 +583,7 @@ const bool Hamster::CollectedAllCheckpoints()const{
|
||||
}
|
||||
|
||||
const bool Hamster::HasCollectedCheckpoint(const Checkpoint&cp)const{
|
||||
return checkpointsCollected.contains(cp);
|
||||
return checkpointsCollected.contains(cp.GetPos());
|
||||
}
|
||||
const std::vector<Hamster>&Hamster::GetHamsters(){
|
||||
return HAMSTER_LIST;
|
||||
|
@ -111,7 +111,7 @@ class Hamster{
|
||||
float jetFuel{0.f};
|
||||
float jetFuelDisplayAmt{0.f};
|
||||
float knockoutTimer{0.f};
|
||||
std::unordered_set<Checkpoint>checkpointsCollected;
|
||||
std::set<vf2d>checkpointsCollected;
|
||||
float raceFinishAnimTimer{0.f};
|
||||
std::pair<Timer,vf2d>collectedCheckpointInfo{INFINITY,{}};
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user