Remove block info getters and setters

Regex is great

GetBlockInfo\(this, \((\w+) (\w+)\) ?=> ?\2(.+)\);
GetBlockInfo<$1>(this)$3;

SetBlockInfo\(this, \(ref (\w+) (\w+), \w+ (\w+)\) ?=> \2(.*) = \3,\s*value\);
GetBlockInfo<$1>(this)$4 = value;
This commit is contained in:
Norbi Peti 2021-05-10 23:08:15 +02:00
parent 61184145a9
commit d238c97906
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
13 changed files with 63 additions and 64 deletions

View file

@ -285,14 +285,14 @@ namespace TechbloxModdingAPI
/// </summary> /// </summary>
public float3 Scale public float3 Scale
{ {
get => BlockEngine.GetBlockInfo(this, (ScalingEntityStruct st) => st.scale); get => BlockEngine.GetBlockInfo<ScalingEntityStruct>(this).scale;
set set
{ {
int uscale = UniformScale; int uscale = UniformScale;
if (value.x < 4e-5) value.x = uscale; if (value.x < 4e-5) value.x = uscale;
if (value.y < 4e-5) value.y = uscale; if (value.y < 4e-5) value.y = uscale;
if (value.z < 4e-5) value.z = uscale; if (value.z < 4e-5) value.z = uscale;
BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, float3 val) => st.scale = val, value); BlockEngine.GetBlockInfo<ScalingEntityStruct>(this).scale = value;
if (!Exists) return; //UpdateCollision needs the block to exist if (!Exists) return; //UpdateCollision needs the block to exist
ScalingEngine.UpdateCollision(Id); ScalingEngine.UpdateCollision(Id);
BlockEngine.UpdateDisplayedBlock(Id); BlockEngine.UpdateDisplayedBlock(Id);
@ -305,12 +305,11 @@ namespace TechbloxModdingAPI
/// </summary> /// </summary>
public int UniformScale public int UniformScale
{ {
get => BlockEngine.GetBlockInfo(this, (UniformBlockScaleEntityStruct st) => st.scaleFactor); get => BlockEngine.GetBlockInfo<UniformBlockScaleEntityStruct>(this).scaleFactor;
set set
{ {
if (value < 1) value = 1; if (value < 1) value = 1;
BlockEngine.SetBlockInfo(this, (ref UniformBlockScaleEntityStruct st, int val) => st.scaleFactor = val, BlockEngine.GetBlockInfo<UniformBlockScaleEntityStruct>(this).scaleFactor = value;
value);
Scale = new float3(value, value, value); Scale = new float3(value, value, value);
} }
} }
@ -320,7 +319,7 @@ namespace TechbloxModdingAPI
*/ */
public bool Flipped public bool Flipped
{ {
get => BlockEngine.GetBlockInfo(this, (ScalingEntityStruct st) => st.scale.x < 0); get => BlockEngine.GetBlockInfo<ScalingEntityStruct>(this).scale.x < 0;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, bool val) => BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, bool val) =>
@ -371,7 +370,7 @@ namespace TechbloxModdingAPI
/// </summary> /// </summary>
public float4 CustomColor public float4 CustomColor
{ {
get => BlockEngine.GetBlockInfo(this, (ColourParameterEntityStruct st) => st.paletteColour); get => BlockEngine.GetBlockInfo<ColourParameterEntityStruct>(this).paletteColour;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, float4 val) => BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, float4 val) =>

View file

@ -70,11 +70,16 @@ namespace TechbloxModdingAPI.Blocks
: entitiesDB.QueryEntity<PaletteEntryEntityStruct>(index, : entitiesDB.QueryEntity<PaletteEntryEntityStruct>(index,
CommonExclusiveGroups.COLOUR_PALETTE_GROUP).Colour; CommonExclusiveGroups.COLOUR_PALETTE_GROUP).Colour;
public OptionalRef<T> GetBlockInfo<T>(Block block) where T : unmanaged, IEntityComponent public OptionalRef<T> GetBlockInfoOptional<T>(Block block) where T : unmanaged, IEntityComponent
{ {
return entitiesDB.QueryEntityOptional<T>(block); return entitiesDB.QueryEntityOptional<T>(block);
} }
public ref T GetBlockInfo<T>(Block block) where T : unmanaged, IEntityComponent
{
return ref entitiesDB.QueryEntityOrDefault<T>(block);
}
public void UpdateDisplayedBlock(EGID id) public void UpdateDisplayedBlock(EGID id)
{ {
if (!BlockExists(id)) return; if (!BlockExists(id)) return;

View file

@ -19,7 +19,7 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float MaxForce public float MaxForce
{ {
get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct dsrs) => dsrs.springFrequency); get => BlockEngine.GetBlockInfo<DampedSpringReadOnlyStruct>(this).springFrequency;
set => BlockEngine.SetBlockInfo(this, set => BlockEngine.SetBlockInfo(this,
(ref DampedSpringReadOnlyStruct dsrs, float val) => dsrs.springFrequency = val, value); (ref DampedSpringReadOnlyStruct dsrs, float val) => dsrs.springFrequency = val, value);
@ -39,7 +39,7 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float Damping public float Damping
{ {
get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct ljf) => ljf.springDamping); get => BlockEngine.GetBlockInfo<DampedSpringReadOnlyStruct>(this).springDamping;
set => BlockEngine.SetBlockInfo(this, set => BlockEngine.SetBlockInfo(this,
(ref DampedSpringReadOnlyStruct ljf, float val) => ljf.springDamping = val, value); (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.springDamping = val, value);
@ -50,7 +50,7 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float MaxExtension public float MaxExtension
{ {
get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct ljf) => ljf.maxExtent); get => BlockEngine.GetBlockInfo<DampedSpringReadOnlyStruct>(this).maxExtent;
set => BlockEngine.SetBlockInfo(this, set => BlockEngine.SetBlockInfo(this,
(ref DampedSpringReadOnlyStruct ljf, float val) => ljf.maxExtent = val, value); (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.maxExtent = val, value);

View file

@ -28,12 +28,12 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxVelocity); return BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(this).maxVelocity;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxVelocity = val, value); BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(this).maxVelocity = value;
} }
} }
@ -44,12 +44,12 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxForce); return BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(this).maxForce;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxForce = val, value); BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(this).maxForce = value;
} }
} }
@ -60,12 +60,12 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.reverse); return BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(this).reverse;
} }
set set
{ {
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, bool val) => st.reverse = val, value); BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(this).reverse = value;
} }
} }
} }

View file

@ -28,7 +28,7 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (MusicBlockDataEntityStruct st) => st.trackIndx); return BlockEngine.GetBlockInfo<MusicBlockDataEntityStruct>(this).trackIndx;
} }
set set
@ -83,7 +83,7 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (MusicBlockDataEntityStruct msdes) => msdes.tweakableVolume); return BlockEngine.GetBlockInfo<MusicBlockDataEntityStruct>(this).tweakableVolume;
} }
set set

View file

@ -16,7 +16,7 @@ namespace TechbloxModdingAPI.Blocks
public char Identifier public char Identifier
{ {
get => (char) BlockEngine.GetBlockInfo(this, (ObjectIdEntityStruct st) => st.objectId + 'A'); get => (char) BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(this).objectId + 'A';
set set
{ {
BlockEngine.SetBlockInfo(this, (ref ObjectIdEntityStruct st, char val) => BlockEngine.SetBlockInfo(this, (ref ObjectIdEntityStruct st, char val) =>
@ -32,7 +32,7 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public byte SimID public byte SimID
{ {
get => BlockEngine.GetBlockInfo(this, (ObjectIdEntityStruct st) => st.simObjectId); get => BlockEngine.GetBlockInfo<ObjectIdEntityStruct>(this).simObjectId;
} }
/// <summary> /// <summary>

View file

@ -26,12 +26,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float MaximumExtension public float MaximumExtension
{ {
get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.maxDeviation); get => BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).maxDeviation;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.maxDeviation = val, BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).maxDeviation = value;
value);
} }
} }
@ -40,11 +39,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float MaximumForce public float MaximumForce
{ {
get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.pistonVelocity); get => BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).pistonVelocity;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.pistonVelocity = val, value); BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).pistonVelocity = value;
} }
} }
} }

View file

@ -26,11 +26,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float MinimumAngle public float MinimumAngle
{ {
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.minDeviation); get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).minDeviation;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.minDeviation = val, value); BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).minDeviation = value;
} }
} }
@ -39,11 +39,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float MaximumAngle public float MaximumAngle
{ {
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.maxDeviation); get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).maxDeviation;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.maxDeviation = val, value); BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).maxDeviation = value;
} }
} }
@ -52,11 +52,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float MaximumForce public float MaximumForce
{ {
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.servoVelocity); get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).servoVelocity;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.servoVelocity = val, value); BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).servoVelocity = value;
} }
} }
@ -65,11 +65,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public bool Reverse public bool Reverse
{ {
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.reverse); get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).reverse;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, bool val) => st.reverse = val, value); BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).reverse = value;
} }
} }
} }

View file

@ -22,7 +22,7 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.tweakableVolume); return BlockEngine.GetBlockInfo<SoundSfxBlockDataEntityStruct>(this).tweakableVolume;
} }
set set
@ -36,7 +36,7 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.tweakablePitch); return BlockEngine.GetBlockInfo<SoundSfxBlockDataEntityStruct>(this).tweakablePitch;
} }
set set
@ -50,7 +50,7 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.is3D); return BlockEngine.GetBlockInfo<SoundSfxBlockDataEntityStruct>(this).is3D;
} }
set set
@ -78,7 +78,7 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.soundEffectIndex); return BlockEngine.GetBlockInfo<SoundSfxBlockDataEntityStruct>(this).soundEffectIndex;
} }
set set
@ -162,7 +162,7 @@ namespace TechbloxModdingAPI.Blocks
{ {
get get
{ {
return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.isLoopedBlock); return BlockEngine.GetBlockInfo<SoundSfxBlockDataEntityStruct>(this).isLoopedBlock;
} }
set set

View file

@ -67,7 +67,7 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public uint InputCount public uint InputCount
{ {
get => BlockEngine.GetBlockInfo(this, (BlockPortsStruct st) => st.inputCount); get => BlockEngine.GetBlockInfo<BlockPortsStruct>(this).inputCount;
} }
/// <summary> /// <summary>
@ -75,7 +75,7 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public uint OutputCount public uint OutputCount
{ {
get => BlockEngine.GetBlockInfo(this, (BlockPortsStruct st) => st.outputCount); get => BlockEngine.GetBlockInfo<BlockPortsStruct>(this).outputCount;
} }
/// <summary> /// <summary>

View file

@ -28,11 +28,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public uint Lives public uint Lives
{ {
get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.lives); get => BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(this).lives;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, uint val) => st.lives = val, value); BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(this).lives = value;
} }
} }
@ -41,11 +41,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public bool Damageable public bool Damageable
{ {
get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.canTakeDamage); get => BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(this).canTakeDamage;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, bool val) => st.canTakeDamage = val, value); BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(this).canTakeDamage = value;
} }
} }
@ -54,11 +54,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public bool GameOverEnabled public bool GameOverEnabled
{ {
get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.gameOverScreen); get => BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(this).gameOverScreen;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, bool val) => st.gameOverScreen = val, value); BlockEngine.GetBlockInfo<SpawnPointStatsEntityStruct>(this).gameOverScreen = value;
} }
} }
@ -67,11 +67,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public byte Team public byte Team
{ {
get => BlockEngine.GetBlockInfo(this, (SpawnPointIdsEntityStruct st) => st.teamId); get => BlockEngine.GetBlockInfo<SpawnPointIdsEntityStruct>(this).teamId;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref SpawnPointIdsEntityStruct st, byte val) => st.teamId = val, value); BlockEngine.GetBlockInfo<SpawnPointIdsEntityStruct>(this).teamId = value;
} }
} }
} }

View file

@ -27,7 +27,7 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public string Text public string Text
{ {
get => BlockEngine.GetBlockInfo(this, (TextBlockDataStruct st) => st.textCurrent); get => BlockEngine.GetBlockInfo<TextBlockDataStruct>(this).textCurrent;
set set
{ {
@ -45,7 +45,7 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public string TextBlockId public string TextBlockId
{ {
get => BlockEngine.GetBlockInfo(this, (TextBlockDataStruct st) => st.textBlockID); get => BlockEngine.GetBlockInfo<TextBlockDataStruct>(this).textBlockID;
set set
{ {

View file

@ -28,12 +28,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float Start public float Start
{ {
get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.startTime); get => BlockEngine.GetBlockInfo<TimerBlockDataStruct>(this).startTime;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.startTime = val, BlockEngine.GetBlockInfo<TimerBlockDataStruct>(this).startTime = value;
value);
} }
} }
@ -42,12 +41,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public float End public float End
{ {
get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.endTime); get => BlockEngine.GetBlockInfo<TimerBlockDataStruct>(this).endTime;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.endTime = val, BlockEngine.GetBlockInfo<TimerBlockDataStruct>(this).endTime = value;
value);
} }
} }
@ -56,12 +54,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public bool DisplayMilliseconds public bool DisplayMilliseconds
{ {
get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.outputFormatHasMS); get => BlockEngine.GetBlockInfo<TimerBlockDataStruct>(this).outputFormatHasMS;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, bool val) => tbds.outputFormatHasMS = val, BlockEngine.GetBlockInfo<TimerBlockDataStruct>(this).outputFormatHasMS = value;
value);
} }
} }
@ -70,12 +67,11 @@ namespace TechbloxModdingAPI.Blocks
/// </summary> /// </summary>
public int CurrentTime public int CurrentTime
{ {
get => BlockEngine.GetBlockInfo(this, (TimerBlockLabelCacheEntityStruct st) => st.timeLastRenderFrameMS); get => BlockEngine.GetBlockInfo<TimerBlockLabelCacheEntityStruct>(this).timeLastRenderFrameMS;
set set
{ {
BlockEngine.SetBlockInfo(this, (ref TimerBlockLabelCacheEntityStruct tbds, int val) => tbds.timeLastRenderFrameMS = val, BlockEngine.GetBlockInfo<TimerBlockLabelCacheEntityStruct>(this).timeLastRenderFrameMS = value;
value);
} }
} }
} }