Ejemplo n.º 1
0
        public string RemoveStructure(Session session, String[] parms)
        {
            bool help = false;
            uint x    = 0;
            uint y    = 0;

            try
            {
                var p = new OptionSet
                {
                    { "?|help|h", v => help = true },
                    { "x=", v => x = uint.Parse(v.TrimMatchingQuotes()) },
                    { "y=", v => y = uint.Parse(v.TrimMatchingQuotes()) }
                };
                p.Parse(parms);
            }
            catch (Exception)
            {
                help = true;
            }

            if (help || x == 0 || y == 0)
            {
                return("removestructure --x=### --y=###");
            }

            IRegion region = world.Regions.GetRegion(x, y);

            if (region == null)
            {
                return("Invalid coordinates");
            }

            var structure = region.GetObjectsInTile(x, y).OfType <IStructure>().FirstOrDefault();

            if (structure == null)
            {
                return("No structures found at specified coordinates");
            }

            return(locker.Lock(structure.City).Do(() =>
            {
                var removeAction = actionFactory.CreateStructureSelfDestroyPassiveAction(structure.City.Id, structure.ObjectId);
                var result = structure.City.Worker.DoPassive(structure.City, removeAction, false);

                if (result != Error.Ok)
                {
                    return string.Format("Error: {0}", result);
                }

                return "OK!";
            }));
        }
Ejemplo n.º 2
0
        public IEnumerable <ISimpleGameObject> GetObjectsInTile(uint x, uint y)
        {
            IRegion region = GetRegion(x, y);

            return(region == null ? new ISimpleGameObject[0] : region.GetObjectsInTile(x, y));
        }