diff --git a/Nautilus/Assets/PrefabInfo.cs b/Nautilus/Assets/PrefabInfo.cs
index 9562621d..8b05d0a2 100644
--- a/Nautilus/Assets/PrefabInfo.cs
+++ b/Nautilus/Assets/PrefabInfo.cs
@@ -48,7 +48,7 @@ public static PrefabInfo WithTechType(string classId, bool unlockAtStart = false
/// The display name of this Tech Type, can be anything. If null or empty, this will use the language line "{enumName}" instead.
/// The tooltip displayed when hovered in the PDA, can be anything. If null or empty, this will use the language line "Tooltip_{enumName}" instead.
/// The language for this entry. Defaults to English.
- /// Whether this tech type should be unlocked on game start or not. Default to
++ - <RootNamespace>SMLHelper.V2</RootNamespace> + <RootNamespace>Nautilus</RootNamespace> +## Referencing @@ -23,7 +25,8 @@ mentioned in your code. ### Handler.cs Following the handler interfaces change, the overly under-used `Handler` class will leave us in Nautilus -++ // Handler.cs - namespace SMLHelper.V2 @@ -45,6 +48,7 @@ Following the handler interfaces change, the overly under-used `Handler` class w - ... - } +
### BioReactorHandler @@ -52,9 +56,11 @@ The `BioReactorHandler` class is removed in Nautilus because it only had one ver SML's entry point, it didn't get applied. The following example demonstrates how you can implement the same functionality the `BioReactorHandler` class offered. -++ - BioReactorHandler.SetBioreactorCharge(TechType.Peeper, 69f); + BaseBioReactor.charge[TechType.Peeper] = 69f; +### FishHandler @@ -63,7 +69,8 @@ The `FishHandler` has been removed in Nautilus. At the time being, we have not a ### PDAEncyclopediaHandler And PDALogHandler Beginning with Nautilus, both of these handler methods were moved to `PDAHandler` as they only had one method each. -++ PDAEncyclopedia.EntryData entry = new PDAEncyclopedia.EntryData() { key = "SomeEncy", @@ -76,13 +83,16 @@ PDAEncyclopedia.EntryData entry = new PDAEncyclopedia.EntryData() - PDALogHandler.AddCustomEntry("SomeLog", "SomeLanguageKey"); + PDAHandler.AddLogEntry("SomeLog", "SomeLanguageKey"); +### InGameMenuHandler The methods `InGameMenuHandler` class had have been moved to the `Nautilus.Utility` namespace and the class has been renamed to `SaveUtils`. -++ - InGameMenuHandler.RegisterOnSaveEvent(() => ErrorMessage.AddMessage("We do be saving!")); + SaveUtils.RegisterOnSaveEvent(() => ErrorMessage.AddMessage("We do be saving!")); +## Enum Handlers @@ -117,35 +127,44 @@ Below we will talk about the necessary changes you will need to make your custom ### Configuring Custom TechType Objects -++ - TechType customTech = TechTypeHandler.AddTechType("CustomTech", "Custom Tech", "Custom Tech that makes me go yes.", SpriteManager.Get(TechType.Titanium), unlockedAtStart: false); + TechType customTech = EnumHandler.AddEntry<TechType>("CustomTech") + .WithPdaInfo("Custom Tech", "Custom Tech that makes me go yes.", unlockedAtStart: false) + .WithIcon(SpriteManager.Get(TechType.Titanium)); +### Configuring Custom CraftData.BackgroundType Objects -++ - CraftData.BackgroundType customBG = BackgroundTypeHandler.AddBackgroundType("CustomBackground", SpriteManager.GetBackground(TechType.Battery)); + CraftData.BackgroundType customBG = EnumHandler.AddEntry<CraftData.BackgroundType>("CustomBackground") + .WithBackground(SpriteManager.GetBackground(TechType.Battery)); +### Configuring Custom EquipmentType Objects -++ - EquipmentType customEquipment = EquipmentHandler.AddEquipmentType("CustomEquipment"); + EquipmentType customEquipment = EnumHandler.AddEntry<EquipmentType>("CustomEquipment"); +### Configuring Custom PingType Objects -++ - PingType customPing = PingHandler.RegisterNewPingType("CustomPing", SpriteManager.Get(SpriteManager.Group.Pings, PingType.Signal.ToString())); + PingType customPing = EnumHandler.AddEntry<PingType>("CustomPing") + .WithIcon(SpriteManager.Get(SpriteManager.Group.Pings, PingType.Signal.ToString())); +### Configuring Custom TechCategory and TechGroup Objects -++ - TechGroup customGroup = TechGroupHandler.AddTechCategory("CustomGroup", "Custom Group"); + TechGroup customGroup = EnumHandler.AddEntry<TechCategory>("CustomGroup").WithPdaInfo("Custom Group"); @@ -153,15 +172,18 @@ Below we will talk about the necessary changes you will need to make your custom - TechCategoryHandler.TryRegisterTechCategoryToTechGroup(customGroup, customCategory); + TechCategory customCategory = EnumHandler.AddEntry<TechCategory>("CustomCategory").WithPdaInfo("Custom Group") + .RegisterToTechGroup(customGroup); +### Configuring Custom CraftTree.Type Objects -++ - ModCraftTreeRoot root = CraftTreeHandler.CreateCustomCraftTreeAndType(CustomTree, out CraftTree.Type customTree); + CraftTree.Type customTree = EnumHandler.AddEntry<CraftTree.Type>("CustomTree") + .CreateCraftTreeRoot(out ModCraftTreeRoot root); root.AddTabNode("SomeTab"); +___ @@ -512,7 +534,8 @@ Since we discovered the best practices and better ways to deal with custom sound Beginning with Nautilus, all custom sounds will require a bus instead of a SoundChannel to determine the effects (E.G: reverb, muffling, low-pass, etc..) and the volume slider. Additionally, the `PlaySound` signature was also modified and renamed to `TryPlaySound`. -++ - Channel channel = AudioUtils.PlaySound(soundPath, SoundChannel.Music); + if (AudioUtils.TryPlaySound(soundPath, AudioUtils.BusPaths.Music, out Channel channel)) + { @@ -540,6 +563,7 @@ Additionally, the `PlaySound` signature was also modified and renamed to `TryPla + // do something with channel + } +> [!WARNING] diff --git a/Nautilus/Handlers/CoordinatedSpawnsHandler.cs b/Nautilus/Handlers/CoordinatedSpawnsHandler.cs index 44141bdd..150da21d 100644 --- a/Nautilus/Handlers/CoordinatedSpawnsHandler.cs +++ b/Nautilus/Handlers/CoordinatedSpawnsHandler.cs @@ -77,6 +77,7 @@ public struct SpawnInfo : IEquatableinternal Vector3 Scale { get; } // For the sake of backwards compatibility, a scale of 0x0x0 is automatically converted to 1x1x1. Sorry, no 0x scale entities allowed. internal Vector3 ActualScale => Scale == default ? Vector3.one : Scale; + internal Action OnSpawned { get; } /// /// Initializes a new . @@ -84,7 +85,7 @@ public struct SpawnInfo : IEquatable /// TechType to spawn. /// Position to spawn into. public SpawnInfo(TechType techType, Vector3 spawnPosition) - : this(default, techType, spawnPosition, Quaternion.identity, Vector3.one) { } + : this(default, techType, spawnPosition, Quaternion.identity, Vector3.one, null) { } /// /// Initializes a new . @@ -92,7 +93,7 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition) /// ClassID to spawn. /// Position to spawn into. public SpawnInfo(string classId, Vector3 spawnPosition) - : this(classId, default, spawnPosition, Quaternion.identity, Vector3.one) { } + : this(classId, default, spawnPosition, Quaternion.identity, Vector3.one, null) { } /// /// Initializes a new . @@ -101,7 +102,7 @@ public SpawnInfo(string classId, Vector3 spawnPosition) /// Position to spawn into. /// Rotation to spawn at. public SpawnInfo(TechType techType, Vector3 spawnPosition, Quaternion rotation) - : this(default, techType, spawnPosition, rotation, Vector3.one) { } + : this(default, techType, spawnPosition, rotation, Vector3.one, null) { } /// /// Initializes a new . @@ -110,7 +111,7 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition, Quaternion rotation) /// Position to spawn into. /// Rotation to spawn at. public SpawnInfo(string classId, Vector3 spawnPosition, Quaternion rotation) - : this(classId, default, spawnPosition, rotation, Vector3.one) { } + : this(classId, default, spawnPosition, rotation, Vector3.one, null) { } /// /// Initializes a new . @@ -120,7 +121,7 @@ public SpawnInfo(string classId, Vector3 spawnPosition, Quaternion rotation) /// Rotation to spawn at. /// Scale to spawn with. public SpawnInfo(TechType techType, Vector3 spawnPosition, Quaternion rotation, Vector3 scale) - : this(default, techType, spawnPosition, rotation, scale) { } + : this(default, techType, spawnPosition, rotation, scale, null) { } /// /// Initializes a new . @@ -130,7 +131,7 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition, Quaternion rotation, /// Rotation to spawn at. /// Scale to spawn with. public SpawnInfo(string classId, Vector3 spawnPosition, Quaternion rotation, Vector3 scale) - : this(classId, default, spawnPosition, rotation, scale) { } + : this(classId, default, spawnPosition, rotation, scale, null) { } /// /// Initializes a new . @@ -139,7 +140,7 @@ public SpawnInfo(string classId, Vector3 spawnPosition, Quaternion rotation, Vec /// Position to spawn into. /// Rotation to spawn at. public SpawnInfo(TechType techType, Vector3 spawnPosition, Vector3 rotation) - : this(default, techType, spawnPosition, Quaternion.Euler(rotation), Vector3.one) { } + : this(default, techType, spawnPosition, Quaternion.Euler(rotation), Vector3.one, null) { } /// /// Initializes a new . @@ -148,7 +149,7 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition, Vector3 rotation) /// Position to spawn into. /// Rotation to spawn at. public SpawnInfo(string classId, Vector3 spawnPosition, Vector3 rotation) - : this(classId, default, spawnPosition, Quaternion.Euler(rotation), Vector3.one) { } + : this(classId, default, spawnPosition, Quaternion.Euler(rotation), Vector3.one, null) { } /// /// Initializes a new . @@ -158,7 +159,7 @@ public SpawnInfo(string classId, Vector3 spawnPosition, Vector3 rotation) /// Rotation to spawn at. /// Scale to spawn with. public SpawnInfo(TechType techType, Vector3 spawnPosition, Vector3 rotation, Vector3 scale) - : this(default, techType, spawnPosition, Quaternion.Euler(rotation), scale) { } + : this(default, techType, spawnPosition, Quaternion.Euler(rotation), scale, null) { } /// /// Initializes a new . @@ -168,10 +169,32 @@ public SpawnInfo(TechType techType, Vector3 spawnPosition, Vector3 rotation, Vec /// Rotation to spawn at. /// Scale to spawn with. public SpawnInfo(string classId, Vector3 spawnPosition, Vector3 rotation, Vector3 scale) - : this(classId, default, spawnPosition, Quaternion.Euler(rotation), scale) { } + : this(classId, default, spawnPosition, Quaternion.Euler(rotation), scale, null) { } + + /// + /// Initializes a new + /// TechType to spawn. + /// Position to spawn into. + /// Rotation to spawn at. + /// Scale to spawn with. + /// Callback that is used when the object is successfully spawned. + public SpawnInfo(TechType techType, Vector3 spawnPosition, Quaternion rotation, Vector3 scale, Action. + /// onSpawned) + : this(default, techType, spawnPosition, rotation, scale, onSpawned) { } + /// + /// Initializes a new + /// ClassID to spawn. + /// Position to spawn into. + /// Rotation to spawn at. + /// Scale to spawn with. + /// Callback that is used when the object is successfully spawned. + public SpawnInfo(string classId, Vector3 spawnPosition, Quaternion rotation, Vector3 scale, Action. + /// onSpawned) + : this(classId, default, spawnPosition, rotation, scale, onSpawned) { } + [JsonConstructor] - internal SpawnInfo(string classId, TechType techType, Vector3 spawnPosition, Quaternion rotation, Vector3 scale) + internal SpawnInfo(string classId, TechType techType, Vector3 spawnPosition, Quaternion rotation, Vector3 scale, Action onSpawned) { ClassId = classId; TechType = techType; @@ -183,6 +206,7 @@ internal SpawnInfo(string classId, TechType techType, Vector3 spawnPosition, Qua _ => SpawnType.TechType }; Scale = scale; + OnSpawned = onSpawned; } /// diff --git a/Nautilus/Handlers/PrefabHandler.cs b/Nautilus/Handlers/PrefabHandler.cs index 95708b8a..ffc219f2 100644 --- a/Nautilus/Handlers/PrefabHandler.cs +++ b/Nautilus/Handlers/PrefabHandler.cs @@ -60,7 +60,6 @@ private static IEnumerator InitPrefabAsync(TaskResult gameObject, Pr InternalLogger.Error($"PrefabHandler: PrefabFactory returned null for {info.ClassID}"); yield break; } - obj.SetActive(false); var techType = info.TechType; var classId = info.ClassID; diff --git a/Nautilus/MonoBehaviours/EntitySpawner.cs b/Nautilus/MonoBehaviours/EntitySpawner.cs index f4826d74..4edda351 100644 --- a/Nautilus/MonoBehaviours/EntitySpawner.cs +++ b/Nautilus/MonoBehaviours/EntitySpawner.cs @@ -68,6 +68,8 @@ private IEnumerator SpawnAsync() obj.SetActive(true); + spawnInfo.OnSpawned?.Invoke(obj); + LargeWorldEntity.Register(obj); LargeWorldStreamerPatcher.SavedSpawnInfos.Add(spawnInfo); diff --git a/Nautilus/docfx.json b/Nautilus/docfx.json index 8f09e998..f0f2cdc4 100644 --- a/Nautilus/docfx.json +++ b/Nautilus/docfx.json @@ -66,7 +66,7 @@ "template": [ "default", "modern", - "DocFX/template" + "DocFX/custom" ] } } \ No newline at end of file diff --git a/Version.targets b/Version.targets index 22d11afd..14b34be0 100644 --- a/Version.targets +++ b/Version.targets @@ -3,7 +3,7 @@ \ No newline at end of file 1.0.0 -30 +32 pre.$(SuffixNumber)