This repository has been archived on 2024-12-27. You can view files and clone it, but cannot push or open issues or pull requests.
continuity/Content/Systems/WorldGenSystem.cs

54 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria.ID;
using Terraria;
using Terraria.IO;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.WorldBuilding;
using Continuity.Content.Tiles;
namespace Continuity.Content.Systems
{
public class WorldGenSystem : ModSystem
{
public static LocalizedText CoalGenMessage { get; private set; }
public override void SetStaticDefaults()
{
CoalGenMessage = Language.GetOrRegister(Mod.GetLocalizationKey($"WorldGen.{nameof(CoalGenMessage)}"));
}
public override void ModifyWorldGenTasks(List<GenPass> tasks, ref double totalWeight)
{
int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies"));
if (ShiniesIndex != -1)
{
tasks.Insert(ShiniesIndex + 1, new CoalGenPass("Adding Coal to the surface layer of the world", 100));
}
}
}
public class CoalGenPass : GenPass
{
public CoalGenPass(string name, float loadWeight) : base(name, loadWeight) { }
protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
{
progress.Message = WorldGenSystem.CoalGenMessage.Value;
for (int k = 0; k < (int)((Main.maxTilesX * Main.maxTilesY) * 1E-03); k++)
{
int x = WorldGen.genRand.Next(0, Main.maxTilesX);
int y = WorldGen.genRand.Next((int)GenVars.rockLayerHigh, Main.maxTilesY);
WorldGen.OreRunner(x, y, 8, 2, (ushort)ModContent.TileType<CoalTile>());
}
}
}
}