public void FromBytes(ByteQueue bytes)
        {
            Clear();
            startStateTick    = bytes.GetInt();
            endStateTick      = bytes.GetInt();
            entityCount.value = bytes.GetIToBytes <LongValue>(entityCount.GetType()).value;
            spawns.AddRange(bytes.GetIToBytes <SerializableListEntity>(spawns.GetType()));
            despawns.AddRange(bytes.GetIToBytes <SerializableListEntity>(despawns.GetType()));

            foreach (var componentType in componentTypes)
            {
                for (int i = 0; i < entityCount.value; i++)
                {
                    var hasChanges = bytes.GetBool();
                    if (hasChanges)
                    {
                        changes[componentType].Add(bytes.GetIToBytes <Component>(componentType));
                    }
                    else
                    {
                        changes[componentType].Add(null);
                    }
                }
            }
        }
Example #2
0
        public void FromBytes(ByteQueue bytes)
        {
            tick = bytes.GetInt();
            entities.Clear();
            entities.FromBytes(bytes);

            foreach (var componentType in componentTypes)
            {
                foreach (var entity in entities)
                {
                    var hasComponent = bytes.GetBool();
                    if (hasComponent)
                    {
                        entity.AddComponent(bytes.GetIToBytes <Component>(componentType));
                    }
                }
            }
        }