Ejemplo n.º 1
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var mod = trigger.Text.NextModifiers();
                var id  = trigger.Text.NextEnum(GOEntryId.End);

                var entry = GOMgr.GetEntry(id, false);

                var target = trigger.Args.Target;
                var map    = target != null ? target.Map : World.Kalimdor;

                if (mod == "c")
                {
                    // spawn closest
                    GOSpawnEntry closest;

                    if (entry != null)
                    {
                        // Entry specified
                        closest = entry.SpawnEntries.GetClosestEntry(target);
                    }
                    else
                    {
                        // no entry, just spawn any nearby Template
                        var templates = GOMgr.GetSpawnPoolTemplatesByMap(map.Id);
                        closest = templates == null ? null : templates.GetClosestEntry(target);
                    }

                    if (closest == null)
                    {
                        trigger.Reply("No valid SpawnEntries found (Entry: {0})", entry);
                    }
                    else
                    {
                        closest.Spawn(map);
                        trigger.Reply("Spawned: " + closest.Entry);
                        if (target != null)
                        {
                            target.TeleportTo(map, closest.Position);
                        }
                    }
                }
                else
                {
                    if (entry != null)
                    {
                        // spawn a new GO
                        var go = entry.Spawn(trigger.Args.Target, trigger.Args.Target);
                        trigger.Reply("Successfully spawned new GO: {0}.", go.Name);
                    }
                    else
                    {
                        trigger.Reply("Invalid GO.");
                    }
                }
            }
Ejemplo n.º 2
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                string  str    = trigger.Text.NextModifiers();
                GOEntry entry  = GOMgr.GetEntry(trigger.Text.NextEnum(GOEntryId.End), false);
                Unit    target = trigger.Args.Target;
                Map     map    = target != null ? target.Map : World.Kalimdor;

                if (str == "c")
                {
                    GOSpawnEntry goSpawnEntry;
                    if (entry != null)
                    {
                        goSpawnEntry = entry.SpawnEntries.GetClosestEntry(target);
                    }
                    else
                    {
                        List <GOSpawnPoolTemplate> poolTemplatesByMap = GOMgr.GetSpawnPoolTemplatesByMap(map.Id);
                        goSpawnEntry = poolTemplatesByMap == null
              ? null
              : poolTemplatesByMap.GetClosestEntry(target);
                    }

                    if (goSpawnEntry == null)
                    {
                        trigger.Reply("No valid SpawnEntries found (Entry: {0})", (object)entry);
                    }
                    else
                    {
                        goSpawnEntry.Spawn(map);
                        trigger.Reply("Spawned: " + goSpawnEntry.Entry);
                        if (target == null)
                        {
                            return;
                        }
                        target.TeleportTo(map, goSpawnEntry.Position);
                    }
                }
                else if (entry != null)
                {
                    GameObject gameObject = entry.Spawn(trigger.Args.Target, trigger.Args.Target);
                    trigger.Reply("Successfully spawned new GO: {0}.", (object)gameObject.Name);
                }
                else
                {
                    trigger.Reply("Invalid GO.");
                }
            }