From 0052edae47d1e6ae613497c524719eff5838f52a Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 18 Feb 2022 23:54:30 +0100 Subject: Switched to use GetIntance for Game instead of static methods --- Stars45/ShipAI.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'Stars45/ShipAI.cpp') diff --git a/Stars45/ShipAI.cpp b/Stars45/ShipAI.cpp index b1495f8..71c1abe 100644 --- a/Stars45/ShipAI.cpp +++ b/Stars45/ShipAI.cpp @@ -278,12 +278,12 @@ ShipAI::ExecFrame(double secs) if (target == ship->GetTarget() && target->Type() == SimObject::SIM_SHIP) { // if this isn't the same ship we last called out: - if (target->Identity() != engaged_ship_id && Game::GameTime() - last_call_time > 10000) { + if (target->Identity() != engaged_ship_id && Game::GetInstance()->GameTime() - last_call_time > 10000) { // call engaging: RadioMessage* msg = new(__FILE__,__LINE__) RadioMessage(ship->GetElement(), ship, RadioMessage::CALL_ENGAGING); msg->AddTarget(target); RadioTraffic::Transmit(msg); - last_call_time = Game::GameTime(); + last_call_time = Game::GetInstance()->GameTime(); engaged_ship_id = target->Identity(); } @@ -383,7 +383,7 @@ ShipAI::FindObjective() // if not the element leader, stay in formation: if (form && element_index > 1) { - ship->SetDirectorInfo(Game::GetText("ai.formation")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.formation")); if (navpt && navpt->Action() == Instruction::LAUNCH) { FindObjectiveNavPoint(); @@ -411,7 +411,7 @@ ShipAI::FindObjective() if (support) { double d_support = Point(support->Location() - ship->Location()).length(); if (d_support > 35e3) { - ship->SetDirectorInfo(Game::GetText("ai.regroup")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.regroup")); FindObjectiveTarget(support); objective = Transform(obj_w); return; @@ -420,7 +420,7 @@ ShipAI::FindObjective() // run away: else if (threat != target) { - ship->SetDirectorInfo(Game::GetText("ai.retreat")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.retreat")); obj_w = ship->Location() + Point(ship->Location() - threat->Location()) * 100; objective = Transform(obj_w); return; @@ -429,31 +429,31 @@ ShipAI::FindObjective() // normal processing: if (target) { - ship->SetDirectorInfo(Game::GetText("ai.seek-target")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.seek-target")); FindObjectiveTarget(target); objective = AimTransform(obj_w); } else if (patrol) { - ship->SetDirectorInfo(Game::GetText("ai.patrol")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.patrol")); FindObjectivePatrol(); objective = Transform(obj_w); } else if (ward) { - ship->SetDirectorInfo(Game::GetText("ai.seek-ward")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.seek-ward")); FindObjectiveFormation(); objective = Transform(obj_w); } else if (navpt && form) { - ship->SetDirectorInfo(Game::GetText("ai.seek-navpt")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.seek-navpt")); FindObjectiveNavPoint(); objective = Transform(obj_w); } else if (rumor) { - ship->SetDirectorInfo(Game::GetText("ai.search")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.search")); FindObjectiveTarget(rumor); objective = Transform(obj_w); } @@ -892,11 +892,11 @@ ShipAI::Navigator() ship->SetFLCSMode(Ship::FLCS_HELM); if (target) - ship->SetDirectorInfo(Game::GetText("ai.seek-target")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.seek-target")); else if (rumor) - ship->SetDirectorInfo(Game::GetText("ai.seek-rumor")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.seek-rumor")); else - ship->SetDirectorInfo(Game::GetText("ai.none")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.none")); Accumulate(AvoidCollision()); Accumulate(AvoidTerrain()); @@ -1046,7 +1046,7 @@ ShipAI::AvoidCollision() last_avoid_time = 0; // check for a new obstacle immediately } - if (!other && Game::GameTime() - last_avoid_time < 500) + if (!other && Game::GetInstance()->GameTime() - last_avoid_time < 500) return avoid; brake = 0; @@ -1119,11 +1119,11 @@ ShipAI::AvoidCollision() avoid = Avoid(obstacle, (float) (ship->Radius() + other->Radius() + avoid_dist * 0.9)); avoid.brake = brake; - ship->SetDirectorInfo(Game::GetText("ai.avoid-collision")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.avoid-collision")); } } - last_avoid_time = Game::GameTime(); + last_avoid_time = Game::GetInstance()->GameTime(); return avoid; } @@ -1260,7 +1260,7 @@ ShipAI::AvoidCloseObject(SimObject* obj) Steer avoid = Flee(obstacle); avoid.brake = 0.3; - ship->SetDirectorInfo(Game::GetText("ai.avoid-collision")); + ship->SetDirectorInfo(Game::GetInstance()->GetText("ai.avoid-collision")); return avoid; } -- cgit v1.1