Browse Source

Update to Techblox 2021.04.29.18.37

tags/v2.0.0
NorbiPeti 3 years ago
parent
commit
df6a2e84e1
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
7 changed files with 11 additions and 9 deletions
  1. +1
    -0
      GamecraftModdingAPI/Block.cs
  2. +3
    -3
      GamecraftModdingAPI/Blocks/BlockEngine.cs
  3. +1
    -0
      GamecraftModdingAPI/Blocks/BlockEngineInit.cs
  4. +1
    -1
      GamecraftModdingAPI/Blocks/CustomBlock.cs
  5. +2
    -2
      GamecraftModdingAPI/Blocks/MovementEngine.cs
  6. +2
    -2
      GamecraftModdingAPI/Blocks/RotationEngine.cs
  7. +1
    -1
      GamecraftModdingAPI/Blocks/SignalEngine.cs

+ 1
- 0
GamecraftModdingAPI/Block.cs View File

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


+ 3
- 3
GamecraftModdingAPI/Blocks/BlockEngine.cs 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
{
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>())
return getter(initializer.Get<T>());
return def;
@@ -133,7 +133,7 @@ namespace GamecraftModdingAPI.Blocks
{
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;
ref T structRef = ref component;
setter(ref structRef, value);
@@ -161,7 +161,7 @@ namespace GamecraftModdingAPI.Blocks
return true;
if (block.InitData.Group == null)
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>();
}



+ 1
- 0
GamecraftModdingAPI/Blocks/BlockEngineInit.cs View File

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

internal delegate FasterDictionary<RefWrapperType, ITypeSafeDictionary> GetInitGroup(


+ 1
- 1
GamecraftModdingAPI/Blocks/CustomBlock.cs View File

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


+ 2
- 2
GamecraftModdingAPI/Blocks/MovementEngine.cs View File

@@ -40,7 +40,7 @@ namespace GamecraftModdingAPI.Blocks
if (!entitiesDB.Exists<PositionEntityStruct>(blockID))
{
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<GridRotationStruct>().position = vector;
init.GetOrCreate<LocalTransformEntityStruct>().position = vector;
@@ -70,7 +70,7 @@ namespace GamecraftModdingAPI.Blocks
if (!entitiesDB.Exists<PositionEntityStruct>(blockID))
{
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;
}
ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(blockID);


+ 2
- 2
GamecraftModdingAPI/Blocks/RotationEngine.cs View File

@@ -40,7 +40,7 @@ namespace GamecraftModdingAPI.Blocks
if (!entitiesDB.Exists<RotationEntityStruct>(blockID))
{
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<GridRotationStruct>().rotation = Quaternion.Euler(vector);
init.GetOrCreate<LocalTransformEntityStruct>().rotation = Quaternion.Euler(vector);
@@ -77,7 +77,7 @@ namespace GamecraftModdingAPI.Blocks
if (!entitiesDB.Exists<RotationEntityStruct>(blockID))
{
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>()
? (float3) ((Quaternion) init.Get<RotationEntityStruct>().rotation).eulerAngles
: float3.zero;


+ 1
- 1
GamecraftModdingAPI/Blocks/SignalEngine.cs View File

@@ -399,7 +399,7 @@ namespace GamecraftModdingAPI.Blocks
exists = false;
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>())
{
exists = true;


Loading…
Cancel
Save