示例#1
0
        static void DoSummon(Player p, string message)
        {
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to summon."); return;
            }
            string[] args        = message.SplitSpaces(2);
            string   spawnerName = args[0];
            bool     precise     = (args.Length > 1) ? args[1].CaselessEq("precise") : false;

            p.Message("precise is {0}", precise);

            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, spawnerName, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            if (spawner.EditableBy(p, "summon"))
            {
                float diffX = spawner.x - spawner.originX;
                float diffY = spawner.y - spawner.originY;
                float diffZ = spawner.z - spawner.originZ;

                if (precise)
                {
                    spawner.x = (float)(p.Pos.X) / 32f;
                    spawner.y = (float)(p.Pos.Y - Entities.CharacterHeight) / 32f;
                    spawner.z = (float)(p.Pos.Z) / 32f;
                }
                else
                {
                    spawner.x = p.Pos.BlockX;
                    spawner.y = p.Pos.FeetBlockCoords.Y;
                    spawner.z = p.Pos.BlockZ;
                    //center in block
                    spawner.x += 0.5f;
                    spawner.y += 0.5f;
                    spawner.z += 0.5f;
                }

                spawner.originX = spawner.x - diffX;
                spawner.originY = spawner.y - diffY;
                spawner.originZ = spawner.z - diffZ;
                if (precise)
                {
                    p.Message("Summoned spawner {0} to your precise feet position.", spawner.name);
                }
                else
                {
                    p.Message("Summoned spawner {0} to your block position.", spawner.name);
                }
                PluginGoodlyEffects.SpawnersFile.Save(p.level);
            }
        }