예제 #1
0
 void ActualEntity_ChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db)
 {
     if (changeType == EntityChangeData.EntityChangeType.EntityRemoved)
     {
         Position.GetDataFrom = DataFrom.Memory;
     }
 }
예제 #2
0
        internal void SetDataBlob(int entityID, BaseDataBlob dataBlob, bool updateListners = true)
        {
            int typeIndex;

            TryGetTypeIndex(dataBlob.GetType(), out typeIndex);
            SetDataBlob(entityID, dataBlob, typeIndex, updateListners);
        }
예제 #3
0
        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);
        }
예제 #4
0
            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);
            }
예제 #5
0
        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);
        }
예제 #6
0
 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);
     }
 }
예제 #7
0
        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];
        }
예제 #8
0
        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);
        }
예제 #9
0
 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);
         }
     }
 }
예제 #10
0
        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);
        }
예제 #11
0
            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);
            }
예제 #12
0
 public void InvokeChangeEvent(EntityChangeData.EntityChangeType changeType, BaseDataBlob db)
 {
     ChangeEvent?.Invoke(changeType, db);
 }
예제 #13
0
 internal static void CompareDatabob <T>(BaseDataBlob db, Entity sensorEntity) where T : BaseDataBlob
 {
     if (sensorEntity.HasDataBlob <T>())
     {
     }
 }
예제 #14
0
 public static void Export([NotNull] Game game, [NotNull] Stream outputStream, [NotNull] BaseDataBlob datablob, bool compress       = false) => ExportInternal(game, outputStream, datablob, compress);
예제 #15
0
 public static string Export([NotNull] Game game, [NotNull] BaseDataBlob datablob, bool compress = false) => Export <BaseDataBlob>(game, datablob, compress);
예제 #16
0
 internal void SetDataBlob(int entityID, BaseDataBlob dataBlob, int typeIndex)
 {
     _dataBlobMap[typeIndex][entityID] = dataBlob;
     EntityMasks[entityID][typeIndex]  = true;
     dataBlob.OwningEntity             = _entities[entityID];
 }