-
Notifications
You must be signed in to change notification settings - Fork 37
Coordinated Spawns
Coordinated Spawns system allows you to spawn entities via world positions and rotations instead of the traditional LootDistribution
system the game uses.
SMLHelper introduces a new handler named CoordinatedSpawnsHandler
under the SMLHelper.V2.Handlers
namespace, which registers spawns to the system.
SpawnInfo |
---|
Registers a Coordinated Spawn.
-
SpawnInfo spawnInfo
Information about where and what entity should spawn.
Registers multiple Coordinated Spawns.
RegisterCoordinatedSpawnsForOneTechType(TechType techTypeToSpawn, List<Vector3> coordinatesToSpawnTo)
Registers multiple Coordinated Spawns for one single passed TechType.
-
TechType
techTypeToSpawn
TechType entity to spawn. -
List<Vector3>
coordinatesToSpawnTo
World positions to spawn to.
RegisterCoordinatedSpawnsForOneTechType(TechType techTypeToSpawn, Dictionary<Vector3, Vector3> coordinatesAndRotationsToSpawnTo)
[Deprecated]
Registers multiple Coordinated Spawns with rotations for one single passed TechType.
-
TechType
techTypeToSpawn
TechType entity to spawn. -
Dictionary<Vector3, Vector3>
coordinatesAndRotationsToSpawnTo
The world positions (key) and rotations (value) the entity should spawn to.
This method existed prior to Spawnable.SpawnLocation
and was only used in the Spawnable
class.
Usage of this method is ill-advised as the SpawnInfo already covers all use-cases.
The following examples demonstrate the usage of CoordinatedSpawnsHandler
methods.
using SMLHelper.V2.Handlers;
using UnityEngine;
[QModCore]
public static class MyMainClass
{
[QModPatch]
public static void MyPatch()
{
SpawnInfo reaperInfo = new SpawnInfo(TechType.ReaperLeviathan, new Vector3(280f, -1400f, 47f)); // Lava Lakes
CoordinatedSpawnsHandler.RegisterCoordinatedSpawn(reaperInfo);
var spawnInfos = new List<SpawnInfo>()
{
new SpawnInfo(TechType.Seamoth, Vector3.zero),
new SpawnInfo(TechType.SandShark, new Vector3(10, -4, 5), Vector3.up * 90f) // rotate its Y axis 90 degrees
}
CoordinatedSpawnsHandler.RegisterCoordinatedSpawns(spawnInfos);
// Spawns a batch of titaniums around 10, -3, 15 world position
var randomPositions = RandomPositions(new vector3(10f, -3f, 15f));
CoordinatedSpawnsHandler.RegisterCoordinatedSpawnsForOneTechType(
TechType.Titanium, randomPositions);
}
// Gets 5 random positions around the passed location.
private static List<Vector3> RandomPositions(Vector3 centerPosition)
{
var result = new List<Vector3>();
for (int i = 0; i < 5; i++)
{
result.Add(centerPosition + (Random.insideUnitSphere * i));
}
return result;
}
}
Provides sufficient information for the Coordinated Spawns system to function.
public struct SpawnInfo : IEquatable<SpawnInfo>
SpawnInfo(TechType techType, Vector3 spawnPosition) |
---|
SpawnInfo(string classId, Vector3 spawnPosition) |
SpawnInfo(TechType techType, Vector3 spawnPosition, Quaternion rotation) |
SpawnInfo(string classId, Vector3 spawnPosition, Quaternion rotation) |
SpawnInfo(TechType techType, Vector3 spawnPosition, Vector3 rotation) |
SpawnInfo(string classId, Vector3 spawnPosition, Vector3 rotation) |
If there is something missing or ambiguous, please create an issue or contact us on the Subnautica Modding Discord using our tags:
- PrimeSonic:
@PrimeSonic#0667
- Metious:
@Metious#3682
Please note that some pages are under construction and the links to them will be enabled as they are completed
[Adding]
- Items/GameObjects using Asset Classes
- Asynchronous loading for ModPrefab
- [Custom Scanner Unlocks]
- Items/GameObjects to the Spawning System
- [Recipes to uncraftable items]
- [Custom Mouse Click Actions]
[Editing]
- Background Type
- Crafting Time
- Equipment Type
- Quick Slot Type
- Size in Inventory
- [Recipes for craftable items]
- Harvest Settings
- BioReactor Fuel Values
- [Scanning Count/Time]
- [Spawning (Where/How often/How many)]
[General Utilities]
- In-Game Options Menu
- Adding crafting recipes for other mods items
- Using items from other mods
- Texture/Sprite Utilities
- [Adding/Playing Audio]
- Config Files using Abstract Json Config class
- Custom Console Commands
- [Registering OnSave/OnQuit Actions]
[Language]