|
|
@@ -35,23 +35,32 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
|
|
|
|
// implementations for Rotation static class |
|
|
|
|
|
|
|
public float3 RotateBlock(EGID blockID, Vector3 vector) |
|
|
|
internal float3 RotateBlock(EGID blockID, BlockEngine.BlockInitData data, Vector3 vector) |
|
|
|
{ |
|
|
|
if (!entitiesDB.Exists<RotationEntityStruct>(blockID)) |
|
|
|
{ |
|
|
|
if (data.Group == null) return float3.zero; |
|
|
|
var init = new EntityComponentInitializer(blockID, data.Group); |
|
|
|
init.Init(new RotationEntityStruct {rotation = new Quaternion {eulerAngles = vector}}); |
|
|
|
init.Init(new GridRotationStruct {rotation = new Quaternion {eulerAngles = vector}}); |
|
|
|
init.Init(new LocalTransformEntityStruct {rotation = new Quaternion {eulerAngles = vector}}); |
|
|
|
return vector; |
|
|
|
} |
|
|
|
ref RotationEntityStruct rotStruct = ref this.entitiesDB.QueryEntity<RotationEntityStruct>(blockID); |
|
|
|
ref GridRotationStruct gridStruct = ref this.entitiesDB.QueryEntity<GridRotationStruct>(blockID); |
|
|
|
ref LocalTransformEntityStruct transStruct = ref this.entitiesDB.QueryEntity<LocalTransformEntityStruct>(blockID); |
|
|
|
ref UECSPhysicsEntityStruct phyStruct = ref this.entitiesDB.QueryEntity<UECSPhysicsEntityStruct>(blockID); |
|
|
|
// main (persistent) position |
|
|
|
Quaternion newRotation = (Quaternion)rotStruct.rotation; |
|
|
|
newRotation.eulerAngles += vector; |
|
|
|
rotStruct.rotation = (quaternion)newRotation; |
|
|
|
Quaternion newRotation = rotStruct.rotation; |
|
|
|
newRotation.eulerAngles = vector; |
|
|
|
rotStruct.rotation = newRotation; |
|
|
|
// placement grid rotation |
|
|
|
Quaternion newGridRotation = (Quaternion)gridStruct.rotation; |
|
|
|
newGridRotation.eulerAngles += vector; |
|
|
|
gridStruct.rotation = (quaternion)newGridRotation; |
|
|
|
Quaternion newGridRotation = gridStruct.rotation; |
|
|
|
newGridRotation.eulerAngles = vector; |
|
|
|
gridStruct.rotation = newGridRotation; |
|
|
|
// rendered position |
|
|
|
Quaternion newTransRotation = (Quaternion)rotStruct.rotation; |
|
|
|
newTransRotation.eulerAngles += vector; |
|
|
|
Quaternion newTransRotation = rotStruct.rotation; |
|
|
|
newTransRotation.eulerAngles = vector; |
|
|
|
transStruct.rotation = newTransRotation; |
|
|
|
// collision position |
|
|
|
FullGameFields._physicsWorld.EntityManager.SetComponentData(phyStruct.uecsEntity, new Unity.Transforms.Rotation |
|
|
@@ -63,8 +72,17 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public float3 GetRotation(EGID blockID) |
|
|
|
internal float3 GetRotation(EGID blockID, BlockEngine.BlockInitData data) |
|
|
|
{ |
|
|
|
if (!entitiesDB.Exists<RotationEntityStruct>(blockID)) |
|
|
|
{ |
|
|
|
if (data.Group == null) return float3.zero; |
|
|
|
var init = new EntityComponentInitializer(blockID, data.Group); |
|
|
|
return init.Has<RotationEntityStruct>() |
|
|
|
? (float3) ((Quaternion) init.Get<RotationEntityStruct>().rotation).eulerAngles |
|
|
|
: float3.zero; |
|
|
|
} |
|
|
|
|
|
|
|
ref RotationEntityStruct rotStruct = ref entitiesDB.QueryEntity<RotationEntityStruct>(blockID); |
|
|
|
return ((Quaternion) rotStruct.rotation).eulerAngles; |
|
|
|
} |
|
|
|