/// <summary> /// Initializes a new <see cref="Spawnable"/>, the basic class needed for any item that can be spawned into the Subnautica game world. /// </summary> /// <param name="classId">The main internal identifier for this item. Your item's <see cref="TechType"/> will be created using this name.</param> /// <param name="friendlyName">The name displayed in-game for this item whether in the open world or in the inventory.</param> /// <param name="description">The description for this item; Typically seen in the PDA, inventory, or crafting screens.</param> protected Spawnable(string classId, string friendlyName, string description) : base(classId, $"{classId}Prefab") { if (string.IsNullOrEmpty(classId)) { Logger.Log($"ClassID for Spawnables must be a non-empty value.", LogLevel.Error); throw new ArgumentException($"Error patching Spawnable"); } FriendlyName = friendlyName; Description = description; CorePatchEvents += () => { PrefabHandler.RegisterPrefab(this); SpriteHandler.RegisterSprite(TechType, GetItemSprite()); if (!SizeInInventory.Equals(defaultSize)) { CraftDataHandler.SetItemSize(TechType, SizeInInventory); } if (EntityInfo != null && BiomesToSpawnIn != null) { LootDistributionHandler.AddLootDistributionData(this, BiomesToSpawnIn, EntityInfo); } else if (EntityInfo != null) { WorldEntityDatabaseHandler.AddCustomInfo(ClassID, EntityInfo); } }; }
/// <summary> /// Initializes a new <see cref="Spawnable"/>, the basic class needed for any item that can be spawned into the Subnautica game world. /// </summary> /// <param name="classId">The main internal identifier for this item. Your item's <see cref="TechType"/> will be created using this name.</param> /// <param name="friendlyName">The name displayed in-game for this item whether in the open world or in the inventory.</param> /// <param name="description">The description for this item; Typically seen in the PDA, inventory, or crafting screens.</param> protected Spawnable(string classId, string friendlyName, string description) : base(classId, $"{classId}Prefab") { if (string.IsNullOrEmpty(classId)) { Logger.Log($"ClassID for Spawnables must be a non-empty value.", LogLevel.Error); throw new ArgumentException($"Error patching Spawnable"); } FriendlyName = friendlyName; Description = description; CorePatchEvents += () => { PrefabHandler.RegisterPrefab(this); #if SUBNAUTICA SpriteHandler.RegisterSprite(TechType, GetItemSprite()); #elif BELOWZERO CoroutineHost.StartCoroutine(RegisterSpriteAsync()); #endif if (!SizeInInventory.Equals(defaultSize)) { CraftDataHandler.SetItemSize(TechType, SizeInInventory); } if (EntityInfo != null) { if (BiomesToSpawnIn != null) { LootDistributionHandler.AddLootDistributionData(this, BiomesToSpawnIn, EntityInfo); } else { WorldEntityDatabaseHandler.AddCustomInfo(ClassID, EntityInfo); } } if (CoordinatedSpawns != null) { foreach (var(position, eulerAngles) in CoordinatedSpawns) { CoordinatedSpawnsHandler.RegisterCoordinatedSpawn(new SpawnInfo(TechType, position, eulerAngles)); } } }; }