protected override void OnLoad(BitStream stream, Action <MyCharacter> loadingDoneHandler) { bool isUsing; VRage.Serialization.MySerializer.CreateAndRead(stream, out isUsing); if (isUsing) { long ownerId; VRage.Serialization.MySerializer.CreateAndRead(stream, out ownerId); long characterId; VRage.Serialization.MySerializer.CreateAndRead(stream, out characterId); MyEntities.CallAsync(() => LoadAsync(ownerId, characterId, loadingDoneHandler)); } else { MyCharacter character = new MyCharacter(); MyObjectBuilder_Character builder = (MyObjectBuilder_Character)VRage.Serialization.MySerializer.CreateAndRead <MyObjectBuilder_EntityBase>(stream, MyObjectBuilderSerializer.Dynamic); TryRemoveExistingEntity(builder.EntityId); Vector3 velocity = builder.LinearVelocity; velocity /= MyEntityPhysicsStateGroup.EffectiveSimulationRatio; builder.LinearVelocity = velocity; MyEntities.InitAsync(character, builder, true, (e) => loadingDoneHandler(character)); } }
protected override void OnLoad(VRage.Library.Collections.BitStream stream, Action <MyCraftingComponentBase> loadingDoneHandler) { long entityId; VRage.Serialization.MySerializer.CreateAndRead(stream, out entityId); MyEntities.CallAsync(() => LoadAsync(entityId, loadingDoneHandler)); }
protected override void OnLoad(BitStream stream, Action <T> loadingDoneHandler) { long entityId; VRage.Serialization.MySerializer.CreateAndRead(stream, out entityId); MyEntities.CallAsync(() => LoadAsync(entityId, loadingDoneHandler)); }
protected override void OnLoad(BitStream stream, Action <MyInventory> loadingDoneHandler) { if (stream != null) { MySerializer.CreateAndRead(stream, out m_entityId); MySerializer.CreateAndRead(stream, out m_inventoryId); } MyEntities.CallAsync(delegate { LoadAsync(loadingDoneHandler); }); }
protected override void OnLoad(BitStream stream, Action <MyCubeGrid> loadingDoneHandler) { bool isSplit = stream.ReadBool(); MyCubeGrid grid = null; if (isSplit) { long gridId = stream.ReadInt64(); MyEntities.CallAsync(() => loadingDoneHandler(FindGrid(gridId))); } else { grid = new MyCubeGrid(); grid.DebugCreatedBy = DebugCreatedBy.FromServer; var builder = VRage.Serialization.MySerializer.CreateAndRead <MyObjectBuilder_EntityBase>(stream, MyObjectBuilderSerializer.Dynamic); Byte numSubGrids = stream.ReadByte(); bool hasSubGrids = numSubGrids > 0; for (int i = 0; i < numSubGrids; ++i) { var subGridBuilder = VRage.Serialization.MySerializer.CreateAndRead <MyObjectBuilder_EntityBase>(stream, MyObjectBuilderSerializer.Dynamic); if (m_builders == null) { m_builders = new List <MyObjectBuilder_EntityBase>(); } m_builders.Add(subGridBuilder); } if (hasSubGrids == false) { MyEntities.InitAsync(grid, builder, true, (e) => loadingDoneHandler(grid)); } else { MyEntities.InitAsync(grid, builder, true, (e) => loadingDoneHandler(grid), m_builders); } } }
protected override void OnLoad(BitStream stream, Action <MySyncedBlock> loadingDoneHandler) { long blockEntityId = stream.ReadInt64(); MyEntities.CallAsync(() => loadingDoneHandler(FindBlock(blockEntityId))); }