/// <summary> /// Registers a CustomFish object into the game /// </summary> /// <param name="fish">The CustomFish that you are registering</param> /// <returns>The TechType created using the info from your CustomFish object</returns> public static TechType RegisterFish(CustomFish fish) { Logger.Log($"[FishFramework] Creating fish: {fish.displayName}"); TechType type = TechTypeHandler.AddTechType(fish.id, fish.displayName, fish.tooltip); fishTechTypes.Add(type); CustomFishPrefab fishPrefab = new CustomFishPrefab(fish.id, $"WorldEntities/Tools/{fish.id}", type) { modelPrefab = fish.modelPrefab, swimSpeed = fish.swimSpeed, swimRadius = fish.swimRadius, swimInterval = fish.swimInterval, pickupable = fish.isPickupable, isWaterCreature = fish.isWaterCreature }; if (!string.IsNullOrEmpty(fish.spriteFileName)) { SpriteHandler.RegisterSprite(type, Path.Combine(Environment.CurrentDirectory + "/QMods/", fish.spriteFileName)); } PrefabHandler.RegisterPrefab(fishPrefab); return(type); }
public static void Patch() { bundle = AssetBundle.LoadFromFile(Path.Combine(Environment.CurrentDirectory, "QMods/MinecraftFish/fishassets")); TropicalFishGenerator.Init(); CustomFish cod = new CustomFish(); cod.id = "MineCod"; cod.displayName = "Cod"; cod.tooltip = "The classic, blocky, tasty fish"; cod.bundle = bundle; cod.fileName = "Assets/Prefabs/CodFish.prefab"; cod.scale = 0.07f; cod.isPickupable = true; cod.swimRadius = Vector3.one * 10f; cod.swimSpeed = 7f; cod.Register(); int index = 0; foreach (string tropicalPrefab in TropicalFishGenerator.tropicalFishPrefabFiles) { Console.WriteLine($"[MinecraftFish] Creating tropical fish with filename: {tropicalPrefab}"); CustomFish tropical = new CustomFish(); tropical.id = "Tropical" + index; index++; tropical.displayName = "Tropical Fish"; tropical.tooltip = "A lovely colourful tropical fish"; tropical.bundle = bundle; tropical.fileName = tropicalPrefab; tropical.scale = 0.07f; tropical.isPickupable = true; tropical.swimRadius = Vector3.one * 10f; tropical.swimSpeed = 7f; tropical.components = new List <Type> { typeof(TropicalFish) }; tropical.Register(); } }