feat: coal world gen + world gen test framework
This commit is contained in:
parent
082bcba90c
commit
417f4923e7
6 changed files with 105 additions and 18 deletions
54
Content/Systems/WorldGenSystem.cs
Normal file
54
Content/Systems/WorldGenSystem.cs
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
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>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ using Terraria;
|
||||||
using Terraria.ID;
|
using Terraria.ID;
|
||||||
using Terraria.Localization;
|
using Terraria.Localization;
|
||||||
using Terraria.ModLoader;
|
using Terraria.ModLoader;
|
||||||
|
using Terraria.WorldBuilding;
|
||||||
|
|
||||||
namespace continuity.Content.Tiles
|
namespace continuity.Content.Tiles
|
||||||
{
|
{
|
||||||
|
@ -30,4 +31,5 @@ namespace continuity.Content.Tiles
|
||||||
HitSound = SoundID.Tink;
|
HitSound = SoundID.Tink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,5 @@ Items: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Tiles.CoalTile.MapEntry: Coal Tile
|
Tiles.CoalTile.MapEntry: Coal
|
||||||
|
WorldGen.CoalGenMessage: "Industrializing the World"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"Terraria": {
|
"Terraria": {
|
||||||
"commandName": "Executable",
|
"commandName": "Executable",
|
||||||
"executablePath": "/etc/profiles/per-user/devraza/bin/dotnet",
|
"executablePath": "$(DotNetName)",
|
||||||
"commandLineArgs": "$(tMLPath)",
|
"commandLineArgs": "$(tMLPath)",
|
||||||
"workingDirectory": "$(tMLSteamPath)"
|
"workingDirectory": "$(tMLSteamPath)"
|
||||||
},
|
},
|
||||||
|
|
33
Utilities/WorldGenWorld.cs
Normal file
33
Utilities/WorldGenWorld.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// DEBUG WorldGen System for testing
|
||||||
|
using Terraria;
|
||||||
|
using Terraria.ModLoader;
|
||||||
|
using Microsoft.Xna.Framework.Input;
|
||||||
|
using Terraria.ID;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Terraria.GameContent.Generation;
|
||||||
|
using continuity.Content.Tiles;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
namespace continuity.Utilities
|
||||||
|
{
|
||||||
|
public class WorldGenWorld : ModSystem
|
||||||
|
{
|
||||||
|
public static bool JustPressed(Keys key) {
|
||||||
|
return Main.keyState.IsKeyDown(key) && !Main.oldKeyState.IsKeyDown(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PostUpdateWorld() {
|
||||||
|
if (JustPressed(Keys.D1))
|
||||||
|
TestMethod((int)Main.MouseWorld.X / 16, (int)Main.MouseWorld.Y / 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
// implement whatever test code you want here.
|
||||||
|
private void TestMethod(int x, int y) {
|
||||||
|
Dust.QuickBox(new Vector2(x, y) * 16, new Vector2(x + 1, y + 1) * 16, 2, Color.YellowGreen, null);
|
||||||
|
|
||||||
|
// Code to test placed here:
|
||||||
|
WorldGen.OreRunner(x, y, 8, 2, (ushort)ModContent.TileType<CoalTile>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -9,8 +9,5 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- References -->
|
<!-- References -->
|
||||||
<ItemGroup>
|
|
||||||
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Reference in a new issue