Пример #1
0
        protected override void Process()
        {
            if (!BCUtils.CheckWorld(out var world))
            {
                return;
            }

            if (Options.ContainsKey("all") || Options.ContainsKey("istype") || Options.ContainsKey("type") || Options.ContainsKey("minibike") || Options.ContainsKey("ecname"))
            {
                var count = new Dictionary <string, int>();

                foreach (var key in BCUtils.FilterEntities(world.Entities.dict, Options).Keys)
                {
                    RemoveEntity(world, key, count);
                }

                SendJson(count);
            }
            else if (Params.Count == 1)
            {
                if (!int.TryParse(Params[0], out var entityId))
                {
                    SendOutput("Unable to parse entity id");

                    return;
                }

                RemoveEntity(world, entityId);
            }
            else
            {
                SendOutput(GetHelp());
            }
        }
Пример #2
0
        public override void Process()
        {
            var world = GameManager.Instance.World;

            if (world == null)
            {
                return;
            }

            if (Options.ContainsKey("all") || Options.ContainsKey("istype") || Options.ContainsKey("type") || Options.ContainsKey("minibike"))
            {
                var count = new Dictionary <string, int>();

                foreach (var key in BCUtils.FilterEntities(world.Entities.dict, Options).Keys)
                {
                    RemoveEntity(key, count);
                }

                SendJson(count);
            }
            else if (Params.Count == 1)
            {
                if (!int.TryParse(Params[0], out var entityId))
                {
                    SendOutput("Unable to parse entity id");

                    return;
                }

                RemoveEntity(entityId);
            }
            else
            {
                SendOutput(GetHelp());
            }
        }
Пример #3
0
        protected override void Process()
        {
            if (!BCUtils.CheckWorld(out var world))
            {
                return;
            }

            if (Options.ContainsKey("filters"))
            {
                Filters();

                return;
            }

            if (Options.ContainsKey("index"))
            {
                Indexed();

                return;
            }

            if (Params.Count > 1)
            {
                SendOutput("Wrong number of arguments");
                SendOutput(Config.GetHelp(GetType().Name));

                return;
            }

            if (Params.Count == 1)
            {
                // specific entity
                Entity e = null;
                if (int.TryParse(Params[0], out var entityId))
                {
                    if (world.Entities.dict.ContainsKey(entityId))
                    {
                        e = world.Entities.dict[entityId];
                    }
                }
                if (e == null)
                {
                    SendOutput("Entity id not found.");

                    return;
                }

                var entity = new BCMEntity(e, Options, GetFilters(BCMGameObject.GOTypes.Entities));
                if (Options.ContainsKey("min"))
                {
                    SendJson(new List <List <object> >
                    {
                        entity.Data().Select(d => d.Value).ToList()
                    });
                }
                else
                {
                    SendJson(entity.Data());
                }
            }
            else
            {
                //todo: /entity=id1,id2,id3

                // All entities
                var data = new List <object>();
                foreach (var entity in BCUtils.FilterEntities(world.Entities.dict, Options).Values.Select(en => new BCMEntity(en, Options, GetFilters(BCMGameObject.GOTypes.Entities))))
                {
                    if (Options.ContainsKey("min"))
                    {
                        data.Add(entity.Data().Select(d => d.Value).ToList());
                    }
                    else
                    {
                        data.Add(entity.Data());
                    }
                }

                SendJson(data);
            }
        }