CWMapApi
Map API Library for Content Warning
模組介紹 作者原文
CWMapApi – Custom Map API for Content Warning
A lightweight, dependency-free API that allows modders to add fully functional custom maps (moons) to Content Warning
How to Create a Custom Map
- Create your map in Unity
- Build it as an AssetBundle containing exactly one scene
- In your mod, load the AssetBundle and the scene yourself (via AssetBundle.LoadFromFile)
- Create a class that inherits from CWMapApi.Api.CustomMap
- Register an instance of your class with CustomMapApi.RegisterCustomMap(yourMapInstance)
Required Scene Setup
| Object | Purpose | Important Notes |
|-----------------------|---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| PatrolPoints | Empty parent → child Transforms = positions where monsters patrol and where scrap/items can spawn | This GameObject will be destroyed after initialization. Only its child positions are used. |
| DiveBellSpawns | Empty parent → child Transforms = possible dive-bell spawn locations | This GameObject will be destroyed after initialization. Only positions matter. |
| Navmesh | GameObject containing your baked NavMesh | Required for normal AI movement |
| NavmeshWide | GameObject containing your baked NavMesh for large enemies (BigSlap, Toolkit, Fire, etc.) | Required for normal AI movement |
| Level | Empty root object that holds all your map geometry and props | Game logic (lighting, audio, etc.) will parent under this object during initialization |
Critical: All objects that have colliders must be on Unity Layer index 10.
Example Implementation
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
using CWMapApi.Api;
public class MyCustomMoon: CustomMap
{
public override string GetMapName() => "Abandoned Factory";
public override string GetSceneName() => "AbandonedFactoryScene"; // exact scene name inside your AssetBundle
public override GameObject GetPatrolPoints() => GameObject.Find("PatrolPoints");
public override GameObject GetDiveBells() => GameObject.Find("DiveBellSpawns");
public override GameObject GetNavmesh() => GameObject.Find("Navmesh");
public override GameObject GetNavmeshWide() => GameObject.Find("NavmeshWide"); // or return GetNavmesh()
public override GameObject GetLevel() => GameObject.Find("Level");
// Highly recommended for compatibility with ConfigureMap and other map-related mods
public override string GetMapIconPath()
{
return Path.Combine(PluginInfo.PLUGIN_GUID.Directory, "icon.png"); // 256×256 PNG
}
// Runs right after your scene is loaded, but BEFORE game logic (players, dive-bell, etc.) is initialized
public override IEnumerator Prefix()
{
SetDefaultSkybox(); // removes skybox, sets black ambient (vanilla look)
SetDefaultWorldMaterialRecursive(GetLevel()); // applies the dark default material to everything
yield return null;
}
// Runs AFTER full map initialization (dive-bell placed, players spawned, etc.)
public override IEnumerator Postfix()
{
// Spawn extra props, play music, modify lighting, etc.
yield return null;
}
}
Random Map Pool Control
By default, CWMapApi automatically adds every registered custom moon to the random rotation.
If your mod (or another mod such as ConfigureMap) wants full control over which moon is selected, disable the automatic injection:
CustomMapApi.EnableMapPoolPatch(false);
Call with true to restore default behavior.
Included Helper
The mod package contains DiveBell.unitypackage – import it into Unity to get an exact 1:1 model of the dive bell for easier placement of spawn points.
Static API Reference
| Method | Description |
|---------------------------------------------------|-----------------------------------------------------------------------------|
| RegisterCustomMap(CustomMap map) | Registers your moon (throws if a moon with the same name already exists) |
| Unr
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。
下面這些內容需要先安裝,否則該模組不會生效: