Example #1
0
		public void AddPlayer(string name, ModPlayer player)
		{
			Type itemClass = typeof(Item);
			Type intClass = typeof(int);
			if (player.GetType().GetMethod("CatchFish", new Type[] {
				itemClass, itemClass, intClass, intClass, intClass, intClass,
				intClass.MakeByRefType(), typeof(bool).MakeByRefType() }) != null)
			{
				throw new OldHookException("ModPlayer.CatchFish");
			}
			player.Name = name;
			players[name] = player;
			player.mod = this;
			PlayerHooks.Add(player);
		}
Example #2
0
        internal static void VerifyGlobalItem(ModPlayer player)
        {
            var type = player.GetType();

            int netCustomBiomeMethods = 0;

            if (HasMethod(type, "CustomBiomesMatch", typeof(Player)))
            {
                netCustomBiomeMethods++;
            }
            if (HasMethod(type, "CopyCustomBiomesTo", typeof(Player)))
            {
                netCustomBiomeMethods++;
            }
            if (HasMethod(type, "SendCustomBiomes", typeof(BinaryWriter)))
            {
                netCustomBiomeMethods++;
            }
            if (HasMethod(type, "ReceiveCustomBiomes", typeof(BinaryReader)))
            {
                netCustomBiomeMethods++;
            }
            if (netCustomBiomeMethods > 0 && netCustomBiomeMethods < 4)
            {
                throw new Exception(type + " must override all of (CustomBiomesMatch/CopyCustomBiomesTo/SendCustomBiomes/ReceiveCustomBiomes) or none");
            }

            int netClientMethods = 0;

            if (HasMethod(type, "clientClone", typeof(ModPlayer)))
            {
                netClientMethods++;
            }
            if (HasMethod(type, "SyncPlayer", typeof(int), typeof(int), typeof(bool)))
            {
                netClientMethods++;
            }
            if (HasMethod(type, "SendClientChanges", typeof(ModPlayer)))
            {
                netClientMethods++;
            }
            if (netClientMethods > 0 && netClientMethods < 3)
            {
                throw new Exception(type + " must override all of (clientClone/SyncPlayer/SendClientChanges) or none");
            }

            int saveMethods = 0;

            if (HasMethod(type, "Save"))
            {
                saveMethods++;
            }
            if (HasMethod(type, "Load", typeof(TagCompound)))
            {
                saveMethods++;
            }
            if (saveMethods == 1)
            {
                throw new Exception(type + " must override all of (Save/Load) or none");
            }

            int netMethods = 0;

            if (HasMethod(type, "NetSend", typeof(BinaryWriter)))
            {
                netMethods++;
            }
            if (HasMethod(type, "NetReceive", typeof(BinaryReader)))
            {
                netMethods++;
            }
            if (netMethods == 1)
            {
                throw new Exception(type + " must override both of (NetSend/NetReceive) or none");
            }
        }