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 . + /// Whether this tech type should be unlocked on game start or not. Defaults to . /// The assembly that owns the created tech type. The name of this assembly will be shown in the PDA. /// An instance of the constructed . public static PrefabInfo WithTechType(string classId, string displayName, string description, string language = "English", bool unlockAtStart = false, Assembly techTypeOwner = null) @@ -109,4 +109,4 @@ public PrefabInfo WithFileName(string fileName) { return this with {PrefabFileName = fileName}; } -} \ No newline at end of file +} diff --git a/Nautilus/Crafting/TabNode.cs b/Nautilus/Crafting/TabNode.cs index 06b7b937..369939bb 100644 --- a/Nautilus/Crafting/TabNode.cs +++ b/Nautilus/Crafting/TabNode.cs @@ -23,9 +23,9 @@ internal TabNode(string[] path, CraftTree.Type scheme, Sprite sprite, string nam Sprite = sprite; DisplayName = displayName; Name = name; - Id = $"{Scheme.ToString()}_{Name}"; + Id = $"{Scheme.ToString()}Menu_{Name}"; - ModSprite.Add(new ModSprite(SpriteManager.Group.Category, Id, Sprite)); + ModSprite.Add(new ModSprite(SpriteManager.Group.Category, $"{Scheme.ToString()}_{Name}", Sprite)); if (!string.IsNullOrEmpty(displayName)) { diff --git a/Nautilus/DocFX/template/styles/days_one.ttf b/Nautilus/DocFX/custom/public/days_one.ttf similarity index 100% rename from Nautilus/DocFX/template/styles/days_one.ttf rename to Nautilus/DocFX/custom/public/days_one.ttf diff --git a/Nautilus/DocFX/template/styles/main.css b/Nautilus/DocFX/custom/public/main.css similarity index 85% rename from Nautilus/DocFX/template/styles/main.css rename to Nautilus/DocFX/custom/public/main.css index d1d4d83e..717703dd 100644 --- a/Nautilus/DocFX/template/styles/main.css +++ b/Nautilus/DocFX/custom/public/main.css @@ -3,16 +3,12 @@ src: url("days_one.ttf"); } -[data-bs-theme=dark] .lang-diff { - background: #0d1117; -} - .lang-diff-rem { color: rgb(236, 89, 117); } .lang-diff-add { - color: rgb(62, 175, 124);; + color: rgb(62, 175, 124); } @media (min-width: 1600px) { diff --git a/Nautilus/Documentation/guides/sml2-to-nautilus.md b/Nautilus/Documentation/guides/sml2-to-nautilus.md index b415d3e2..816c8101 100644 --- a/Nautilus/Documentation/guides/sml2-to-nautilus.md +++ b/Nautilus/Documentation/guides/sml2-to-nautilus.md @@ -4,9 +4,11 @@ In this article, we will be talking about the necessary changes you must apply t ## Namespace The root namespace for Nautilus is not the same as SMLHelper 2.0. -
+
+
 - <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 : IEquatable internal 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 @@ 1.0.0 - 30 + 32 pre.$(SuffixNumber) \ No newline at end of file