diff options
| author | Léo Lam <leo@leolam.fr> | 2026-09-28 03:39:31 +0200 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2026-10-06 03:19:38 +0200 |
| commit | 38905c8c075ec4ed8f8fcf858aef46bc5e05f8e2 (patch) | |
| tree | c1c1378ec76107a6e93bdaabe27cc80ded4d943b /src | |
| parent | 4a6239bbbf5b5ab78c8d7eebb7afeeb79601ff43 (diff) | |
AutoPlacement is game code: move it to Game/
It is created only from game code, no engine code calls it, and it
hardcodes game actor names.
(AI assisted using Claude Fable 5.1 and Claude Opus 5.5)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Game/Actor/Action/actionAddAutoPlacementCreator.cpp | 11 | ||||
| -rw-r--r-- | src/Game/AutoPlacement/AutoPlacement.cpp (renamed from src/KingSystem/Map/mapAutoPlacement.cpp) | 58 | ||||
| -rw-r--r-- | src/Game/AutoPlacement/AutoPlacement.h (renamed from src/KingSystem/Map/mapAutoPlacement.h) | 18 | ||||
| -rw-r--r-- | src/Game/AutoPlacement/AutoPlacementFlowMgr.cpp (renamed from src/KingSystem/Map/mapAutoPlacementFlowMgr.cpp) | 10 | ||||
| -rw-r--r-- | src/Game/AutoPlacement/AutoPlacementFlowMgr.h (renamed from src/KingSystem/Map/mapAutoPlacementFlowMgr.h) | 6 | ||||
| -rw-r--r-- | src/Game/AutoPlacement/AutoPlacementMgr.cpp | 7 | ||||
| -rw-r--r-- | src/Game/AutoPlacement/AutoPlacementMgr.h (renamed from src/KingSystem/Map/mapAutoPlacementMgr.h) | 8 | ||||
| -rw-r--r-- | src/Game/AutoPlacement/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | src/Game/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/Game/E3Mgr.cpp | 2 | ||||
| -rw-r--r-- | src/KingSystem/Map/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/KingSystem/Map/mapAutoPlacementMgr.cpp | 7 |
12 files changed, 73 insertions, 69 deletions
diff --git a/src/Game/Actor/Action/actionAddAutoPlacementCreator.cpp b/src/Game/Actor/Action/actionAddAutoPlacementCreator.cpp index 086fb095..8a1d4e67 100644 --- a/src/Game/Actor/Action/actionAddAutoPlacementCreator.cpp +++ b/src/Game/Actor/Action/actionAddAutoPlacementCreator.cpp @@ -1,6 +1,6 @@ #include "Game/Actor/Action/actionAddAutoPlacementCreator.h" +#include "Game/AutoPlacement/AutoPlacementMgr.h" #include "KingSystem/ActorSystem/actActor.h" -#include "KingSystem/Map/mapAutoPlacementMgr.h" #include "KingSystem/Map/mapDebug.h" #include "KingSystem/Utils/MathUtil.h" @@ -43,9 +43,8 @@ void AddAutoPlacementCreator::enter_(ksys::act::ai::InlineParamPack* params) { return; } - if (ksys::map::AutoPlacementMgr::instance() != nullptr && - ksys::map::AutoPlacementMgr::instance()->sub_7100659E40(mActor, mActorName_m, *mCount_m, - is_box)) { + if (AutoPlacementMgr::instance() != nullptr && + AutoPlacementMgr::instance()->sub_7100659E40(mActor, mActorName_m, *mCount_m, is_box)) { actor->setDeleteDistance(actor->getDeleteDistance() + 100.0f); mInitialised = true; } @@ -57,8 +56,8 @@ void AddAutoPlacementCreator::leave_() { if (!mInitialised) return; - if (ksys::map::AutoPlacementMgr::instance() != nullptr) - ksys::map::AutoPlacementMgr::instance()->sub_7100659F94(mActor); + if (AutoPlacementMgr::instance() != nullptr) + AutoPlacementMgr::instance()->sub_7100659F94(mActor); mInitialised = false; } diff --git a/src/KingSystem/Map/mapAutoPlacement.cpp b/src/Game/AutoPlacement/AutoPlacement.cpp index b47494c8..d655fb7d 100644 --- a/src/KingSystem/Map/mapAutoPlacement.cpp +++ b/src/Game/AutoPlacement/AutoPlacement.cpp @@ -1,17 +1,17 @@ -#include "KingSystem/Map/mapAutoPlacement.h" +#include "Game/AutoPlacement/AutoPlacement.h" +#include "Game/AutoPlacement/AutoPlacementFlowMgr.h" +#include "Game/AutoPlacement/AutoPlacementMgr.h" #include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actActorUtil.h" #include "KingSystem/ActorSystem/actInfoData.h" #include "KingSystem/ActorSystem/actPhysicsUserTag.h" #include "KingSystem/Ecosystem/ecoSystem.h" -#include "KingSystem/Map/mapAutoPlacementFlowMgr.h" -#include "KingSystem/Map/mapAutoPlacementMgr.h" #include "KingSystem/Physics/RigidBody/physRigidBody.h" #include "KingSystem/Physics/System/physRayCastForRequest.h" #include "KingSystem/Utils/Byaml/Byaml.h" #include "KingSystem/World/worldWeatherMgr.h" -namespace ksys::map { +namespace uking { AutoPlacement::AutoPlacement() = default; AutoPlacement::~AutoPlacement() = default; @@ -33,10 +33,10 @@ u32 AutoPlacement::sub_710064CD80(u32 a, u32 b) { } void ActorSpawnInfo::calcSpawnLocations() { - auto* mgr = act::InfoData::instance(); + auto* mgr = ksys::act::InfoData::instance(); al::ByamlIter iter; - using namespace act::tags; + using namespace ksys::act::tags; spawn_location.makeAllZero(); if (mgr == nullptr || !mgr->getActorIter(&iter, name.cstr())) @@ -88,11 +88,12 @@ void AutoPlacement::sub_710064DA54() { _8 = 2; } -eco::AreaItemType sPlacementItemTypesData[] = { - eco::AreaItemType::Enemy, eco::AreaItemType::Animal, eco::AreaItemType::Insect, - eco::AreaItemType::Fish, eco::AreaItemType::Bird, eco::AreaItemType::AutoPlacementMaterial, +ksys::eco::AreaItemType sPlacementItemTypesData[] = { + ksys::eco::AreaItemType::Enemy, ksys::eco::AreaItemType::Animal, + ksys::eco::AreaItemType::Insect, ksys::eco::AreaItemType::Fish, + ksys::eco::AreaItemType::Bird, ksys::eco::AreaItemType::AutoPlacementMaterial, }; -sead::Buffer<eco::AreaItemType> sPlacementItemTypes{sPlacementItemTypesData}; +sead::Buffer<ksys::eco::AreaItemType> sPlacementItemTypes{sPlacementItemTypesData}; // NON_MATCHING: stack bool AutoPlacement::sub_710064E178(const sead::SafeString& name, u32 placement_type, @@ -100,7 +101,7 @@ bool AutoPlacement::sub_710064E178(const sead::SafeString& name, u32 placement_t if (mNearFlag == 0xFE) return true; - auto* eco = eco::Ecosystem::instance(); + auto* eco = ksys::eco::Ecosystem::instance(); if (eco == nullptr) return false; @@ -108,7 +109,7 @@ bool AutoPlacement::sub_710064E178(const sead::SafeString& name, u32 placement_t if (area < 0) return false; - eco::AreaItemSet item_set; + ksys::eco::AreaItemSet item_set; eco->getAreaItems(area, sPlacementItemTypes[placement_type], &item_set); for (int i = 0; i < item_set.count; ++i) { @@ -129,12 +130,12 @@ bool PlacementThing::invoke() { if (mRaycast == nullptr || mState != State::Initialized) return false; - mRaycast->enableLayer(phys::ContactLayer::EntityGround); - mRaycast->enableLayer(phys::ContactLayer::EntityGroundRough); - mRaycast->enableLayer(phys::ContactLayer::EntityGroundSmooth); - mRaycast->enableLayer(phys::ContactLayer::EntityAirWall); - mRaycast->enableLayer(phys::ContactLayer::EntityGroundObject); - mRaycast->enableLayer(phys::ContactLayer::EntityTree); + mRaycast->enableLayer(ksys::phys::ContactLayer::EntityGround); + mRaycast->enableLayer(ksys::phys::ContactLayer::EntityGroundRough); + mRaycast->enableLayer(ksys::phys::ContactLayer::EntityGroundSmooth); + mRaycast->enableLayer(ksys::phys::ContactLayer::EntityAirWall); + mRaycast->enableLayer(ksys::phys::ContactLayer::EntityGroundObject); + mRaycast->enableLayer(ksys::phys::ContactLayer::EntityTree); if (_8944) { sead::Vector3f v1 = mVec1 + sead::Vector3f{0, 4, 30}; @@ -165,13 +166,13 @@ bool AutoPlacement::sub_7100650144(PlacementGroup* grp, bool check_exposure) { return true; } - if (object->getProc() == nullptr && object->getFlags0().isOn(Object::Flag0::_80)) + if (object->getProc() == nullptr && object->getFlags0().isOn(ksys::map::Object::Flag0::_80)) return true; if (grp->_1d != 2) return false; - if (check_exposure && !world::WeatherMgr::isExposureZero()) + if (check_exposure && !ksys::world::WeatherMgr::isExposureZero()) return true; return false; } @@ -273,11 +274,12 @@ void PlacementThing::stepRaycast() { switch (mState) { case State::Uninitialized: - mRaycast = phys::RayCastForRequest::allocRequest(nullptr, phys::GroundHit::Animal); + mRaycast = + ksys::phys::RayCastForRequest::allocRequest(nullptr, ksys::phys::GroundHit::Animal); next = mRaycast != nullptr ? State::Initialized : State::Invalid; break; case State::LayersDone: - mRaycast->submitRequest(phys::ContactLayerType::Entity); + mRaycast->submitRequest(ksys::phys::ContactLayerType::Entity); next = State::RaycastDone; break; case State::PlacementDone: @@ -295,14 +297,14 @@ void PlacementThing::stepRaycast() { mState = next; } -void AutoPlacement::sub_7100650C28(phys::RigidBody* rb) { +void AutoPlacement::sub_7100650C28(ksys::phys::RigidBody* rb) { if (rb == nullptr) return; - if (rb->getContactLayer() == phys::ContactLayer::EntityTree) + if (rb->getContactLayer() == ksys::phys::ContactLayer::EntityTree) mNearFlag.setDirect(1); - auto* tag = sead::DynamicCast<act::PhysicsUserTag>(rb->getUserTag()); + auto* tag = sead::DynamicCast<ksys::act::PhysicsUserTag>(rb->getUserTag()); if (tag == nullptr) return; @@ -310,8 +312,8 @@ void AutoPlacement::sub_7100650C28(phys::RigidBody* rb) { if (actor == nullptr) return; - mNearFlag.set(act::hasTag(actor, act::tags::Tree) || - act::hasTag(actor, act::tags::AutoPlacementForbidCreate)); + mNearFlag.set(ksys::act::hasTag(actor, ksys::act::tags::Tree) || + ksys::act::hasTag(actor, ksys::act::tags::AutoPlacementForbidCreate)); _b.set(actor->getName() == "AirWallHorse"); } @@ -332,4 +334,4 @@ const char* PlacementThing::getCurrentWaterSubMat() const { } } -} // namespace ksys::map +} // namespace uking diff --git a/src/KingSystem/Map/mapAutoPlacement.h b/src/Game/AutoPlacement/AutoPlacement.h index 5624fddb..1b1db151 100644 --- a/src/KingSystem/Map/mapAutoPlacement.h +++ b/src/Game/AutoPlacement/AutoPlacement.h @@ -15,7 +15,7 @@ class RayCastForRequest; class RigidBody; } // namespace ksys::phys -namespace ksys::map { +namespace uking { class AutoPlacement; struct AutoPlacementFlowRes; @@ -67,24 +67,24 @@ public: bool invoke(); void stepRaycast(); - void sub_7100650C28(phys::RigidBody*); + void sub_7100650C28(ksys::phys::RigidBody*); const char* getCurrentGroundMat() const; const char* getCurrentWaterSubMat() const; private: friend class AutoPlacement; - phys::RayCastForRequest* mRaycast{}; + ksys::phys::RayCastForRequest* mRaycast{}; u8 _8880{}; u8 mUnderwater{}; sead::Vector3f mVec1{}; sead::Vector3f mQueryVec{}; u32 _889c{}; f32 _88a0 = 1.0f; - phys::MaterialMask mMask1; - phys::MaterialMask mMask2; + ksys::phys::MaterialMask mMask1; + ksys::phys::MaterialMask mMask2; f32 mWaterQuery = -1.0f; - sead::Delegate1<PlacementThing, phys::RigidBody*> mDelegate; + sead::Delegate1<PlacementThing, ksys::phys::RigidBody*> mDelegate; sead::CriticalSection mCS{}; State mState; u8 _8944{}; @@ -141,11 +141,11 @@ public: s32 placeGroup(AutoPlacementFlowRes* res); s32 sub_7100650908(); void stepAllRaycasts(); - void sub_7100650C28(phys::RigidBody* rb); + void sub_7100650C28(ksys::phys::RigidBody* rb); private: struct ObjectRef { - Object* obj; + ksys::map::Object* obj; void* _8; }; @@ -175,4 +175,4 @@ private: sead::Buffer<ObjectRef> mObjectRefs; }; -} // namespace ksys::map +} // namespace uking diff --git a/src/KingSystem/Map/mapAutoPlacementFlowMgr.cpp b/src/Game/AutoPlacement/AutoPlacementFlowMgr.cpp index 3bef06c4..10742efa 100644 --- a/src/KingSystem/Map/mapAutoPlacementFlowMgr.cpp +++ b/src/Game/AutoPlacement/AutoPlacementFlowMgr.cpp @@ -1,9 +1,9 @@ -#include "KingSystem/Map/mapAutoPlacementFlowMgr.h" +#include "Game/AutoPlacement/AutoPlacementFlowMgr.h" #include <container/seadBuffer.h> #include <evfl/ResActor.h> #include "KingSystem/Resource/resLoadRequest.h" -namespace ksys::map { +namespace uking { const char* sFlowResNamesData[] = { "AutoPlacement_Animal.bfevfl", @@ -38,7 +38,7 @@ void AutoPlacementFlowMgr::loadEventFlows() { sead::FixedSafeString<128> path; path.format("EventFlow/%s", flow.evfl_name.cstr()); - res::LoadRequest req; + ksys::res::LoadRequest req; req.mRequester = "AutoPlacementFlow"; flow.handle.requestLoad(path, &req); @@ -51,11 +51,11 @@ void AutoPlacementFlowMgr::loadEventFlows() { sead::FixedSafeString<128> path; path.format("EventFlow/%s", flow.evfl_name.cstr()); - res::LoadRequest req; + ksys::res::LoadRequest req; req.mRequester = "AutoPlacementFlow"; flow.handle.requestLoad(path, &req); } } -} // namespace ksys::map +} // namespace uking diff --git a/src/KingSystem/Map/mapAutoPlacementFlowMgr.h b/src/Game/AutoPlacement/AutoPlacementFlowMgr.h index df3b6648..26103f3a 100644 --- a/src/KingSystem/Map/mapAutoPlacementFlowMgr.h +++ b/src/Game/AutoPlacement/AutoPlacementFlowMgr.h @@ -6,14 +6,14 @@ #include <prim/seadSafeString.h> #include "KingSystem/Resource/resHandle.h" -namespace ksys::map { +namespace uking { class AutoPlacement; struct AutoPlacementFlowRes { void start(AutoPlacement* placement, const sead::SafeString& unit_name, int*); - res::Handle handle; + ksys::res::Handle handle; sead::SafeString evfl_name; evfl::FlowchartContext flowchart_ctx; AutoPlacement* placement; @@ -38,4 +38,4 @@ private: sead::SafeArray<AutoPlacementFlowRes, 7> mFlowNearArray; }; -} // namespace ksys::map +} // namespace uking diff --git a/src/Game/AutoPlacement/AutoPlacementMgr.cpp b/src/Game/AutoPlacement/AutoPlacementMgr.cpp new file mode 100644 index 00000000..c73dbfd4 --- /dev/null +++ b/src/Game/AutoPlacement/AutoPlacementMgr.cpp @@ -0,0 +1,7 @@ +#include "Game/AutoPlacement/AutoPlacementMgr.h" + +namespace uking { + +SEAD_SINGLETON_DISPOSER_IMPL(AutoPlacementMgr) + +} // namespace uking diff --git a/src/KingSystem/Map/mapAutoPlacementMgr.h b/src/Game/AutoPlacement/AutoPlacementMgr.h index dc918b32..cad8d489 100644 --- a/src/KingSystem/Map/mapAutoPlacementMgr.h +++ b/src/Game/AutoPlacement/AutoPlacementMgr.h @@ -11,7 +11,7 @@ namespace ksys::act { class Actor; } // namespace ksys::act -namespace ksys::map { +namespace uking { class AutoPlacementMgr { SEAD_SINGLETON_DISPOSER(AutoPlacementMgr) @@ -19,9 +19,9 @@ public: AutoPlacementMgr(); virtual ~AutoPlacementMgr(); - bool sub_7100659E40(act::Actor* actor, const sead::SafeString& actor_name, int count, + bool sub_7100659E40(ksys::act::Actor* actor, const sead::SafeString& actor_name, int count, bool is_box); - void sub_7100659F94(act::Actor* actor); + void sub_7100659F94(ksys::act::Actor* actor); // 0x0000007100654e44 bool threadFn(); @@ -38,4 +38,4 @@ public: }; // KSYS_CHECK_SIZE_NX150(AutoPlacementMgr, 0x189E38); -} // namespace ksys::map +} // namespace uking diff --git a/src/Game/AutoPlacement/CMakeLists.txt b/src/Game/AutoPlacement/CMakeLists.txt new file mode 100644 index 00000000..4e98bbb6 --- /dev/null +++ b/src/Game/AutoPlacement/CMakeLists.txt @@ -0,0 +1,8 @@ +target_sources(uking PRIVATE + AutoPlacement.cpp + AutoPlacement.h + AutoPlacementFlowMgr.cpp + AutoPlacementFlowMgr.h + AutoPlacementMgr.cpp + AutoPlacementMgr.h +) diff --git a/src/Game/CMakeLists.txt b/src/Game/CMakeLists.txt index 457b3f56..702f626f 100644 --- a/src/Game/CMakeLists.txt +++ b/src/Game/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(Actor) +add_subdirectory(AutoPlacement) add_subdirectory(Cooking) add_subdirectory(DLC) add_subdirectory(Scene) diff --git a/src/Game/E3Mgr.cpp b/src/Game/E3Mgr.cpp index 61b7e60b..63eb18c2 100644 --- a/src/Game/E3Mgr.cpp +++ b/src/Game/E3Mgr.cpp @@ -1,5 +1,5 @@ #include "E3Mgr.h" -#include "KingSystem/Map/mapAutoPlacementMgr.h" +#include "Game/AutoPlacement/AutoPlacementMgr.h" #include "KingSystem/Map/mapPlacementMgr.h" #include "KingSystem/Resource/resLoadRequest.h" #include "controller/seadController.h" diff --git a/src/KingSystem/Map/CMakeLists.txt b/src/KingSystem/Map/CMakeLists.txt index 87d13eee..b201b701 100644 --- a/src/KingSystem/Map/CMakeLists.txt +++ b/src/KingSystem/Map/CMakeLists.txt @@ -1,11 +1,5 @@ target_sources(uking PRIVATE mapTypes.h - mapAutoPlacement.cpp - mapAutoPlacement.h - mapAutoPlacementFlowMgr.cpp - mapAutoPlacementFlowMgr.h - mapAutoPlacementMgr.cpp - mapAutoPlacementMgr.h mapDebug.cpp mapDebug.h mapLazyTraverseList.cpp diff --git a/src/KingSystem/Map/mapAutoPlacementMgr.cpp b/src/KingSystem/Map/mapAutoPlacementMgr.cpp deleted file mode 100644 index 8a3c4983..00000000 --- a/src/KingSystem/Map/mapAutoPlacementMgr.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "KingSystem/Map/mapAutoPlacementMgr.h" - -namespace ksys::map { - -SEAD_SINGLETON_DISPOSER_IMPL(AutoPlacementMgr) - -} // namespace ksys::map |
