private ErrorCodes CollectEnvironmentData(long eid, int range, out int definition, out EntityEnvironmentDescription result)
        {
            result = new EntityEnvironmentDescription();
            const ErrorCodes ec = ErrorCodes.NoError;

            definition = 0;

            var unit = _zone.GetUnit(eid);

            if (unit == null)
            {
                return(ErrorCodes.ItemNotFound);
            }

            definition = unit.Definition;

            var entityPosition = unit.CurrentPosition;

            var sampleArea = _zone.CreateArea(entityPosition, range);

            var turns = (int)(Math.Round(unit.Orientation, 2) / 0.25);

            var blocksTiles = CollectBlockingHeight(sampleArea, entityPosition, turns);

            if (blocksTiles.Count > 0)
            {
                result.blocksTiles = blocksTiles;
            }

            return(ec);
        }
        public static void WriteEnvironmentToSql(int definition, EntityEnvironmentDescription nativeEnvironmentData)
        {
            var descriptionString = GenxyConverter.Serialize(nativeEnvironmentData.ToDictionary());

            Db.Query().CommandText("writeEnvironment")
            .SetParameter("@definition", definition)
            .SetParameter("@descriptionstring", descriptionString)
            .ExecuteScalar <int>().ThrowIfEqual(0, ErrorCodes.SQLInsertError);
        }
        private static EntityEnvironmentDescription ConvertFromString(string descriptionString)
        {
            var nativeDescription = new EntityEnvironmentDescription();

            var descriptionObjects = GenxyConverter.Deserialize(descriptionString);

            if (descriptionObjects.ContainsKey(k.blocks))
            {
                var tileDict = (Dictionary <string, object>)descriptionObjects[k.blocks];
                nativeDescription.blocksTiles = ConvertTilesToList(tileDict);
            }

            return(nativeDescription);
        }
        public ErrorCodes CollectEnvironmentFromPosition(Position origin, int range, int turns, out EntityEnvironmentDescription result)
        {
            result = new EntityEnvironmentDescription();

            var sampleArea = _zone.CreateArea(origin, range);

            var blocksTiles = CollectBlockingHeight(sampleArea, origin, turns);

            if (blocksTiles.Count > 0)
            {
                result.blocksTiles = blocksTiles;
            }

            return(ErrorCodes.NoError);
        }