コード例 #1
0
        public static JObject Serialize(DurableEntity durableEntity)
        {
            var retObject = new JObject();

            SerializationUtils.SerializeType(durableEntityType, ref retObject);
            Serialize(durableEntity, ref retObject);

            return(retObject);
        }
コード例 #2
0
        public new static DurableEntity Deserialize(JObject jObject)
        {
            DurableEntity durableEntity = ReflectionUtils.CallPrivateConstructor <DurableEntity>();

            Deserialize(ref jObject, durableEntity);

            durableEntity.Init();

            return(durableEntity);
        }
コード例 #3
0
        public static LivingEntity Create(WorldPosition worldPosition, LivingEntityType livingEntityType)
        {
            MovingEntity livingEntity = null;

            if (livingEntityType.ID == Player)
            {
                livingEntity = new Player(worldPosition)
                {
                    PreloadedSurroundingWorldGridChunkRadius = livingEntityType.PreloadedSurroundingWorldGridChunkRadius
                };
            }
            else if (livingEntityType.IsDurableEntity)
            {
                livingEntity = new DurableEntity(worldPosition)
                {
                    PreloadedSurroundingWorldGridChunkRadius = livingEntityType.PreloadedSurroundingWorldGridChunkRadius
                };
            }
            else
            {
                livingEntity = new MovingEntity(worldPosition);
            }

            livingEntity.YPositionDepthOffset = (livingEntityType.YPositionDepthOffset == 0) ? 15 : livingEntityType.YPositionDepthOffset;
            livingEntity.LivingEntityType     = livingEntityType.ID;

            livingEntity.MaximumLife = livingEntityType.MaximumLife;
            livingEntity.CurrentLife = livingEntityType.CurrentLife;
            livingEntity.Invincible  = livingEntityType.Invincible;

            livingEntity.LifeRegeneration = livingEntityType.LifeRegeneration;
            livingEntity.Fraction         = livingEntityType.Fraction;
            livingEntity.Velocity         = livingEntityType.Velocity;

            livingEntity.LiveSpan = livingEntityType.LiveSpan;

            livingEntity.SetBlocking(livingEntityType.IsBlocking);
            livingEntity.SetHitable(livingEntityType.IsHitable);

            livingEntity.CustomProperties = livingEntityType.CustomProperties != null ? (JObject)livingEntityType.CustomProperties.DeepClone() : null;

            livingEntity.Init();

            return(livingEntity);
        }
コード例 #4
0
        protected static void Serialize(DurableEntity durableEntity, ref JObject jObject)
        {
            MovingEntitySerializer.Serialize(durableEntity, ref jObject);

            SerializationUtils.AddToObject(jObject, durableEntity, durableEntityType, serializeableProperties);
        }
コード例 #5
0
        protected static void Deserialize(ref JObject jObject, DurableEntity durableEntity)
        {
            MovingEntitySerializer.Deserialize(ref jObject, durableEntity);

            SerializationUtils.SetFromObject(jObject, durableEntity, durableEntityType, serializeableProperties);
        }