示例#1
0
        internal static object Call(string call_type, params object[] args)
        {
            WormholeLink link;
            Color        color;

            switch (call_type)
            {
            case "GetModSettings":
                return(WormholesAPI.GetModSettings());

            case "WormholesFinishedSpawning":
                return(WormholesAPI.WormholesFinishedSpawning);

            case "GetWormholeCount":
                return(WormholesAPI.GetWormholeCount());

            case "GetWormholes":
                return(WormholesAPI.GetWormholes());

            case "RandomizeWormhole":
                if (args.Length == 0 || !(args[1] is WormholeLink))
                {
                    throw new ArgumentException("Invalid argument for " + call_type + "; must be a WormholeLink");
                }

                link = (WormholeLink)args[1];

                WormholesAPI.RandomizeWormhole(link);
                return(null);

            case "AddWormhole":
                if (args.Length == 0 || !(args[1] is WormholeLink))
                {
                    throw new ArgumentException("Invalid argument for " + call_type + "; must be a Color");
                }

                color = (Color)args[1];

                WormholesAPI.AddWormhole(color);
                return(null);

            case "RemoveWormhole":
                if (args.Length == 0 || !(args[1] is WormholeLink))
                {
                    throw new ArgumentException("Invalid argument for " + call_type + "; must be a WormholeLink");
                }

                link = (WormholeLink)args[1];

                WormholesAPI.RemoveWormhole(link);
                return(null);
            }

            throw new Exception("No such api call " + call_type);
        }
        ////////////////

        public override object Call(params object[] args)
        {
            if (args.Length == 0)
            {
                throw new Exception("Undefined call type.");
            }

            string call_type = args[0] as string;

            if (args == null)
            {
                throw new Exception("Invalid call type.");
            }

            var new_args = new object[args.Length - 1];

            Array.Copy(args, 1, new_args, 0, args.Length - 1);

            return(WormholesAPI.Call(call_type, new_args));
        }