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/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/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/Version.targets b/Version.targets index 5e7bd9cd..14b34be0 100644 --- a/Version.targets +++ b/Version.targets @@ -3,7 +3,7 @@ 1.0.0 - 31 + 32 pre.$(SuffixNumber) \ No newline at end of file