TechbloxModdingAPI/CodeGenerator/MakeEverythingPublicInGame.cs
Norbi Peti 23439abde3
Add new blocks and materials, make every type public in the game, fix entity publish
- Probably should've committed more
- Added new block IDs and a material (also fixed material names)
- Added missing player states
- Added a class to make every type public in the game's code, so we don't need to worry about internal components
- We don't need to worry about anticheat so it should be fine - will need to be made into its own exe though
- Fixed delayed entity publishing and set the limits based on the consumers (just 30 almost everywhere)
2022-10-04 01:47:09 +02:00

36 lines
1.1 KiB
C#

using System;
using System.IO;
using System.Reflection.Metadata;
using System.Text.RegularExpressions;
using Mono.Cecil;
using ModuleDefinition = Mono.Cecil.ModuleDefinition;
namespace CodeGenerator
{
public class MakeEverythingPublicInGame
{
public void Start()
{
Console.WriteLine("Starting assembly editing...");
var fileRegex =
new Regex(".*(Techblox|Gamecraft|RobocraftX|FullGame|RobocraftECS|DataLoader|RCX|GameState)[^/]*(\\.dll)");
foreach (var file in Directory.EnumerateFiles(@"../../../../../ref/Techblox_Data/Managed"))
{
if (!fileRegex.IsMatch(file)) continue;
Console.WriteLine(file);
ProcessAssembly(file);
}
}
public void ProcessAssembly(string path)
{
var mod = ModuleDefinition.ReadModule(path, new(ReadingMode.Immediate) { ReadWrite = true });
foreach (var typeDefinition in mod.Types)
{
typeDefinition.Attributes |= TypeAttributes.Public;
}
mod.Write();
}
}
}