Beispiel #1
0
        public override void Process()
        {
            //todo: reset region

            var loc = new Vector3i {
                y = 0
            };

            if (Params.Count == 2)
            {
                if (int.TryParse(Params[0], out loc.x) && int.TryParse(Params[1], out loc.z))
                {
                    return;
                }

                SendOutput("One of <x> <z> params could not be parsed as a number.");
            }
            else if (Options.ContainsKey("here"))
            {
                EntityPlayer entityPlayer = null;
                if (SenderInfo.RemoteClientInfo != null)
                {
                    entityPlayer = GameManager.Instance.World.Entities.dict[SenderInfo.RemoteClientInfo.entityId] as EntityPlayer;
                }

                if (entityPlayer == null)
                {
                    return;
                }

                loc.RoundToInt(entityPlayer.position);
            }
            else
            {
                SendOutput(GetHelp());

                return;
            }

            //var chunk = GameManager.Instance.World.GetChunkFromWorldPos(loc) as Chunk;
            //todo: call the regeneration methods from ChunkProviderGenerateWorld
            //chunk.Reset();
        }
Beispiel #2
0
        private Vector3i GetTarget()
        {
            Vector3i   v  = Vector3i.zero;
            ClientInfo ci = null;

            if (Params.Count < 3 && SenderInfo.RemoteClientInfo != null)
            {
                ci = SenderInfo.RemoteClientInfo;
            }
            else
            {
                var nameOrId = Params[0];

                ConsoleHelper.ParseParamPartialNameOrId(nameOrId, out string _, out ci);
                if (ci != null)
                {
                }
            }

            EntityPlayer target = null;

            if (ci != null)
            {
                target = GameManager.Instance.World.Entities.dict[ci.entityId] as EntityPlayer;
            }

            if (target != null)
            {
                v.RoundToInt(target.position);
            }
            else
            {
                SendOutput("Unable to find target to get location");
            }

            return(v);
        }
Beispiel #3
0
        private static void RemoveEntity(int entityId, IDictionary <string, int> count = null)
        {
            var world = GameManager.Instance.World;

            if (world == null)
            {
                return;
            }

            if (!world.Entities.dict.ContainsKey(entityId))
            {
                if (!Options.ContainsKey("all"))
                {
                    SendOutput("Invalid entityId, entity not found: " + entityId);
                }

                return;
            }

            var e = world.Entities.dict[entityId];

            if (e == null)
            {
                if (!Options.ContainsKey("all"))
                {
                    SendOutput("Invalid entity, entity not found: " + entityId);
                }

                return;
            }

            if (e is EntityPlayer)
            {
                if (!Options.ContainsKey("all"))
                {
                    SendOutput("You can't remove a player!");
                }

                return;
            }

            world.RemoveEntity(entityId, EnumRemoveEntityReason.Despawned);

            var entityClass = EntityClass.list[e.entityClass];

            if (Options.ContainsKey("all") || Options.ContainsKey("istype") || Options.ContainsKey("type"))
            {
                if (count == null)
                {
                    return;
                }

                if (count.ContainsKey(e.GetType() + ":" + entityClass.entityClassName))
                {
                    count[e.GetType() + ":" + entityClass.entityClassName]++;
                }
                else
                {
                    count.Add(e.GetType() + ":" + entityClass.entityClassName, 1);
                }
            }
            else
            {
                var v = new Vector3i();
                v.RoundToInt(e.position);
                SendOutput($"Entity Removed: {e.GetType()}:{(entityClass != null ? entityClass.entityClassName : "")} @{v.x} {v.y} {v.z}");
            }
        }