public ErrorCodes DrawDecorEnvironment(int decorId)
        {
            DecorDescription decorDescription;

            if (!_decors.TryGetValue(decorId, out decorDescription))
            {
                return(ErrorCodes.ItemNotFound);
            }

            var environmentDescription = EntityEnvironment.LoadEnvironmentSql(decorDescription.definition);

            if (environmentDescription.Equals(default(EntityEnvironmentDescription)))
            {
                return(ErrorCodes.DefinitionHasNoEnvironment);
            }

            ErrorCodes ec;
            var        newTurns = -1;
            var        flipX    = false;
            var        flipY    = false;

            if ((ec = decorDescription.FindQuaternionRotationAndMirror(ref newTurns, ref flipX, ref flipY)) != ErrorCodes.NoError)
            {
                return(ec);
            }

            _zone.DrawEnvironmentForDecor(decorDescription.GetServerPosition(), environmentDescription, newTurns, flipX, flipY);
            return(ErrorCodes.NoError);
        }
Esempio n. 2
0
        public static void CleanEnvironmentByUnit(this IZone zone, Unit unit)
        {
            var description = EntityEnvironment.LoadEnvironmentSql(unit.Definition);
            var turns       = (int)(Math.Round(unit.Orientation, 2) / 0.25);

            CleanEnvironmentWithMirrorAndTurns(zone, unit.CurrentPosition, description, turns, false, false);
        }
Esempio n. 3
0
        private static void DrawEnvironmentByDefinitionAndPosition(this IZone zone, Unit unit)
        {
            //enviroment load
            var description = EntityEnvironment.LoadEnvironmentSql(unit.Definition);

            //draw extra environment
            if (description.Equals(default(EntityEnvironmentDescription)))
            {
                return;
            }

            if (description.blocksTiles == null || description.blocksTiles.Count <= 0)
            {
                return;
            }

            foreach (var tile in description.blocksTiles)
            {
                var offsetPosition = unit.CurrentPosition + tile.ToPosition();
                if (!offsetPosition.IsValid(zone.Size))
                {
                    continue;
                }

                zone.Terrain.Blocks.UpdateValue(offsetPosition, bi =>
                {
                    return(new BlockingInfo
                    {
                        Obstacle = true,
                        Height = Math.Max(bi.Height, tile.data),
                    });
                });
            }
        }
Esempio n. 4
0
        public static void CleanBlockingByDefinition(this IZone zone, EntityDefault entityDefault)
        {
            Logger.Info($"clean blocking for definition:{entityDefault.Definition} {entityDefault.Name} on zone:{zone.Id}");

            var units = zone.Units.Where(u => u.ED == entityDefault).ToList();

            foreach (var unit in units)
            {
                Logger.Info($"cleaning position: {unit.CurrentPosition.ToDoubleString2D()}");
                //enviroment load
                var description = EntityEnvironment.LoadEnvironmentSql(entityDefault.Definition);
                //clean environment
                CleanEnvironmentFromLayers(zone, unit.CurrentPosition, description);
            }

            Logger.Info($"{units.Count} {entityDefault.Name} cleaned.");
        }