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)
This commit is contained in:
Norbi Peti 2022-10-04 01:47:09 +02:00
parent 5e90c5ee26
commit 23439abde3
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
10 changed files with 105 additions and 45 deletions

View file

@ -20,6 +20,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Lib.Harmony" Version="2.0.4" /> <PackageReference Include="Lib.Harmony" Version="2.0.4" />
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
<PackageReference Include="System.CodeDom" Version="7.0.0-preview.2.22152.2" /> <PackageReference Include="System.CodeDom" Version="7.0.0-preview.2.22152.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -0,0 +1,36 @@
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();
}
}
}

View file

@ -11,6 +11,13 @@ namespace CodeGenerator
internal class Program internal class Program
{ {
public static void Main(string[] args) public static void Main(string[] args)
{
GenerateBlockClasses();
var mepig = new MakeEverythingPublicInGame();
mepig.Start();
}
private static void GenerateBlockClasses()
{ {
var bcg = new BlockClassGenerator(); var bcg = new BlockClassGenerator();
bcg.Generate("Engine", null, new Dictionary<string, string> bcg.Generate("Engine", null, new Dictionary<string, string>

View file

@ -302,6 +302,7 @@ namespace TechbloxModdingAPI.Blocks
FloodLight, FloodLight,
SoccerBall, SoccerBall,
CircularWallLight, CircularWallLight,
BlueSkyAtmos,
DirtToGrassTransitionTile = 393, DirtToGrassTransitionTile = 393,
DirtToGrassTransitionInnerTile, DirtToGrassTransitionInnerTile,
DirtToGrassTransitionOuterTile, DirtToGrassTransitionOuterTile,
@ -362,10 +363,21 @@ namespace TechbloxModdingAPI.Blocks
SmallGridHill, SmallGridHill,
SmallGridHillInnerCorner, SmallGridHillInnerCorner,
SmallGridHillOuterCorner, SmallGridHillOuterCorner,
Vector7SmallJet = 460, AimingAxleServo,
AimingHingeServo,
WeaponDisabler,
Vector7SmallJet,
Vector7MediumJet, Vector7MediumJet,
Vector7LargeJet, Vector7LargeJet,
Vector7XLJet, Vector7XLJet,
Vector7XXLJet Vector7XXLJet,
APCWheelRigNoSteering,
APCWheelRigWithSteering,
APCWheel,
APCSeat,
APCEngine,
DamageScoreBlock,
KillScoreBlock,
Autocannon = 480
} }
} }

View file

@ -33,13 +33,14 @@ namespace TechbloxModdingAPI.Blocks
WoodRoughGrungy, WoodRoughGrungy,
Boundary, Boundary,
Emissive, Emissive,
AircraftPaneling_Riveted_Painted, AircraftPanelingRivetedPainted,
AircraftPaneling_Riveted_Metallic, AircraftPanelingRivetedMetallic,
Steel_Bodywork_Pearlescent, SteelBodyworkPearlescent,
Steel_Bodywork_RadWrap, SteelBodyworkRadWrap,
Steel_Bodywork_Glitter, SteelBodyworkGlitter,
BouncyRubber, BouncyRubber,
BouncyRubber_TieDye, BouncyRubberTieDye,
FuturisticPaneling_Riveted_Painted = 40 BrickPainted,
FuturisticPanelingRivetedPainted,
} }
} }

View file

@ -80,7 +80,6 @@ namespace TechbloxModdingAPI.Blocks
yield break; yield break;
for (var index = 0; index < blocks.Length; index++) for (var index = 0; index < blocks.Length; index++)
{ {
if (index % 10 == 0) yield return new WaitForSecondsEnumerator(1f).Continue(); //The material or flipped status can only be changed 130 times per submission
var block = blocks[index]; var block = blocks[index];
if (!block.Exists) continue; if (!block.Exists) continue;
foreach (var property in block.GetType().GetProperties()) foreach (var property in block.GetType().GetProperties())

View file

@ -30,11 +30,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((bool)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "engineOn"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).engineOn;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "engineOn", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).engineOn = value;
} }
} }
@ -45,11 +45,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((int)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentGear"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).currentGear;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentGear", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).currentGear = value;
} }
} }
@ -60,11 +60,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "gearChangeCountdown"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).gearChangeCountdown;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "gearChangeCountdown", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).gearChangeCountdown = value;
} }
} }
@ -75,11 +75,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentRpmAV"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).currentRpmAV;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentRpmAV", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).currentRpmAV = value;
} }
} }
@ -90,11 +90,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentRpmLV"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).currentRpmLV;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentRpmLV", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).currentRpmLV = value;
} }
} }
@ -105,11 +105,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "targetRpmAV"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).targetRpmAV;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "targetRpmAV", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).targetRpmAV = value;
} }
} }
@ -120,11 +120,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "targetRpmLV"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).targetRpmLV;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "targetRpmLV", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).targetRpmLV = value;
} }
} }
@ -135,11 +135,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentTorque"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).currentTorque;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentTorque", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).currentTorque = value;
} }
} }
@ -150,11 +150,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelVelocityAV"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).totalWheelVelocityAV;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelVelocityAV", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).totalWheelVelocityAV = value;
} }
} }
@ -165,11 +165,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelVelocityLV"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).totalWheelVelocityLV;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelVelocityLV", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).totalWheelVelocityLV = value;
} }
} }
@ -180,11 +180,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((int)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelCount"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).totalWheelCount;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelCount", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).totalWheelCount = value;
} }
} }
@ -195,11 +195,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((bool)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "lastGearUpInput"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).lastGearUpInput;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "lastGearUpInput", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).lastGearUpInput = value;
} }
} }
@ -210,11 +210,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((bool)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "lastGearDownInput"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).lastGearDownInput;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "lastGearDownInput", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).lastGearDownInput = value;
} }
} }
@ -225,11 +225,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "manualToAutoGearCoolOffCounter"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).manualToAutoGearCoolOffCounter;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "manualToAutoGearCoolOffCounter", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).manualToAutoGearCoolOffCounter = value;
} }
} }
@ -240,11 +240,11 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "load"))); return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).load;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "load", value); BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).load = value;
} }
} }

View file

@ -21,6 +21,7 @@ using Unity.Mathematics;
using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Engines;
using TechbloxModdingAPI.Utility; using TechbloxModdingAPI.Utility;
using PrefabsID = RobocraftX.Common.PrefabsID;
namespace TechbloxModdingAPI.Blocks.Engines namespace TechbloxModdingAPI.Blocks.Engines
{ {
@ -124,7 +125,7 @@ namespace TechbloxModdingAPI.Blocks.Engines
var skew = entitiesDB.QueryEntity<SkewComponent>(id); var skew = entitiesDB.QueryEntity<SkewComponent>(id);
entitiesDB.QueryEntity<RenderingDataStruct>(id).matrix = entitiesDB.QueryEntity<RenderingDataStruct>(id).matrix =
math.mul(float4x4.TRS(pos.position, rot.rotation, scale.scale), skew.skewMatrix); math.mul(float4x4.TRS(pos.position, rot.rotation, scale.scale), skew.skewMatrix);
entitiesDB.PublishEntityChangeDelayed<GFXPrefabEntityStructGPUI>(id); // Signal a prefab change so it updates the render buffers entitiesDB.PublishEntityChangeDelayed<GFXPrefabEntityStructGPUI>(id, 30); // Signal a prefab change so it updates the render buffers
} }
internal void UpdatePrefab(Block block, byte material, bool flipped) internal void UpdatePrefab(Block block, byte material, bool flipped)
@ -145,8 +146,8 @@ namespace TechbloxModdingAPI.Blocks.Engines
entitiesDB.QueryEntityOrDefault<GFXPrefabEntityStructGPUI>(block).prefabID = prefabId; entitiesDB.QueryEntityOrDefault<GFXPrefabEntityStructGPUI>(block).prefabID = prefabId;
if (block.Exists) if (block.Exists)
{ {
entitiesDB.PublishEntityChangeDelayed<CubeMaterialStruct>(block.Id); entitiesDB.PublishEntityChangeDelayed<CubeMaterialStruct>(block.Id, 30);
entitiesDB.PublishEntityChangeDelayed<GFXPrefabEntityStructGPUI>(block.Id); entitiesDB.PublishEntityChangeDelayed<GFXPrefabEntityStructGPUI>(block.Id, 30);
ref BuildingActionComponent local = ref BuildingActionComponent local =
ref entitiesDB.QueryEntity<BuildingActionComponent>(BuildingDroneUtility ref entitiesDB.QueryEntity<BuildingActionComponent>(BuildingDroneUtility
@ -160,7 +161,7 @@ namespace TechbloxModdingAPI.Blocks.Engines
public void UpdateBlockColor(EGID id) public void UpdateBlockColor(EGID id)
{ {
entitiesDB.PublishEntityChange<ColourParameterEntityStruct>(id); entitiesDB.PublishEntityChangeDelayed<ColourParameterEntityStruct>(id, 30);
} }
public bool BlockExists(EGID blockID) public bool BlockExists(EGID blockID)

View file

@ -365,6 +365,9 @@ namespace TechbloxModdingAPI
var group when group == CharacterExclusiveGroups.MachineSpawningGroup => PlayerState.HoldingMachine, var group when group == CharacterExclusiveGroups.MachineSpawningGroup => PlayerState.HoldingMachine,
var group when group == CharacterExclusiveGroups.OnFootGroup => PlayerState.OnFoot, var group when group == CharacterExclusiveGroups.OnFootGroup => PlayerState.OnFoot,
var group when group == CharacterExclusiveGroups.InPilotSeatGroup => PlayerState.InSeat, var group when group == CharacterExclusiveGroups.InPilotSeatGroup => PlayerState.InSeat,
var group when group == CharacterExclusiveGroups.DyingOnFootGroup => PlayerState.OnFoot,
var group when group == CharacterExclusiveGroups.DyingInPilotSeatGroup => PlayerState.InSeat,
var group when group == CharacterExclusiveGroups.DeadGroup => PlayerState.OnFoot,
_ => throw new ArgumentOutOfRangeException("", "Unknown player state") _ => throw new ArgumentOutOfRangeException("", "Unknown player state")
}; };

View file

@ -99,7 +99,7 @@ namespace TechbloxModdingAPI.Utility
changes.Remove(id); changes.Remove(id);
ChangesToPublish[typeof(T)] = (count + 1, changes); ChangesToPublish[typeof(T)] = (count + 1, changes);
yield return Yield.It; yield return Yield.It;
ChangesToPublish[typeof(T)] = (0, changes); ChangesToPublish[typeof(T)] = (Math.Max(ChangesToPublish[typeof(T)].PublishedCount - 1, 0), changes);
} }
/// <summary> /// <summary>