Browse Source

Update to Gamecraft 2020.06.17.08.41 (preview)

Removed BlockIdentifiers.OWNED_BLOCKS as the original got replaced with an array
Added the correct group for each supported functional block
Removed EntityFactory property from IEntitySerializer as it is provided on deserialization
tags/v1.4.0-preview
NorbiPeti 3 years ago
parent
commit
f403feb298
25 changed files with 93 additions and 126 deletions
  1. +4
    -4
      GamecraftModdingAPI/App/GameBuildSimEventEngine.cs
  2. +11
    -17
      GamecraftModdingAPI/App/GameGameEngine.cs
  3. +6
    -6
      GamecraftModdingAPI/Block.cs
  4. +13
    -12
      GamecraftModdingAPI/Blocks/BlockEngine.cs
  5. +4
    -4
      GamecraftModdingAPI/Blocks/BlockIdentifiers.cs
  6. +2
    -1
      GamecraftModdingAPI/Blocks/ConsoleBlock.cs
  7. +2
    -1
      GamecraftModdingAPI/Blocks/Motor.cs
  8. +8
    -8
      GamecraftModdingAPI/Blocks/MovementEngine.cs
  9. +2
    -1
      GamecraftModdingAPI/Blocks/ObjectIdentifier.cs
  10. +2
    -1
      GamecraftModdingAPI/Blocks/Piston.cs
  11. +3
    -16
      GamecraftModdingAPI/Blocks/PlacementEngine.cs
  12. +8
    -8
      GamecraftModdingAPI/Blocks/RotationEngine.cs
  13. +2
    -1
      GamecraftModdingAPI/Blocks/Servo.cs
  14. +7
    -15
      GamecraftModdingAPI/Blocks/SignalEngine.cs
  15. +2
    -1
      GamecraftModdingAPI/Blocks/SpawnPoint.cs
  16. +2
    -1
      GamecraftModdingAPI/Blocks/TextBlock.cs
  17. +2
    -1
      GamecraftModdingAPI/Blocks/Timer.cs
  18. +2
    -2
      GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs
  19. +2
    -2
      GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs
  20. +0
    -4
      GamecraftModdingAPI/GamecraftModdingAPI.csproj
  21. +1
    -7
      GamecraftModdingAPI/Persistence/IEntitySerializer.cs
  22. +0
    -3
      GamecraftModdingAPI/Persistence/SerializerManager.cs
  23. +2
    -4
      GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs
  24. +2
    -2
      GamecraftModdingAPI/Player.cs
  25. +4
    -4
      GamecraftModdingAPI/Players/PlayerEngine.cs

+ 4
- 4
GamecraftModdingAPI/App/GameBuildSimEventEngine.cs View File

@@ -26,16 +26,16 @@ namespace GamecraftModdingAPI.App

public void Ready() { }

public JobHandle OnInitializeTimeRunningMode()
public JobHandle OnInitializeTimeRunningMode(JobHandle inputDeps)
{
ExceptionUtil.InvokeEvent(SimulationMode, this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder });
return default(JobHandle);
return inputDeps;
}

public JobHandle OnInitializeTimeStoppedMode()
public JobHandle OnInitializeTimeStoppedMode(JobHandle inputDeps)
{
ExceptionUtil.InvokeEvent(BuildMode, this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder });
return default(JobHandle);
return inputDeps;
}
}



+ 11
- 17
GamecraftModdingAPI/App/GameGameEngine.cs View File

@@ -97,28 +97,22 @@ namespace GamecraftModdingAPI.App

public EGID[] GetAllBlocksInGame(BlockIDs filter = BlockIDs.Invalid)
{
EntityCollection<DBEntityStruct> blocks = entitiesDB.QueryEntities<DBEntityStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
var allBlocks = entitiesDB.QueryEntities<DBEntityStruct>();
List<EGID> blockEGIDs = new List<EGID>();
if (filter == BlockIDs.Invalid)
{
EGID[] blockEGIDs = new EGID[blocks.count];
for (uint b = 0; b < blocks.count; b++)
{
blockEGIDs[b] = blocks[b].ID;
}
return blockEGIDs;
foreach (var (blocks, _) in allBlocks)
foreach (var block in blocks)
blockEGIDs.Add(block.ID);
return blockEGIDs.ToArray();
}
else
{
uint dbidFilter = (uint)filter;
List<EGID> blockEGIDs = new List<EGID>();
for (uint b = 0; b < blocks.count; b++)
{
if (blocks[b].DBID == dbidFilter)
{
blockEGIDs.Add(blocks[b].ID);
}
}
return blockEGIDs.ToArray();
foreach (var (blocks, _) in allBlocks)
foreach (var block in blocks)
if (block.DBID == (ulong) filter)
blockEGIDs.Add(block.ID);
return blockEGIDs.ToArray();
}
}
}


+ 6
- 6
GamecraftModdingAPI/Block.cs View File

@@ -135,8 +135,8 @@ namespace GamecraftModdingAPI
Id = id;
}

public Block(uint id) : this(new EGID(id, CommonExclusiveGroups.OWNED_BLOCKS_GROUP))
{
public Block(uint id) : this(new EGID(id, CommonExclusiveGroups.BUILD_STANDARD_BLOCK_GROUP))
{ //TODO: Figure out the block group based on the id
}

public EGID Id { get; }
@@ -147,10 +147,10 @@ namespace GamecraftModdingAPI
/// </summary>
public float3 Position
{
get => Exists ? MovementEngine.GetPosition(Id.entityID) : float3.zero;
get => Exists ? MovementEngine.GetPosition(Id) : float3.zero;
set
{
if (Exists) MovementEngine.MoveBlock(Id.entityID, value);
if (Exists) MovementEngine.MoveBlock(Id, value);
}
}

@@ -159,10 +159,10 @@ namespace GamecraftModdingAPI
/// </summary>
public float3 Rotation
{
get => Exists ? RotationEngine.GetRotation(Id.entityID) : float3.zero;
get => Exists ? RotationEngine.GetRotation(Id) : float3.zero;
set
{
if (Exists) RotationEngine.RotateBlock(Id.entityID, value);
if (Exists) RotationEngine.RotateBlock(Id, value);
}
}



+ 13
- 12
GamecraftModdingAPI/Blocks/BlockEngine.cs View File

@@ -38,14 +38,15 @@ namespace GamecraftModdingAPI.Blocks
public Block[] GetConnectedBlocks(EGID blockID)
{
if (!BlockExists(blockID)) return new Block[0];
Stack<uint> cubeStack = new Stack<uint>();
FasterList<uint> cubes = new FasterList<uint>(10);
var coll = entitiesDB.QueryEntities<GridConnectionsEntityStruct>(CommonExclusiveGroups
.OWNED_BLOCKS_GROUP);
for (int i = 0; i < coll.count; i++)
coll[i].isProcessed = false;
Stack<EGID> cubeStack = new Stack<EGID>();
FasterList<EGID> cubes = new FasterList<EGID>(10);
var coll = entitiesDB.QueryEntities<GridConnectionsEntityStruct>();
foreach (var (ecoll, _) in coll)
foreach (ref var conn in ecoll)
conn.isProcessed = false;

ConnectedCubesUtility.TreeTraversal.GetConnectedCubes(entitiesDB, blockID.entityID, cubeStack, cubes, (in GridConnectionsEntityStruct g) => { return false; });
ConnectedCubesUtility.TreeTraversal.GetConnectedCubes(entitiesDB, blockID, cubeStack, cubes,
(in GridConnectionsEntityStruct g) => { return false; });

var ret = new Block[cubes.count];
for (int i = 0; i < cubes.count; i++)
@@ -125,10 +126,10 @@ namespace GamecraftModdingAPI.Blocks
public SimBody[] GetSimBodiesFromID(byte id)
{
var ret = new FasterList<SimBody>(4);
if (!entitiesDB.HasAny<ObjectIdEntityStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP))
if (!entitiesDB.HasAny<ObjectIdEntityStruct>(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP))
return new SimBody[0];
var oids = entitiesDB.QueryEntities<ObjectIdEntityStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
var connections = entitiesDB.QueryMappedEntities<GridConnectionsEntityStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
var oids = entitiesDB.QueryEntities<ObjectIdEntityStruct>(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP);
var connections = entitiesDB.QueryMappedEntities<GridConnectionsEntityStruct>(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP);
foreach (ref ObjectIdEntityStruct oid in oids)
{
if (oid.objectId != id) continue;
@@ -147,9 +148,9 @@ namespace GamecraftModdingAPI.Blocks
public ObjectIdentifier[] GetObjectIDsFromID(byte id, bool sim)
{
var ret = new FasterList<ObjectIdentifier>(4);
if (!entitiesDB.HasAny<ObjectIdEntityStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP))
if (!entitiesDB.HasAny<ObjectIdEntityStruct>(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP))
return new ObjectIdentifier[0];
var oids = entitiesDB.QueryEntities<ObjectIdEntityStruct>(CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
var oids = entitiesDB.QueryEntities<ObjectIdEntityStruct>(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP);
foreach (ref ObjectIdEntityStruct oid in oids)
if (sim ? oid.simObjectId == id : oid.objectId == id)
ret.Add(new ObjectIdentifier(oid.ID));


+ 4
- 4
GamecraftModdingAPI/Blocks/BlockIdentifiers.cs View File

@@ -12,8 +12,8 @@ namespace GamecraftModdingAPI.Blocks
{
/// <summary>
/// Blocks placed by the player
/// </summary>
public static ExclusiveGroup OWNED_BLOCKS { get { return CommonExclusiveGroups.OWNED_BLOCKS_GROUP; } }
/// </summary> - TODO
//public static ExclusiveGroup OWNED_BLOCKS { get { return CommonExclusiveGroups.REAL_BLOCKS_GROUPS_DON_T_USE_IN_NEW_CODE; } }

/// <summary>
/// Extra parts used in functional blocks
@@ -23,7 +23,7 @@ namespace GamecraftModdingAPI.Blocks
/// <summary>
/// Blocks which are disabled in Simulation mode
/// </summary>
public static ExclusiveGroup SIM_BLOCKS_DISABLED { get { return CommonExclusiveGroups.BLOCKS_DISABLED_IN_SIM_GROUP; } }
public static ExclusiveGroup SIM_BLOCKS_DISABLED { get { return CommonExclusiveGroups.DISABLED_JOINTS_IN_SIM_GROUP; } }

//public static ExclusiveGroup SPAWN_POINTS { get { return CommonExclusiveGroups.SPAWN_POINTS_GROUP; } }

@@ -34,7 +34,7 @@ namespace GamecraftModdingAPI.Blocks
/// </summary>
public static uint LatestBlockID {
get
{
{ //Need the private field as the property increments itself
return ((uint) AccessTools.Field(typeof(CommonExclusiveGroups), "_nextBlockEntityID").GetValue(null)) - 1;
}
}


+ 2
- 1
GamecraftModdingAPI/Blocks/ConsoleBlock.cs View File

@@ -1,6 +1,7 @@
using System;

using RobocraftX.Blocks;
using RobocraftX.Common;
using Svelto.ECS;
using Unity.Mathematics;

@@ -33,7 +34,7 @@ namespace GamecraftModdingAPI.Blocks
}
}

public ConsoleBlock(uint id): base(id)
public ConsoleBlock(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_CONSOLE_BLOCK_GROUP))
{
if (!BlockEngine.GetBlockInfoExists<ConsoleBlockEntityStruct>(this.Id))
{


+ 2
- 1
GamecraftModdingAPI/Blocks/Motor.cs View File

@@ -1,6 +1,7 @@
using System;

using RobocraftX.Blocks;
using RobocraftX.Common;
using Svelto.ECS;
using Unity.Mathematics;

@@ -41,7 +42,7 @@ namespace GamecraftModdingAPI.Blocks
}
}

public Motor(uint id) : base(id)
public Motor(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP))
{
if (!BlockEngine.GetBlockInfoExists<MotorReadOnlyStruct>(this.Id))
{


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

@@ -35,12 +35,12 @@ namespace GamecraftModdingAPI.Blocks

// implementations for Movement static class

public float3 MoveBlock(uint blockID, float3 vector)
public float3 MoveBlock(EGID blockID, float3 vector)
{
ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref GridRotationStruct gridStruct = ref this.entitiesDB.QueryEntity<GridRotationStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref LocalTransformEntityStruct transStruct = ref this.entitiesDB.QueryEntity<LocalTransformEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref UECSPhysicsEntityStruct phyStruct = ref this.entitiesDB.QueryEntity<UECSPhysicsEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(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
posStruct.position = vector;
// placement grid position
@@ -52,13 +52,13 @@ namespace GamecraftModdingAPI.Blocks
{
Value = posStruct.position
});
entitiesDB.QueryEntity<GridConnectionsEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP).isProcessed = false;
entitiesDB.QueryEntity<GridConnectionsEntityStruct>(blockID).isProcessed = false;
return posStruct.position;
}

public float3 GetPosition(uint blockID)
public float3 GetPosition(EGID blockID)
{
ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity<PositionEntityStruct>(blockID);
return posStruct.position;
}
}


+ 2
- 1
GamecraftModdingAPI/Blocks/ObjectIdentifier.cs View File

@@ -1,4 +1,5 @@
using Gamecraft.Wires;
using RobocraftX.Common;
using Svelto.ECS;

namespace GamecraftModdingAPI.Blocks
@@ -13,7 +14,7 @@ namespace GamecraftModdingAPI.Blocks
}
}

public ObjectIdentifier(uint id) : base(id)
public ObjectIdentifier(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP))
{
if (!BlockEngine.GetBlockInfoExists<ObjectIdEntityStruct>(Id))
{


+ 2
- 1
GamecraftModdingAPI/Blocks/Piston.cs View File

@@ -5,6 +5,7 @@ using Svelto.ECS;
using Unity.Mathematics;

using GamecraftModdingAPI.Utility;
using RobocraftX.Common;

namespace GamecraftModdingAPI.Blocks
{
@@ -41,7 +42,7 @@ namespace GamecraftModdingAPI.Blocks
}
}

public Piston(uint id) : base(id)
public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_PISTON_BLOCK_GROUP))
{
if (!BlockEngine.GetBlockInfoExists<PistonReadOnlyStruct>(this.Id))
{


+ 3
- 16
GamecraftModdingAPI/Blocks/PlacementEngine.cs View File

@@ -66,8 +66,6 @@ namespace GamecraftModdingAPI.Blocks
RotationEntityStruct rotation = new RotationEntityStruct {rotation = rotQ};
GridRotationStruct gridRotation = new GridRotationStruct
{position = position, rotation = rotQ};
CubeCategoryStruct category = new CubeCategoryStruct
{category = CubeCategory.General, type = CubeType.Block};
DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid};
BlockPlacementScaleEntityStruct placementScale = new BlockPlacementScaleEntityStruct
{
@@ -76,21 +74,10 @@ namespace GamecraftModdingAPI.Blocks
unitSnapOffset = 0, isUsingUnitSize = true
};
EquippedColourStruct colour = new EquippedColourStruct {indexInPalette = color};
EGID newBlockID;
switch (category.category)
{
case CubeCategory.SpawnPoint:
case CubeCategory.BuildingSpawnPoint:
newBlockID = MachineEditingGroups.NewUncheckedBlockEGID;
break;
default:
newBlockID = MachineEditingGroups.NewBlockID;
break;
}

EntityComponentInitializer
structInitializer =
_blockEntityFactory.Build(newBlockID, dbid); //The ghost block index is only used for triggers
_blockEntityFactory.Build(CommonExclusiveGroups.nextBlockEntityID, dbid); //The ghost block index is only used for triggers
if (colour.indexInPalette != byte.MaxValue)
structInitializer.Init(new ColourParameterEntityStruct
{
@@ -117,10 +104,10 @@ namespace GamecraftModdingAPI.Blocks
PrimaryRotationUtility.InitialisePrimaryDirection(rotation.rotation, ref structInitializer);
EGID playerEGID = new EGID(playerId, CharacterExclusiveGroups.OnFootGroup);
ref PickedBlockExtraDataStruct pickedBlock = ref entitiesDB.QueryEntity<PickedBlockExtraDataStruct>(playerEGID);
pickedBlock.placedBlockEntityID = playerEGID;
pickedBlock.placedBlockEntityID = structInitializer.EGID;
pickedBlock.placedBlockWasAPickedBlock = false;
Block.BlockEngine.Synced = false; // Block entities will need to be submitted before properties can be used
return newBlockID;
return structInitializer.EGID;
}

public string Name { get; } = "GamecraftModdingAPIPlacementGameEngine";


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

@@ -35,12 +35,12 @@ namespace GamecraftModdingAPI.Blocks

// implementations for Rotation static class

public float3 RotateBlock(uint blockID, Vector3 vector)
public float3 RotateBlock(EGID blockID, Vector3 vector)
{
ref RotationEntityStruct rotStruct = ref this.entitiesDB.QueryEntity<RotationEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref GridRotationStruct gridStruct = ref this.entitiesDB.QueryEntity<GridRotationStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref LocalTransformEntityStruct transStruct = ref this.entitiesDB.QueryEntity<LocalTransformEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref UECSPhysicsEntityStruct phyStruct = ref this.entitiesDB.QueryEntity<UECSPhysicsEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
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;
@@ -58,14 +58,14 @@ namespace GamecraftModdingAPI.Blocks
{
Value = rotStruct.rotation
});
entitiesDB.QueryEntity<GridConnectionsEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP).isProcessed = false;
entitiesDB.QueryEntity<GridConnectionsEntityStruct>(blockID).isProcessed = false;
return ((Quaternion)rotStruct.rotation).eulerAngles;

}

public float3 GetRotation(uint blockID)
public float3 GetRotation(EGID blockID)
{
ref RotationEntityStruct rotStruct = ref entitiesDB.QueryEntity<RotationEntityStruct>(blockID, CommonExclusiveGroups.OWNED_BLOCKS_GROUP);
ref RotationEntityStruct rotStruct = ref entitiesDB.QueryEntity<RotationEntityStruct>(blockID);
return ((Quaternion) rotStruct.rotation).eulerAngles;
}
}


+ 2
- 1
GamecraftModdingAPI/Blocks/Servo.cs View File

@@ -1,6 +1,7 @@
using System;

using RobocraftX.Blocks;
using RobocraftX.Common;
using Svelto.ECS;
using Unity.Mathematics;

@@ -41,7 +42,7 @@ namespace GamecraftModdingAPI.Blocks
}
}

public Servo(uint id) : base(id)
public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SERVO_BLOCK_GROUP))
{
if (!BlockEngine.GetBlockInfoExists<ServoReadOnlyStruct>(this.Id))
{


+ 7
- 15
GamecraftModdingAPI/Blocks/SignalEngine.cs View File

@@ -1,4 +1,5 @@
using Svelto.ECS;
using Svelto.DataStructures;
using Gamecraft.Wires;

using GamecraftModdingAPI.Engines;
@@ -166,21 +167,12 @@ namespace GamecraftModdingAPI.Blocks
}

public EGID[] GetElectricBlocks()
{
uint count = entitiesDB.Count<BlockPortsStruct>(BlockIdentifiers.OWNED_BLOCKS) + entitiesDB.Count<BlockPortsStruct>(BlockIdentifiers.FUNCTIONAL_BLOCK_PARTS);
uint i = 0;
EGID[] res = new EGID[count];
foreach (ref BlockPortsStruct s in entitiesDB.QueryEntities<BlockPortsStruct>(BlockIdentifiers.OWNED_BLOCKS))
{
res[i] = s.ID;
i++;
}
foreach (ref BlockPortsStruct s in entitiesDB.QueryEntities<BlockPortsStruct>(BlockIdentifiers.FUNCTIONAL_BLOCK_PARTS))
{
res[i] = s.ID;
i++;
}
return res;
{
var res = new FasterList<EGID>();
foreach (var (coll, _) in entitiesDB.QueryEntities<BlockPortsStruct>())
foreach (ref BlockPortsStruct s in coll)
res.Add(s.ID);
return res.ToArray();
}

private EntityCollection<ChannelDataStruct> GetSignalStruct(uint signalID, out uint index, bool input = true)


+ 2
- 1
GamecraftModdingAPI/Blocks/SpawnPoint.cs View File

@@ -1,6 +1,7 @@
using System;

using RobocraftX.Blocks;
using RobocraftX.Common;
using Gamecraft.CharacterVulnerability;
using Svelto.ECS;
using Unity.Mathematics;
@@ -43,7 +44,7 @@ namespace GamecraftModdingAPI.Blocks
}
}

public SpawnPoint(uint id) : base(id)
public SpawnPoint(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SPAWNPOINT_BLOCK_GROUP))
{
if (!BlockEngine.GetBlockInfoExists<SpawnPointStatsEntityStruct>(this.Id))
{


+ 2
- 1
GamecraftModdingAPI/Blocks/TextBlock.cs View File

@@ -1,6 +1,7 @@
using System;

using Gamecraft.Blocks.GUI;
using RobocraftX.Common;
using Svelto.ECS;
using Unity.Mathematics;

@@ -34,7 +35,7 @@ namespace GamecraftModdingAPI.Blocks
}
}

public TextBlock(uint id) : base(id)
public TextBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TEXT_BLOCK_GROUP))
{
if (!BlockEngine.GetBlockInfoExists<TextBlockDataStruct>(this.Id))
{


+ 2
- 1
GamecraftModdingAPI/Blocks/Timer.cs View File

@@ -1,6 +1,7 @@
using System;

using RobocraftX.Blocks;
using RobocraftX.Common;
using Gamecraft.Blocks.TimerBlock;
using Svelto.ECS;
using Unity.Mathematics;
@@ -37,7 +38,7 @@ namespace GamecraftModdingAPI.Blocks
}
}

public Timer(uint id) : base(id)
public Timer(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TIMER_BLOCK_GROUP))
{
if (!BlockEngine.GetBlockInfoExists<TimerBlockDataStruct>(this.Id))
{


+ 2
- 2
GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs View File

@@ -43,10 +43,10 @@ namespace GamecraftModdingAPI.Events
}
}
public JobHandle OnInitializeTimeStoppedMode()
public JobHandle OnInitializeTimeStoppedMode(JobHandle inputDeps)
{
Emit();
return default(JobHandle);
return inputDeps;
}

public void Ready() { }


+ 2
- 2
GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs View File

@@ -42,10 +42,10 @@ namespace GamecraftModdingAPI.Events
}
}

public JobHandle OnInitializeTimeRunningMode()
public JobHandle OnInitializeTimeRunningMode(JobHandle inputDeps)
{
Emit();
return default(JobHandle);
return inputDeps;
}

public void Ready() { }


+ 0
- 4
GamecraftModdingAPI/GamecraftModdingAPI.csproj View File

@@ -80,10 +80,6 @@
<HintPath>..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
</Reference>
<Reference Include="ClusterToWireConversion.Mock">
<HintPath>..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath>
</Reference>
<Reference Include="CommandLine">
<HintPath>..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>


+ 1
- 7
GamecraftModdingAPI/Persistence/IEntitySerializer.cs View File

@@ -12,13 +12,7 @@ namespace GamecraftModdingAPI.Persistence
/// </summary>
public interface IEntitySerializer : IDeserializationFactory, IQueryingEntitiesEngine
{
/// <summary>
/// The entity factory used for creating entities and entity components.
/// </summary>
/// <value>The entity factory.</value>
IEntityFactory EntityFactory { set; }

/// <summary>
/// <summary>
/// Serialize the entities.
/// </summary>
/// <returns>Whether serialization was successful.</returns>


+ 0
- 3
GamecraftModdingAPI/Persistence/SerializerManager.cs View File

@@ -29,7 +29,6 @@ namespace GamecraftModdingAPI.Persistence
_registrations[name] = (IEntitySerialization ies) => { ies.RegisterSerializationFactory<T>(serializer); };
if (_lastEnginesRoot != null)
{
serializer.EntityFactory = _lastEnginesRoot.GenerateEntityFactory();
_registrations[name].Invoke(_lastEnginesRoot.GenerateEntitySerializer());
_lastEnginesRoot.AddEngine(serializer);
}
@@ -63,12 +62,10 @@ namespace GamecraftModdingAPI.Persistence
public static void RegisterSerializers(EnginesRoot enginesRoot)
{
_lastEnginesRoot = enginesRoot;
IEntityFactory factory = enginesRoot.GenerateEntityFactory();
IEntitySerialization ies = enginesRoot.GenerateEntitySerializer();
foreach (string key in _serializers.Keys)
{
Logging.MetaDebugLog($"Registering IEntitySerializer for {key}");
_serializers[key].EntityFactory = factory;
_registrations[key].Invoke(ies);
enginesRoot.AddEngine(_serializers[key]);
}


+ 2
- 4
GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs View File

@@ -21,13 +21,11 @@ namespace GamecraftModdingAPI.Persistence

protected int serializationType;

public IEntityFactory EntityFactory { set; protected get; }

public EntitiesDB entitiesDB { set; protected get; }

public EntityComponentInitializer BuildDeserializedEntity(EGID egid, ISerializationData serializationData, ISerializableEntityDescriptor entityDescriptor, int serializationType, IEntitySerialization entitySerialization)
public EntityComponentInitializer BuildDeserializedEntity(EGID egid, ISerializationData serializationData, ISerializableEntityDescriptor entityDescriptor, int serializationType, IEntitySerialization entitySerialization, IEntityFactory factory, bool enginesRootIsDeserializationOnly)
{
EntityComponentInitializer esi = EntityFactory.BuildEntity<Descriptor>(egid);
EntityComponentInitializer esi = factory.BuildEntity<Descriptor>(egid);
entitySerialization.DeserializeEntityComponents(serializationData, entityDescriptor, ref esi, serializationType);
return esi;
}


+ 2
- 2
GamecraftModdingAPI/Player.cs View File

@@ -51,7 +51,7 @@ namespace GamecraftModdingAPI
/// <returns>The count.</returns>
public static uint Count()
{
return playerEngine.GetAllPlayerCount();
return (uint) playerEngine.GetAllPlayerCount();
}

/// <summary>
@@ -357,7 +357,7 @@ namespace GamecraftModdingAPI
public Block GetBlockLookedAt(float maxDistance = -1f)
{
var egid = playerEngine.GetThingLookedAt(Id, maxDistance);
return egid.HasValue && egid.Value.groupID == CommonExclusiveGroups.OWNED_BLOCKS_GROUP
return egid.HasValue && egid.Value.groupID != CommonExclusiveGroups.SIMULATION_BODIES_GROUP
? new Block(egid.Value)
: null;
}


+ 4
- 4
GamecraftModdingAPI/Players/PlayerEngine.cs View File

@@ -65,10 +65,10 @@ namespace GamecraftModdingAPI.Players
return uint.MaxValue;
}

public uint GetAllPlayerCount()
public long GetAllPlayerCount()
{
if (entitiesDB == null) return 0;
uint count = 0;
long count = 0;
foreach (ExclusiveGroupStruct eg in PlayersExclusiveGroups.AllPlayers)
{
count += entitiesDB.Count<PlayerIDStruct>(eg);
@@ -76,13 +76,13 @@ namespace GamecraftModdingAPI.Players
return count;
}

public uint GetLocalPlayerCount()
public long GetLocalPlayerCount()
{
if (entitiesDB == null) return 0;
return entitiesDB.Count<PlayerIDStruct>(PlayersExclusiveGroups.LocalPlayers);
}

public uint GetRemotePlayerCount()
public long GetRemotePlayerCount()
{
if (entitiesDB == null) return 0;
return entitiesDB.Count<PlayerIDStruct>(PlayersExclusiveGroups.RemotePlayers);


Loading…
Cancel
Save