Update to Techblox 2021.04.29.18.37

This commit is contained in:
Norbi Peti 2021-04-30 22:36:54 +02:00
parent 6e03847ab0
commit df6a2e84e1
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
7 changed files with 11 additions and 9 deletions

View file

@ -80,6 +80,7 @@ namespace GamecraftModdingAPI
var egid = initializer.EGID; var egid = initializer.EGID;
var bl = New<T>(egid.entityID, egid.groupID); var bl = New<T>(egid.entityID, egid.groupID);
bl.InitData.Group = BlockEngine.InitGroup(initializer); bl.InitData.Group = BlockEngine.InitGroup(initializer);
bl.InitData.Reference = initializer.reference;
Placed += bl.OnPlacedInit; Placed += bl.OnPlacedInit;
return bl; return bl;
} }

View file

@ -104,7 +104,7 @@ namespace GamecraftModdingAPI.Blocks
private U GetBlockInitInfo<T, U>(Block block, Func<T, U> getter, U def) where T : struct, IEntityComponent private U GetBlockInitInfo<T, U>(Block block, Func<T, U> getter, U def) where T : struct, IEntityComponent
{ {
if (block.InitData.Group == null) return def; if (block.InitData.Group == null) return def;
var initializer = new EntityInitializer(block.Id, block.InitData.Group); var initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference);
if (initializer.Has<T>()) if (initializer.Has<T>())
return getter(initializer.Get<T>()); return getter(initializer.Get<T>());
return def; return def;
@ -133,7 +133,7 @@ namespace GamecraftModdingAPI.Blocks
{ {
if (block.InitData.Group != null) if (block.InitData.Group != null)
{ {
var initializer = new EntityInitializer(block.Id, block.InitData.Group); var initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference);
T component = initializer.Has<T>() ? initializer.Get<T>() : default; T component = initializer.Has<T>() ? initializer.Get<T>() : default;
ref T structRef = ref component; ref T structRef = ref component;
setter(ref structRef, value); setter(ref structRef, value);
@ -161,7 +161,7 @@ namespace GamecraftModdingAPI.Blocks
return true; return true;
if (block.InitData.Group == null) if (block.InitData.Group == null)
return false; return false;
var init = new EntityInitializer(block.Id, block.InitData.Group); var init = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference);
return init.Has<T>(); return init.Has<T>();
} }

View file

@ -15,6 +15,7 @@ namespace GamecraftModdingAPI.Blocks
internal struct BlockInitData internal struct BlockInitData
{ {
public FasterDictionary<RefWrapperType, ITypeSafeDictionary> Group; public FasterDictionary<RefWrapperType, ITypeSafeDictionary> Group;
public EntityReference Reference;
} }
internal delegate FasterDictionary<RefWrapperType, ITypeSafeDictionary> GetInitGroup( internal delegate FasterDictionary<RefWrapperType, ITypeSafeDictionary> GetInitGroup(

View file

@ -131,7 +131,7 @@ namespace GamecraftModdingAPI.Blocks
CubeNameKey = attr.NameKey, CubeNameKey = attr.NameKey,
CubeDescriptionKey = attr.DescKey, CubeDescriptionKey = attr.DescKey,
SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, SelectableFaces = new[] {0, 1, 2, 3, 4, 5},
GridScale = new[] {5, 5, 5}, GridScale = new[] {5f, 5, 5},
DefaultMaterialID = 0, //TODO: Material API DefaultMaterialID = 0, //TODO: Material API
scalingPermission = attr.ScalingPermission, scalingPermission = attr.ScalingPermission,
SortIndex = attr.SortIndex, SortIndex = attr.SortIndex,

View file

@ -40,7 +40,7 @@ namespace GamecraftModdingAPI.Blocks
if (!entitiesDB.Exists<PositionEntityStruct>(blockID)) if (!entitiesDB.Exists<PositionEntityStruct>(blockID))
{ {
if (data.Group == null) return float3.zero; if (data.Group == null) return float3.zero;
var init = new EntityInitializer(blockID, data.Group); var init = new EntityInitializer(blockID, data.Group, data.Reference);
init.GetOrCreate<PositionEntityStruct>().position = vector; init.GetOrCreate<PositionEntityStruct>().position = vector;
init.GetOrCreate<GridRotationStruct>().position = vector; init.GetOrCreate<GridRotationStruct>().position = vector;
init.GetOrCreate<LocalTransformEntityStruct>().position = vector; init.GetOrCreate<LocalTransformEntityStruct>().position = vector;
@ -70,7 +70,7 @@ namespace GamecraftModdingAPI.Blocks
if (!entitiesDB.Exists<PositionEntityStruct>(blockID)) if (!entitiesDB.Exists<PositionEntityStruct>(blockID))
{ {
if (data.Group == null) return float3.zero; if (data.Group == null) return float3.zero;
var init = new EntityInitializer(blockID, data.Group); var init = new EntityInitializer(blockID, data.Group, data.Reference);
return init.Has<PositionEntityStruct>() ? init.Get<PositionEntityStruct>().position : float3.zero; return init.Has<PositionEntityStruct>() ? init.Get<PositionEntityStruct>().position : float3.zero;
} }
ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(blockID); ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(blockID);

View file

@ -40,7 +40,7 @@ namespace GamecraftModdingAPI.Blocks
if (!entitiesDB.Exists<RotationEntityStruct>(blockID)) if (!entitiesDB.Exists<RotationEntityStruct>(blockID))
{ {
if (data.Group == null) return float3.zero; if (data.Group == null) return float3.zero;
var init = new EntityInitializer(blockID, data.Group); var init = new EntityInitializer(blockID, data.Group, data.Reference);
init.GetOrCreate<RotationEntityStruct>().rotation = Quaternion.Euler(vector); init.GetOrCreate<RotationEntityStruct>().rotation = Quaternion.Euler(vector);
init.GetOrCreate<GridRotationStruct>().rotation = Quaternion.Euler(vector); init.GetOrCreate<GridRotationStruct>().rotation = Quaternion.Euler(vector);
init.GetOrCreate<LocalTransformEntityStruct>().rotation = Quaternion.Euler(vector); init.GetOrCreate<LocalTransformEntityStruct>().rotation = Quaternion.Euler(vector);
@ -77,7 +77,7 @@ namespace GamecraftModdingAPI.Blocks
if (!entitiesDB.Exists<RotationEntityStruct>(blockID)) if (!entitiesDB.Exists<RotationEntityStruct>(blockID))
{ {
if (data.Group == null) return float3.zero; if (data.Group == null) return float3.zero;
var init = new EntityInitializer(blockID, data.Group); var init = new EntityInitializer(blockID, data.Group, data.Reference);
return init.Has<RotationEntityStruct>() return init.Has<RotationEntityStruct>()
? (float3) ((Quaternion) init.Get<RotationEntityStruct>().rotation).eulerAngles ? (float3) ((Quaternion) init.Get<RotationEntityStruct>().rotation).eulerAngles
: float3.zero; : float3.zero;

View file

@ -399,7 +399,7 @@ namespace GamecraftModdingAPI.Blocks
exists = false; exists = false;
return ref defRef[0]; return ref defRef[0];
} }
EntityInitializer initializer = new EntityInitializer(block.Id, block.InitData.Group); EntityInitializer initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference);
if (initializer.Has<T>()) if (initializer.Has<T>())
{ {
exists = true; exists = true;