From de9c5d510175bba11ab8704e67be3a3a94f9149e Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 9 Nov 2025 19:07:44 -0700 Subject: Implement SpawnParams struct (#536) * Impl SpawnParams * Added json submodule * Update json * Update * Works * Remove comment * Works refactor * Snowman and thwomp working * Impl hot air balloon * More progress * All OObjects are done * cleanup * Refactor 2Dpath to normal path * Update nlohmann json & fix compile * Rest of actors * MORE CHANGES * Finish actors * Done PR, some fix to collision viewer * Impl falling rocks * Add const * wip editor refactor * Property work * continue * Overridable editor properties * Actor saving/loading works now * Fix light alignment * Clarification * Impl penguin * params impl signs * properties impl falling rock * More property impls * impl air balloon * Add spawnParams to OObject Translate * Snowman translate better * impl hedgehog properly * properties impl trophy * thwomp progress * Finish impl properties * Fix compile * Fix cursor collisions * Move registered actors * Rename pathPoint XYZ to xyz * Fix editor pause bug * Clean up * Review comments * Remove SpawnParams struct from actor classes * Rename * Player Label First Iteration * Work now * Working 3d text * Fix boo bug * Finish AText actor * Fix spawnparams compile * Register AText * Finish Text Actor * Fix thwomp interpolation * Fix compile * Fix crab and hedgehog * Fix loading flagpole * Fix Hot Air Balloon * Turn zbuffer on for AText * Update --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> --- src/engine/objects/Boos.cpp | 80 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 8 deletions(-) (limited to 'src/engine/objects/Boos.cpp') diff --git a/src/engine/objects/Boos.cpp b/src/engine/objects/Boos.cpp index dbd380901..a22b0edd0 100644 --- a/src/engine/objects/Boos.cpp +++ b/src/engine/objects/Boos.cpp @@ -23,12 +23,20 @@ extern "C" { size_t OBoos::_count = 0; -OBoos::OBoos(size_t numBoos, const IPathSpan& leftBoundary, const IPathSpan& active, const IPathSpan& rightBoundary) { +OBoos::OBoos(const SpawnParams& params) : OObject(params) { Name = "Boos"; + ResourceName = "mk:boos"; + + size_t numBoos = params.Count.value_or(5); + + ActiveZone = params.TriggerSpan.value_or(IPathSpan(30, 50)); + LeftTrigger = params.LeftExitSpan.value_or(IPathSpan(0, 10)); + RightTrigger = params.RightExitSpan.value_or(IPathSpan(80, 100)); + // Max five boos allowed due to limited splines // D_800E5D9C if (numBoos > 10) { - printf("Boos.cpp: Only 10 boos allowed.\n"); + printf("[Boos.cpp] Only 10 boos allowed.\n"); numBoos = 10; } @@ -40,9 +48,14 @@ OBoos::OBoos(size_t numBoos, const IPathSpan& leftBoundary, const IPathSpan& act } _numBoos = numBoos; - _leftBoundary = leftBoundary; - _active = active; - _rightBoundary = rightBoundary; +} + +void OBoos::SetSpawnParams(SpawnParams& params) { + OObject::SetSpawnParams(params); + params.Count = _numBoos; + params.LeftExitSpan = LeftTrigger; + params.TriggerSpan = ActiveZone; + params.RightExitSpan = RightTrigger; } void OBoos::Tick() { @@ -123,7 +136,8 @@ void OBoos::func_8007CA70(void) { if (_isActive == false) { _playerId = OBoos::func_8007C9F8(); point = &gNearestPathPointByPlayerId[_playerId]; - if ((*point > _active.Start) && (*point < _active.End)) { + + if ((*point > ActiveZone.Start) && (*point < ActiveZone.End)) { // First group entrance OBoos::BooStart(0, _playerId); } @@ -131,11 +145,14 @@ void OBoos::func_8007CA70(void) { if (_isActive == true) { point = &gNearestPathPointByPlayerId[_playerId]; - if ((*point > _leftBoundary.Start) && (*point < _leftBoundary.End)) { + // Left boundary + if ((*point > LeftTrigger.Start) && (*point < LeftTrigger.End)) { // First group exit reverse direction OBoos::BooExit(0); } - if ((*point > _rightBoundary.Start) && (*point < _rightBoundary.End)) { + + // Right boundary + if ((*point > RightTrigger.Start) && (*point < RightTrigger.End)) { // First group exit OBoos::BooExit(0); } @@ -274,3 +291,50 @@ void OBoos::BooExit(s32 group) { _isActive = false; } + +void OBoos::DrawEditorProperties() { + ImGui::Text("Num Boos"); + ImGui::SameLine(); + + int count = static_cast(_count); + if (ImGui::InputInt("##Count", &count)) { + // Clamp to uint32_t range (only lower bound needed if assuming positive values) + if (count < 0) count = 0; + if (count > 10) count = 10; + _count = static_cast(count); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO "##ResetCount")) { + _count = 5; + } + + ImGui::Text("Left Exit Span"); + ImGui::SameLine(); + + if (ImGui::DragInt2("##LeftExitSpan", (int*)&LeftTrigger)) { + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO "##ResetLeftExitSpan")) { + LeftTrigger = IPathSpan(0, 0); + } + + ImGui::Text("Trigger Span"); + ImGui::SameLine(); + + if (ImGui::DragInt2("##TriggerSpan", (int*)&ActiveZone)) { + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO "##ResetTriggerSpan")) { + ActiveZone = IPathSpan(0, 0); + } + + ImGui::Text("Right Exit Span"); + ImGui::SameLine(); + + if (ImGui::DragInt2("##RightExitSpan", (int*)&RightTrigger)) { + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO "##ResetRightExitSpan")) { + RightTrigger = IPathSpan(0, 0); + } +} -- cgit v1.2.3