void ActualEntity_ChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db) { if (changeType == EntityChangeData.EntityChangeType.EntityRemoved) { Position.GetDataFrom = DataFrom.Memory; } }
internal void SetDataBlob(int entityID, BaseDataBlob dataBlob, bool updateListners = true) { int typeIndex; TryGetTypeIndex(dataBlob.GetType(), out typeIndex); SetDataBlob(entityID, dataBlob, typeIndex, updateListners); }
public static BaseDataBlob ImportDatablob([NotNull] Game game, Entity entity, Type type, Stream inputStream) { BaseDataBlob datablob = (BaseDataBlob)Activator.CreateInstance(type); datablob = Import <BaseDataBlob>(game, inputStream, datablob); return(datablob); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { //bool exists1 = Testing.manager.EntityExistsGlobaly(Testing.entityID); var protoEntity = new ProtoEntity(); //StarObject (Entity) reader.Read(); // PropertyName ID reader.Read(); // Actual ID protoEntity.Guid = serializer.Deserialize <Guid>(reader); // Deserialize the ID //bool exists2 = Testing.manager.EntityExistsGlobaly(Testing.entityID); // Deserialize the dataBlobs reader.Read(); // PropertyName DATABLOB while (reader.TokenType == JsonToken.PropertyName) { var typestring = "Pulsar4X.ECSLib." + (string)reader.Value; Type dataBlobType = Type.GetType(typestring); reader.Read(); // StartObject (dataBlob) //bool exists3 = Testing.manager.EntityExistsGlobaly(Testing.entityID); BaseDataBlob dataBlob = (BaseDataBlob)serializer.Deserialize(reader, dataBlobType); // EndObject (dataBlob) //bool exists4 = Testing.manager.EntityExistsGlobaly(Testing.entityID); protoEntity.SetDataBlob(dataBlob); reader.Read(); // PropertyName DATABLOB OR EndObject (Entity) //bool exists5 = Testing.manager.EntityExistsGlobaly(Testing.entityID); } //bool exists6 = Testing.manager.EntityExistsGlobaly(Testing.entityID); return(protoEntity); }
internal void RemoveDataBlob(int entityID, int typeIndex) { BaseDataBlob db = _dataBlobMap[typeIndex][entityID]; _dataBlobMap[typeIndex][entityID].OwningEntity = null; _dataBlobMap[typeIndex][entityID] = null; EntityMasks[entityID][typeIndex] = false; UpdateListners(_entities[entityID], db, EntityChangeType.DBRemoved); }
internal void SetDataBlob(int entityID, BaseDataBlob dataBlob, int typeIndex, bool updateListners = true) { _dataBlobMap[typeIndex][entityID] = dataBlob; EntityMasks[entityID][typeIndex] = true; dataBlob.OwningEntity = _entities[entityID]; if (updateListners) { UpdateListners(_entities[entityID], dataBlob, EntityChangeType.DBAdded); } }
internal void SetDataBlob(int entityID, BaseDataBlob dataBlob) { int typeIndex; TryGetTypeIndex(dataBlob.GetType(), out typeIndex); _dataBlobMap[typeIndex][entityID] = dataBlob; EntityMasks[entityID][typeIndex] = true; dataBlob.OwningEntity = _entities[entityID]; }
internal List <BaseDataBlob> GetAllDataBlobsForEntity(int entityID) { var dataBlobs = new List <BaseDataBlob>(); for (int i = 0; i < InternalDataBlobTypes.Count; i++) { BaseDataBlob dataBlob = _dataBlobMap[i][entityID]; if (dataBlob != null) { dataBlobs.Add(dataBlob); } } return(dataBlobs); }
private void UpdateListners(Entity entity, BaseDataBlob db, EntityChangeType change) { if (EntityListners.Count > 0) { var changeData = new EntityChangeData() { Entity = entity, Datablob = db, ChangeType = change }; foreach (var item in EntityListners) { item.AddChange(changeData); } } }
private void UpdateListners(Entity entity, BaseDataBlob db, EntityChangeType change) { //listners to this work on thier own threads and are not affected by this one. if (EntityListners.Count > 0) { var changeData = new EntityChangeData() { Entity = entity, Datablob = db, ChangeType = change }; foreach (var item in EntityListners) { item.AddChange(changeData); } } //this one works on the active (ie this) thread entity.InvokeChangeEvent(change, db); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var protoEntity = new ProtoEntity(); //StarObject (Entity) reader.Read(); // PropertyName Guid reader.Read(); // Actual Guid protoEntity.Guid = serializer.Deserialize <Guid>(reader); // Deserialize the Guid // Deserialize the dataBlobs reader.Read(); // PropertyName DATABLOB while (reader.TokenType == JsonToken.PropertyName) { Type dataBlobType = Type.GetType("Pulsar4X.ECSLib." + (string)reader.Value); reader.Read(); // StartObject (dataBlob) BaseDataBlob dataBlob = (BaseDataBlob)serializer.Deserialize(reader, dataBlobType); // EndObject (dataBlob) protoEntity.SetDataBlob(dataBlob); reader.Read(); // PropertyName DATABLOB OR EndObject (Entity) } return(protoEntity); }
public void InvokeChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db) { ChangeEvent?.Invoke(changeType, db); }
internal static void CompareDatabob <T>(BaseDataBlob db, Entity sensorEntity) where T : BaseDataBlob { if (sensorEntity.HasDataBlob <T>()) { } }
public static void Export([NotNull] Game game, [NotNull] Stream outputStream, [NotNull] BaseDataBlob datablob, bool compress = false) => ExportInternal(game, outputStream, datablob, compress);
public static string Export([NotNull] Game game, [NotNull] BaseDataBlob datablob, bool compress = false) => Export <BaseDataBlob>(game, datablob, compress);
internal void SetDataBlob(int entityID, BaseDataBlob dataBlob, int typeIndex) { _dataBlobMap[typeIndex][entityID] = dataBlob; EntityMasks[entityID][typeIndex] = true; dataBlob.OwningEntity = _entities[entityID]; }