diff --git a/CodeGenerator/CodeGenerator.csproj b/CodeGenerator/CodeGenerator.csproj index c80dce9..41e2dc5 100644 --- a/CodeGenerator/CodeGenerator.csproj +++ b/CodeGenerator/CodeGenerator.csproj @@ -20,6 +20,7 @@ + diff --git a/CodeGenerator/MakeEverythingPublicInGame.cs b/CodeGenerator/MakeEverythingPublicInGame.cs new file mode 100644 index 0000000..9e8d47c --- /dev/null +++ b/CodeGenerator/MakeEverythingPublicInGame.cs @@ -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(); + } + } +} \ No newline at end of file diff --git a/CodeGenerator/Program.cs b/CodeGenerator/Program.cs index 900c6d4..fd3e0a5 100644 --- a/CodeGenerator/Program.cs +++ b/CodeGenerator/Program.cs @@ -11,6 +11,13 @@ namespace CodeGenerator internal class Program { public static void Main(string[] args) + { + GenerateBlockClasses(); + var mepig = new MakeEverythingPublicInGame(); + mepig.Start(); + } + + private static void GenerateBlockClasses() { var bcg = new BlockClassGenerator(); bcg.Generate("Engine", null, new Dictionary diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index bd4ba8a..3970824 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -302,6 +302,7 @@ namespace TechbloxModdingAPI.Blocks FloodLight, SoccerBall, CircularWallLight, + BlueSkyAtmos, DirtToGrassTransitionTile = 393, DirtToGrassTransitionInnerTile, DirtToGrassTransitionOuterTile, @@ -362,10 +363,21 @@ namespace TechbloxModdingAPI.Blocks SmallGridHill, SmallGridHillInnerCorner, SmallGridHillOuterCorner, - Vector7SmallJet = 460, + AimingAxleServo, + AimingHingeServo, + WeaponDisabler, + Vector7SmallJet, Vector7MediumJet, Vector7LargeJet, Vector7XLJet, - Vector7XXLJet + Vector7XXLJet, + APCWheelRigNoSteering, + APCWheelRigWithSteering, + APCWheel, + APCSeat, + APCEngine, + DamageScoreBlock, + KillScoreBlock, + Autocannon = 480 } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/BlockMaterial.cs b/TechbloxModdingAPI/Blocks/BlockMaterial.cs index 641b21f..51d0694 100644 --- a/TechbloxModdingAPI/Blocks/BlockMaterial.cs +++ b/TechbloxModdingAPI/Blocks/BlockMaterial.cs @@ -33,13 +33,14 @@ namespace TechbloxModdingAPI.Blocks WoodRoughGrungy, Boundary, Emissive, - AircraftPaneling_Riveted_Painted, - AircraftPaneling_Riveted_Metallic, - Steel_Bodywork_Pearlescent, - Steel_Bodywork_RadWrap, - Steel_Bodywork_Glitter, + AircraftPanelingRivetedPainted, + AircraftPanelingRivetedMetallic, + SteelBodyworkPearlescent, + SteelBodyworkRadWrap, + SteelBodyworkGlitter, BouncyRubber, - BouncyRubber_TieDye, - FuturisticPaneling_Riveted_Painted = 40 + BouncyRubberTieDye, + BrickPainted, + FuturisticPanelingRivetedPainted, } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/BlockTests.cs b/TechbloxModdingAPI/Blocks/BlockTests.cs index d1fc146..1e39945 100644 --- a/TechbloxModdingAPI/Blocks/BlockTests.cs +++ b/TechbloxModdingAPI/Blocks/BlockTests.cs @@ -80,7 +80,6 @@ namespace TechbloxModdingAPI.Blocks yield break; 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]; if (!block.Exists) continue; foreach (var property in block.GetType().GetProperties()) diff --git a/TechbloxModdingAPI/Blocks/Engine.cs b/TechbloxModdingAPI/Blocks/Engine.cs index a0ab875..6140b11 100644 --- a/TechbloxModdingAPI/Blocks/Engine.cs +++ b/TechbloxModdingAPI/Blocks/Engine.cs @@ -30,11 +30,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((bool)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "engineOn"))); + return BlockEngine.GetBlockInfo(this).engineOn; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "engineOn", value); + BlockEngine.GetBlockInfo(this).engineOn = value; } } @@ -45,11 +45,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((int)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentGear"))); + return BlockEngine.GetBlockInfo(this).currentGear; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentGear", value); + BlockEngine.GetBlockInfo(this).currentGear = value; } } @@ -60,11 +60,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "gearChangeCountdown"))); + return BlockEngine.GetBlockInfo(this).gearChangeCountdown; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "gearChangeCountdown", value); + BlockEngine.GetBlockInfo(this).gearChangeCountdown = value; } } @@ -75,11 +75,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentRpmAV"))); + return BlockEngine.GetBlockInfo(this).currentRpmAV; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentRpmAV", value); + BlockEngine.GetBlockInfo(this).currentRpmAV = value; } } @@ -90,11 +90,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentRpmLV"))); + return BlockEngine.GetBlockInfo(this).currentRpmLV; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentRpmLV", value); + BlockEngine.GetBlockInfo(this).currentRpmLV = value; } } @@ -105,11 +105,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "targetRpmAV"))); + return BlockEngine.GetBlockInfo(this).targetRpmAV; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "targetRpmAV", value); + BlockEngine.GetBlockInfo(this).targetRpmAV = value; } } @@ -120,11 +120,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "targetRpmLV"))); + return BlockEngine.GetBlockInfo(this).targetRpmLV; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "targetRpmLV", value); + BlockEngine.GetBlockInfo(this).targetRpmLV = value; } } @@ -135,11 +135,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentTorque"))); + return BlockEngine.GetBlockInfo(this).currentTorque; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "currentTorque", value); + BlockEngine.GetBlockInfo(this).currentTorque = value; } } @@ -150,11 +150,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelVelocityAV"))); + return BlockEngine.GetBlockInfo(this).totalWheelVelocityAV; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelVelocityAV", value); + BlockEngine.GetBlockInfo(this).totalWheelVelocityAV = value; } } @@ -165,11 +165,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelVelocityLV"))); + return BlockEngine.GetBlockInfo(this).totalWheelVelocityLV; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelVelocityLV", value); + BlockEngine.GetBlockInfo(this).totalWheelVelocityLV = value; } } @@ -180,11 +180,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((int)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelCount"))); + return BlockEngine.GetBlockInfo(this).totalWheelCount; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "totalWheelCount", value); + BlockEngine.GetBlockInfo(this).totalWheelCount = value; } } @@ -195,11 +195,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((bool)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "lastGearUpInput"))); + return BlockEngine.GetBlockInfo(this).lastGearUpInput; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "lastGearUpInput", value); + BlockEngine.GetBlockInfo(this).lastGearUpInput = value; } } @@ -210,11 +210,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((bool)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "lastGearDownInput"))); + return BlockEngine.GetBlockInfo(this).lastGearDownInput; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "lastGearDownInput", value); + BlockEngine.GetBlockInfo(this).lastGearDownInput = value; } } @@ -225,11 +225,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "manualToAutoGearCoolOffCounter"))); + return BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffCounter; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "manualToAutoGearCoolOffCounter", value); + BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffCounter = value; } } @@ -240,11 +240,11 @@ namespace TechbloxModdingAPI.Blocks { get { - return ((float)(BlockEngine.GetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "load"))); + return BlockEngine.GetBlockInfo(this).load; } set { - BlockEngine.SetBlockInfo(this, HarmonyLib.AccessTools.TypeByName("Techblox.EngineBlock.EngineBlockComponent"), "load", value); + BlockEngine.GetBlockInfo(this).load = value; } } diff --git a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs index e3d7695..824071f 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs @@ -21,6 +21,7 @@ using Unity.Mathematics; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; +using PrefabsID = RobocraftX.Common.PrefabsID; namespace TechbloxModdingAPI.Blocks.Engines { @@ -124,7 +125,7 @@ namespace TechbloxModdingAPI.Blocks.Engines var skew = entitiesDB.QueryEntity(id); entitiesDB.QueryEntity(id).matrix = math.mul(float4x4.TRS(pos.position, rot.rotation, scale.scale), skew.skewMatrix); - entitiesDB.PublishEntityChangeDelayed(id); // Signal a prefab change so it updates the render buffers + entitiesDB.PublishEntityChangeDelayed(id, 30); // Signal a prefab change so it updates the render buffers } internal void UpdatePrefab(Block block, byte material, bool flipped) @@ -145,8 +146,8 @@ namespace TechbloxModdingAPI.Blocks.Engines entitiesDB.QueryEntityOrDefault(block).prefabID = prefabId; if (block.Exists) { - entitiesDB.PublishEntityChangeDelayed(block.Id); - entitiesDB.PublishEntityChangeDelayed(block.Id); + entitiesDB.PublishEntityChangeDelayed(block.Id, 30); + entitiesDB.PublishEntityChangeDelayed(block.Id, 30); ref BuildingActionComponent local = ref entitiesDB.QueryEntity(BuildingDroneUtility @@ -160,7 +161,7 @@ namespace TechbloxModdingAPI.Blocks.Engines public void UpdateBlockColor(EGID id) { - entitiesDB.PublishEntityChange(id); + entitiesDB.PublishEntityChangeDelayed(id, 30); } public bool BlockExists(EGID blockID) diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 857c477..24799f3 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -365,6 +365,9 @@ namespace TechbloxModdingAPI var group when group == CharacterExclusiveGroups.MachineSpawningGroup => PlayerState.HoldingMachine, var group when group == CharacterExclusiveGroups.OnFootGroup => PlayerState.OnFoot, 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") }; diff --git a/TechbloxModdingAPI/Utility/NativeApiExtensions.cs b/TechbloxModdingAPI/Utility/NativeApiExtensions.cs index c20a4b2..34f15f0 100644 --- a/TechbloxModdingAPI/Utility/NativeApiExtensions.cs +++ b/TechbloxModdingAPI/Utility/NativeApiExtensions.cs @@ -99,7 +99,7 @@ namespace TechbloxModdingAPI.Utility changes.Remove(id); ChangesToPublish[typeof(T)] = (count + 1, changes); yield return Yield.It; - ChangesToPublish[typeof(T)] = (0, changes); + ChangesToPublish[typeof(T)] = (Math.Max(ChangesToPublish[typeof(T)].PublishedCount - 1, 0), changes); } ///