@@ -9,6 +9,9 @@ float AIShipCannonController::fMaxCannonDamageRadiusPoint = 1.0f;
99
1010int AIShipCannonController::ColorA = 0 ;
1111int AIShipCannonController::ColorR = 0 ;
12+ int AIShipCannonController::ColorNA = 0 ;
13+ int AIShipCannonController::ColorNR = 0 ;
14+ bool AIShipCannonController::bShowCannonsRange = true ;
1215
1316AIShipCannonController::AIShipCannonController (AIShip *_pShip) : bReload(false ), bNotEnoughBalls(false )
1417{
@@ -563,75 +566,77 @@ void AIShipCannonController::Realize(float fDeltaTime)
563566 debugDrawToggle = !debugDrawToggle;
564567 std::this_thread::sleep_for (100ms);
565568 }
566-
569+
570+ if (!bShowCannonsRange) return ;
571+
567572 if (debugDrawToggle)
568573 {
569- for (auto it = debugFirePositions.begin (); it != debugFirePositions.end ();)
570- {
571- constexpr auto kDebugFadeTime = 3 .0f ;
572- if (auto &[pos, color, dt] = *it; dt <= kDebugFadeTime )
573- {
574- dt += fDeltaTime ;
575-
576- CVECTOR cPos;
577- CVECTOR cAng;
578- float cFov;
579- AIHelper::pRS->GetCamera (cPos, cAng, cFov);
580-
581- const auto dist = (pos - cPos).GetLength ();
582-
583- float radius = 0 .3f ;
584- if (dist > 1 .0f )
585- {
586- radius *= sqrtf (dist);
587- }
588- AIHelper::pRS->DrawSphere (pos, radius, color);
589- ++it;
590- }
591- else
592- {
593- it = debugFirePositions.erase (it);
594- }
595- }
596-
597- static std::vector<RS_LINE> Lines;
598- Lines.clear ();
599-
600- for (const auto &bort : aShipBorts)
601- {
602- for (const auto &cannon : bort.aCannons )
603- {
604- if (!cannon.isDamaged ())
605- {
606- constexpr auto red = ARGB (0xFF , 0xDC , 0x14 , 0x3C );
607- constexpr auto green = ARGB (0xFF , 0x7C , 0xFC , 0x00 );
608-
609- const auto &&vPos = cannon.GetPos ();
610- Lines.emplace_back (RS_LINE{vPos, red});
611- Lines.emplace_back (RS_LINE{vPos + 5 .0f * cannon.GetDir (), red});
612- Lines.emplace_back (RS_LINE{vPos, green});
613- Lines.emplace_back (RS_LINE{vPos + CVECTOR{0 .0f , cannon.GetDirY (), 0 .0f }, green});
614- }
615- }
616- }
617-
618- if (!Lines.empty ())
619- {
620- AIHelper::pRS->SetTransform (D3DTS_WORLD, CMatrix ());
621- AIHelper::pRS->DrawLines (Lines.data (), Lines.size () / 2 , " Line" );
622- }
623-
624- if (GetAIShip ()->isMainCharacter ())
625- {
626- std::string buf;
627- for (const auto &bort : aShipBorts)
628- {
629- buf += fmt::format (" {:.3f} " , GetBortHeightAngle (bort));
630- }
631- AIHelper::pRS->Print (200 , 20 , buf.c_str ());
632- }
574+ for (auto it = debugFirePositions.begin (); it != debugFirePositions.end ();)
575+ {
576+ constexpr auto kDebugFadeTime = 3 .0f ;
577+ if (auto &[pos, color, dt] = *it; dt <= kDebugFadeTime )
578+ {
579+ dt += fDeltaTime ;
580+
581+ CVECTOR cPos;
582+ CVECTOR cAng;
583+ float cFov;
584+ AIHelper::pRS->GetCamera (cPos, cAng, cFov);
585+
586+ const auto dist = (pos - cPos).GetLength ();
587+
588+ float radius = 0 .3f ;
589+ if (dist > 1 .0f )
590+ {
591+ radius *= sqrtf (dist);
592+ }
593+ AIHelper::pRS->DrawSphere (pos, radius, color);
594+ ++it;
595+ }
596+ else
597+ {
598+ it = debugFirePositions.erase (it);
599+ }
600+ }
601+
602+ static std::vector<RS_LINE> Lines;
603+ Lines.clear ();
604+
605+ for (const auto &bort : aShipBorts)
606+ {
607+ for (const auto &cannon : bort.aCannons )
608+ {
609+ if (!cannon.isDamaged ())
610+ {
611+ constexpr auto red = ARGB (0xFF , 0xDC , 0x14 , 0x3C );
612+ constexpr auto green = ARGB (0xFF , 0x7C , 0xFC , 0x00 );
613+
614+ const auto &&vPos = cannon.GetPos ();
615+ Lines.emplace_back (RS_LINE{vPos, red});
616+ Lines.emplace_back (RS_LINE{vPos + 5 .0f * cannon.GetDir (), red});
617+ Lines.emplace_back (RS_LINE{vPos, green});
618+ Lines.emplace_back (RS_LINE{vPos + CVECTOR{0 .0f , cannon.GetDirY (), 0 .0f }, green});
619+ }
620+ }
621+ }
622+
623+ if (!Lines.empty ())
624+ {
625+ AIHelper::pRS->SetTransform (D3DTS_WORLD, CMatrix ());
626+ AIHelper::pRS->DrawLines (Lines.data (), Lines.size () / 2 , " Line" );
627+ }
628+
629+ if (GetAIShip ()->isMainCharacter ())
630+ {
631+ std::string buf;
632+ for (const auto &bort : aShipBorts)
633+ {
634+ buf += fmt::format (" {:.3f} " , GetBortHeightAngle (bort));
635+ }
636+ AIHelper::pRS->Print (200 , 20 , buf.c_str ());
637+ }
633638 }
634-
639+
635640 struct tr_vertex
636641 {
637642 CVECTOR vPos;
@@ -675,11 +680,11 @@ void AIShipCannonController::Realize(float fDeltaTime)
675680 RotateAroundY (v[2 ].x , v[2 ].z , vZ.z , vZ.x );
676681 v[2 ] += v[0 ];
677682
678- if (debugDrawToggle) ColorA = ColorR = ARGB (0x0F , 0x90 , 0xEE , 0x90 );
683+ if (debugDrawToggle) ColorA = ColorR = ColorNA = ColorNR = ARGB (0x0F , 0x90 , 0xEE , 0x90 );
679684
680- Verts.emplace_back (tr_vertex{v[0 ], static_cast <uint32_t >(ColorA)});
681- Verts.emplace_back (tr_vertex{v[1 ], static_cast <uint32_t >(ColorR)});
682- Verts.emplace_back (tr_vertex{v[2 ], static_cast <uint32_t >(ColorR)});
685+ Verts.emplace_back (tr_vertex{v[0 ], bort. isCharged () ? static_cast <uint32_t >(ColorA) : static_cast < uint32_t >(ColorNA )});
686+ Verts.emplace_back (tr_vertex{v[1 ], bort. isCharged () ? static_cast <uint32_t >(ColorR) : static_cast < uint32_t >(ColorNR )});
687+ Verts.emplace_back (tr_vertex{v[2 ], bort. isCharged () ? static_cast <uint32_t >(ColorR) : static_cast < uint32_t >(ColorNR) });
683688 }
684689 }
685690 }
0 commit comments