コード例 #1
0
        public void Func()
        {
            var bindings = new Bindings();

            bindings.Bind("a0", () => { return(true); });
            var a0 = bindings.CallBinding("a0");

            Assert.IsTrue((bool)a0);

            bindings.Bind("a1", (int p1) => { return(p1); });
            var a1 = bindings.CallBinding("a1", 1);

            Assert.AreEqual(1, a1);

            bindings.Bind("a2", (int p1, int p2) => { return(p1 + p2); });
            var a2 = bindings.CallBinding("a2", 1, 2);

            Assert.AreEqual(3, a2);

            bindings.Bind("a3", (int p1, int p2, int p3) => {
                return(p1 + p2 + p3);
            });
            var a3 = bindings.CallBinding("a3", 1, 2, 3);

            Assert.AreEqual(6, a3);

            bindings.Bind("a4", (int p1, int p2, int p3, int p4) => {
                return(p1 + p2 + p3 + p4);
            });
            var a4 = bindings.CallBinding("a4", 1, 2, 3, 5);

            Assert.AreEqual(11, a4);
        }
コード例 #2
0
        public void BindAgain()
        {
            var bindings = new Bindings();

            bindings.Bind("foo", () => { return(true); });

            Assert.Throws <InvalidOperationException>(
                () => bindings.Bind("foo", () => { return(false); })
                );
        }
コード例 #3
0
        private void Run()
        {
            // Make bindings and bind options
            Bindings  binds = new Bindings();
            SmartMenu menu  = new SmartMenu(binds);

            menu.lang = "en";
            binds.Bind("this", This);
            binds.Bind("that", That);
            binds.Bind("something", Something);
            binds.Bind("another", Another);
            binds.Bind("lang", changeLang);

            menu.LoadMenu("MenuSpec.txt");
            menu.Activate();

            void changeLang()
            {
                if (menu.lang == "en")
                {
                    Console.Write("Danish or English? (EN for English and DA for Danish): ");
                }
                else
                {
                    Console.Write("Dansk eller Engelsk ? (EN for Engelsk and DA for Dansk): ");
                }

                string answer = Console.ReadLine();

                if (answer.ToLower().Trim() == "en")
                {
                    menu.LoadMenu("MenuSpec.txt");
                    menu.lang = "en";
                }
                else if (answer.ToLower().Trim() == "da")
                {
                    menu.LoadMenu("DAMenuSpec.txt");
                    menu.lang = "da";
                }
            }

            void Something()
            {
                if (menu.lang == "en")
                {
                    Console.WriteLine("What do you want to do?");
                }
                else
                {
                    Console.WriteLine("Hvad vil du gøre?");
                }

                Console.WriteLine(Functions.DoSomething(Console.ReadLine()));
            }
        }
コード例 #4
0
    public static void SetupDefaults()
    {
        API.FpsMax(200);
        API.ChunkRenderDistance(10);

        Bindings.Bind("W", "Game.PossessedPlayer.ForwardMove");
        Bindings.Bind("LeftStickUp", "Game.PossessedPlayer.ForwardMove");
        Bindings.Bind("S", "Game.PossessedPlayer.BackwardMove");
        Bindings.Bind("LeftStickDown", "Game.PossessedPlayer.BackwardMove");
        Bindings.Bind("D", "Game.PossessedPlayer.RightMove");
        Bindings.Bind("LeftStickRight", "Game.PossessedPlayer.RightMove");
        Bindings.Bind("A", "Game.PossessedPlayer.LeftMove");
        Bindings.Bind("LeftStickLeft", "Game.PossessedPlayer.LeftMove");
        Bindings.Bind("Shift", "Game.PossessedPlayer.Sprint");
        Bindings.Bind("LeftStickClick", "Game.PossessedPlayer.Sprint");
        Bindings.Bind("Space", "Game.PossessedPlayer.Jump");
        Bindings.Bind("XboxA", "Game.PossessedPlayer.Jump");
        Bindings.Bind("Control", "Game.PossessedPlayer.Crouch");
        Bindings.Bind("XboxB", "Game.PossessedPlayer.Crouch");

        Bindings.Bind("WheelUp", "Game.PossessedPlayer.InventoryUp");
        Bindings.Bind("XboxLB", "Game.PossessedPlayer.InventoryUp");
        Bindings.Bind("WheelDown", "Game.PossessedPlayer.InventoryDown");
        Bindings.Bind("XboxRB", "Game.PossessedPlayer.InventoryDown");

        Bindings.Bind("1", "Game.PossessedPlayer.InventorySlot0");
        Bindings.Bind("2", "Game.PossessedPlayer.InventorySlot1");
        Bindings.Bind("3", "Game.PossessedPlayer.InventorySlot2");
        Bindings.Bind("4", "Game.PossessedPlayer.InventorySlot3");
        Bindings.Bind("5", "Game.PossessedPlayer.InventorySlot4");
        Bindings.Bind("6", "Game.PossessedPlayer.InventorySlot5");
        Bindings.Bind("7", "Game.PossessedPlayer.InventorySlot6");
        Bindings.Bind("8", "Game.PossessedPlayer.InventorySlot7");
        Bindings.Bind("9", "Game.PossessedPlayer.InventorySlot8");
        Bindings.Bind("0", "Game.PossessedPlayer.InventorySlot9");

        Bindings.Bind("MouseUp", "Game.PossessedPlayer.LookUp");
        Bindings.Bind("RightStickUp", "Game.PossessedPlayer.LookUp");
        Bindings.Bind("MouseDown", "Game.PossessedPlayer.LookDown");
        Bindings.Bind("RightStickDown", "Game.PossessedPlayer.LookDown");
        Bindings.Bind("MouseRight", "Game.PossessedPlayer.LookRight");
        Bindings.Bind("RightStickRight", "Game.PossessedPlayer.LookRight");
        Bindings.Bind("MouseLeft", "Game.PossessedPlayer.LookLeft");
        Bindings.Bind("RightStickLeft", "Game.PossessedPlayer.LookLeft");

        Bindings.Bind("R", "Game.PossessedPlayer.BuildRotate");
        Bindings.Bind("XboxX", "Game.PossessedPlayer.BuildRotate");
        Bindings.Bind("Q", "Game.PossessedPlayer.ThrowCurrentItem");
        Bindings.Bind("RightStickClick", "Game.PossessedPlayer.ThrowCurrentItem");

        Bindings.Bind("K", "Game.PossessedPlayer.Respawn");
        Bindings.Bind("XboxSelect", "Game.PossessedPlayer.Respawn");
        Bindings.Bind("T", "Game.PossessedPlayer.ToggleFly");
        Bindings.Bind("XboxY", "Game.PossessedPlayer.ToggleFly");

        Bindings.Bind("MouseOne", "Game.PossessedPlayer.PrimaryFire");
        Bindings.Bind("XboxRT", "Game.PossessedPlayer.PrimaryFire");
        Bindings.Bind("MouseTwo", "Game.PossessedPlayer.SecondaryFire");
        Bindings.Bind("XboxLT", "Game.PossessedPlayer.SecondaryFire");
    }
コード例 #5
0
ファイル: QodenController.cs プロジェクト: tretikoff/Qoden.UI
 public override void ViewWillAppear(bool animated)
 {
     //TODO implement logging and return it
     //LOG.Info("View will appear");
     base.ViewWillAppear(animated);
     Bindings.Bind();
     Bindings.UpdateTarget();
 }
コード例 #6
0
 public void UpdateSource()
 {
     Bindings.Property(Model, x => x.Name)
     .To(Control.TextProperty())
     .UpdateSource((_, s) => Model.Name = _.Target.Value + " HAHA");
     Bindings.Bind();
     Control.Text = "Hello World";
     Assert.Equal(Model.Name, "Hello World HAHA");
 }
コード例 #7
0
        public void Action()
        {
            var bindings = new Bindings();

            bool a0 = false;

            bindings.Bind("a0", () => a0 = true);
            bindings.CallBinding("a0");
            Assert.IsTrue(a0);

            int a1 = 0;

            bindings.Bind("a1", (int p1) => a1 = p1);
            bindings.CallBinding("a1", 1);
            Assert.AreEqual(1, a1);

            int a2 = 0;

            bindings.Bind("a2", (int p1, int p2) => { a1 = p1; a2 = p2; });
            bindings.CallBinding("a2", 2, 3);
            Assert.AreEqual(2, a1);
            Assert.AreEqual(3, a2);

            int a3 = 0;

            bindings.Bind("a3", (int p1, int p2, int p3) => {
                a1 = p1; a2 = p2; a3 = p3;
            });
            bindings.CallBinding("a3", 3, 4, 5);
            Assert.AreEqual(3, a1);
            Assert.AreEqual(4, a2);
            Assert.AreEqual(5, a3);

            int a4 = 0;

            bindings.Bind("a4", (int p1, int p2, int p3, int p4) => {
                a1 = p1; a2 = p2; a3 = p3; a4 = p4;
            });
            bindings.CallBinding("a4", 4, 5, 6, 7);
            Assert.AreEqual(4, a1);
            Assert.AreEqual(5, a2);
            Assert.AreEqual(6, a3);
            Assert.AreEqual(7, a4);
        }
コード例 #8
0
        public void CallUnmappedBinding()
        {
            var bindings = new Bindings();

            bindings.Bind("foo", () => { return(true); });

            Assert.Throws <InvalidOperationException>(
                () => bindings.CallBinding("bar")
                );
        }
コード例 #9
0
 public void ControlTriggersCommand()
 {
     Bindings.Command(Model.LoadCommand)
     .To(Control.ButtonClickTrigger());
     Bindings.Bind();
     Control.TriggerClick();
     Assert.True(Model.LoadCommand.IsRunning);
     Model.LoadCommand.Task.Wait();
     Assert.Equal("Name From Server", Model.Name);
 }
コード例 #10
0
 public void UpdateTarget()
 {
     Bindings.Property(Model, x => x.Name)
     .UpdateTarget((_, s) => Control.Text = Control.Text + "1");
     Bindings.Bind();
     Bindings.UpdateTarget();
     Assert.Equal("1", Control.Text);
     Model.Name = "New Name";
     Assert.Equal("11", Control.Text);
 }
コード例 #11
0
 public override void ViewWillAppear(bool animated)
 {
     if (Logger != null && Logger.IsEnabled(LogLevel.Information))
     {
         Logger.LogInformation("View will appear");
     }
     base.ViewWillAppear(animated);
     Bindings.Bind();
     Bindings.UpdateTarget();
     ViewWillAppear();
 }
コード例 #12
0
 public void ConvertBackAndForth()
 {
     Bindings.Property(Model, x => x.Age)
     .Convert(x => x.ToString(), Int32.Parse)
     .To(Control.TextProperty());
     Bindings.Bind();
     Model.Age = 20;
     Assert.Equal("20", Control.Text);
     Control.Text = "25";
     Assert.Equal(25, Model.Age);
 }
コード例 #13
0
ファイル: OptionsMenu.cs プロジェクト: lordee/godotfps
    private void _on_Save_pressed()
    {
        Settings.Sensitivity   = float.Parse(_mSensitivity.Text);
        Settings.InvertedMouse = _mInvert.Pressed;

        foreach (LineEdit le in _playerControls)
        {
            Bindings.Bind(le.Name, le.Text);
        }

        Commands.SaveConfig();
    }
コード例 #14
0
        public void EvaluateReturnsVariableNodeBinding()
        {
            Variable           var        = new Variable("scooby");
            VariableExpression constraint = new VariableExpression(var);

            Bindings bindings = new Bindings();

            bindings.Bind(new Variable("scooby"), new Resource());
            bindings.BindNode(new Variable("scooby"), new UriRef("http://example.com/scooby"));

            Assert.AreEqual(new UriRef("http://example.com/scooby"), constraint.Evaluate(bindings));
        }
コード例 #15
0
        public void SatisfiedBy()
        {
            Bound expression1 = new Bound(new Variable("scooby"));
            Bound expression2 = new Bound(new Variable("velma"));

            Bindings bindings = new Bindings();

            bindings.Bind(new Variable("scooby"), new Resource());

            Assert.AreEqual(true, expression1.Evaluate(bindings), "expression1 should be satisfied by solution");
            Assert.AreEqual(false, expression2.Evaluate(bindings), "expression2 should not be satisfied by solution");
        }
コード例 #16
0
 public void Convert()
 {
     Bindings.Property(Model, x => x.Name)
     .Convert(x => x + " ABC")
     .To(Control.TextProperty());
     Bindings.Bind();
     Model.Name = "Hello";
     Assert.Equal("Hello ABC", Control.Text);
     //Since there is no back conversion specified binding became OneWay automatically.
     Control.Text = "Change";
     Assert.Equal("Hello", Model.Name);
 }
コード例 #17
0
ファイル: BindingsTest.cs プロジェクト: Titan512/spiralrdf
        public void EqualsComparesBindingVariableNames()
        {
            Bindings bindings1 = new Bindings();
            Bindings bindings2 = new Bindings();
            Bindings bindings3 = new Bindings();


            bindings1.Bind(new Variable("foo"), new UriRef("foo:foo"));
            bindings2.Bind(new Variable("foo"), new UriRef("foo:foo"));
            bindings3.Bind(new Variable("foo"), new UriRef("foo:bar"));

            Assert.IsTrue(bindings1.Equals(bindings2), "bindings1 should equal bindings2");
            Assert.IsTrue(!bindings1.Equals(bindings3), "bindings1 should not equal bindings3");
        }
コード例 #18
0
        public void WhenStartedAndFinished()
        {
            bool finished = false;
            bool started  = false;

            Bindings.Command(Model.LoadCommand)
            .WhenStarted(_ => started   = true)
            .WhenFinished(_ => finished = true);
            Bindings.Bind();
            Model.LoadCommand.Execute();
            Assert.True(started);
            Assert.False(finished);
            Model.LoadCommand.Task.Wait();
            Assert.True(finished);
        }
コード例 #19
0
        public void AfterSourceUpdate()
        {
            Bindings.Property(Model, x => x.Name).To(Control.TextProperty())
            .AfterSourceUpdate((binding, s) =>
            {
                Target = (IProperty <string>)binding.Target;
                Source = (IProperty <string>)binding.Source;
            });
            Bindings.Bind();

            Control.Text = "Hello World";

            Assert.NotNull(Target);
            Assert.NotNull(Source);
        }
コード例 #20
0
        public void Bind_Test1()
        {
            var c1 = new Counter();
            var c2 = new Counter();

            var d = Bindings.Bind(() => c1.Count, () => c2.Count);

            c1.Count = 5;

            Assert.AreEqual(c1.Count, c2.Count);

            c2.Count = 4;

            Assert.AreEqual(c1.Count, c2.Count);
        }
コード例 #21
0
        public void CompileFalseBoolInFunction()
        {
            var scope = new Scope();
            var binds = new Bindings();

            binds.Bind <object, object>("id", x => x);

            var nodes = Compiler.Compile("$ id(false)");

            Assert.AreEqual(1, nodes.Count);
            Assert.IsAssignableFrom <Statement>(nodes[0]);

            var exp = (nodes[0] as Statement).expression;

            Assert.AreEqual(false, exp.Evaluate(scope, binds).AsObject());
        }
コード例 #22
0
        public override void WillMoveToSuperview(UIView newsuper)
        {
            base.WillMoveToSuperview(newsuper);

            if (bindings != null)
            {
                if (newsuper != null)
                {
                    Bindings.Bind();
                    Bindings.UpdateTarget();
                }
                else
                {
                    Bindings.Unbind();
                }
            }
        }
コード例 #23
0
        public void CompileVariableKeywordInFunction()
        {
            var scope = new Scope();

            scope.SetVar("truest", 5);
            var binds = new Bindings();

            binds.Bind <object, object>("id", x => x);

            var nodes = Compiler.Compile("$ id(truest)");

            Assert.AreEqual(1, nodes.Count);
            Assert.IsAssignableFrom <Statement>(nodes[0]);

            var exp = (nodes[0] as Statement).expression;

            Assert.AreEqual(5, exp.Evaluate(scope, binds).AsObject());
        }
コード例 #24
0
        public void BeforeAndAfterExecute()
        {
            bool beforeExecute = true, afterExecute = false;

            Bindings.Command(Model.LoadCommand)
            .BeforeExecute(_ => beforeExecute = Model.LoadCommand.IsRunning)
            .AfterExecute(_ => afterExecute   = Model.LoadCommand.IsRunning)
            .To(Control.ButtonClickTrigger());
            Bindings.Bind();

            //Before and After execute does NOT execute when command launched from code.
            Model.LoadCommand.ExecuteAsync().Wait();
            Assert.True(beforeExecute);
            Assert.False(afterExecute);

            //Before and After execute are triggered when command initiated from UI.
            Control.TriggerClick();
            Assert.False(beforeExecute);
            Assert.True(afterExecute);
        }
コード例 #25
0
    public static void LoadDefaultConfig()
    {
        // kb move
        Bindings.Bind("move_forward", "W");
        Bindings.Bind("move_left", "A");
        Bindings.Bind("move_backward", "S");
        Bindings.Bind("move_right", "D");
        Bindings.Bind("jump", "Space");

        // mouse
        Bindings.Bind("attack", "MouseOne");
        Bindings.Bind("look_up", "MouseUp");
        Bindings.Bind("look_down", "MouseDown");
        Bindings.Bind("look_right", "MouseRight");
        Bindings.Bind("look_left", "MouseLeft");

        // other
        Bindings.Bind("mousemode_toggle", "M");
        Bindings.Bind("mainmenu_toggle", "Escape");
        Bindings.Bind("console_toggle", "`");
    }
コード例 #26
0
        public void Bind_Test2()
        {
            var c1 = new Counter();
            var c2 = new Counter();

            var d = Bindings.Bind(() => c1.Count, () => c2.Count);

            c1.Count = 5;

            Assert.AreEqual(c1.Count, c2.Count);

            c2.Count = 4;

            Assert.AreEqual(c1.Count, c2.Count);

            d.Dispose();

            c1.Count++; // 5

            Assert.AreEqual(c1.Count, c2.Count + 1);
        }
コード例 #27
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            if (NavigationController != null)
            {
                NavigationController.NavigationBarHidden = true;
            }

            Waiting.Color = UIColor.Yellow;

            Bindings.Bind(Waiting).For(x => x.Hidden).To(x => x.InFlight);
            Bindings.Apply();

            ViewModel.AuthenticateEvent += (object sender, SdkEventArgs e) => {
                if (!e.Successful)
                {
                    this.Alert("Error", "cannot contact server, please check your internet connection");
                }
            };

            Task.Delay(1000);
            ViewModel.AuthenticateCommand.Execute();
        }
コード例 #28
0
ファイル: API.cs プロジェクト: outrera/SkyOfSteel
    static List <object> GetDelCall(string Name)
    {
        switch (Name)
        {
        case "print":
            return(new List <object> {
                Name, new Action <string>(delegate(string ToPrint){ Console.Print(ToPrint); })
            });

        case "log":
            return(new List <object> {
                Name, new Action <string>(delegate(string ToLog){ Console.Log(ToLog); })
            });

        case "host":
            return(new List <object> {
                Name, new Action(delegate(){
                    Net.Host();
                })
            });

        case "connect":
            return(new List <object> {
                Name, new Action <string>(delegate(string Ip){
                    if (Ip == "" || Ip == "localhost" || Ip == "undefined")
                    {
                        Ip = "127.0.0.1";
                    }
                    Net.ConnectTo(Ip);
                })
            });

        case "disconnect":
            return(new List <object> {
                Name, new Action(delegate(){
                    Net.Disconnect();
                })
            });

        case "ms_get":
            return(new List <object> {
                Name, new Func <int>(() => { return OS.GetTicksMsec(); })
            });

        case "peerlist_get":
            return(new List <object> {
                Name, new Func <Jurassic.Library.ArrayInstance>(() => {
                    Jurassic.Library.ArrayInstance Out = Scripting.ConsoleEngine.Array.Construct();
                    foreach (int Id in Net.PeerList)
                    {
                        Out.Push(Id);
                    }
                    return Out;
                })
            });

        case "bind":
            return(new List <object> {
                Name, new Action <string, string>(delegate(string FunctionName, string InputString){
                    Bindings.Bind(FunctionName, InputString);
                })
            });

        case "unbind":
            return(new List <object> {
                Name, new Action <string>(delegate(string FunctionName){
                    Bindings.UnBind(FunctionName);
                })
            });

        case "player_input_forward_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.ForwardMove(Sens);
                })
            });

        case "player_input_forward_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.ForwardSens; })
            });

        case "player_input_backward_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.BackwardMove(Sens);
                })
            });

        case "player_input_backward_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.BackwardSens; })
            });

        case "player_input_right_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.RightMove(Sens);
                })
            });

        case "player_input_right_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.RightSens; })
            });

        case "player_input_left_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LeftMove(Sens);
                })
            });

        case "player_input_left_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.LeftSens; })
            });

        case "player_input_sprint_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.Sprint(Sens);
                })
            });

        case "player_input_sprint_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.IsSprinting ? 1d : 0d; })
            });

        case "player_input_jump_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.Jump(Sens);
                })
            });

        case "player_input_jump_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.IsJumping ? 1d : 0d; })
            });

        case "player_input_inventory_up":
            return(new List <object> {
                Name, new Action(delegate(){
                    Game.PossessedPlayer.InventoryUp();
                })
            });

        case "player_input_inventory_down":
            return(new List <object> {
                Name, new Action(delegate(){
                    Game.PossessedPlayer.InventoryDown();
                })
            });

        case "player_input_look_up":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookUp(Sens);
                })
            });

        case "player_input_look_down":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookDown(Sens);
                })
            });

        case "player_input_look_right":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookRight(Sens);
                })
            });

        case "player_input_look_left":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookLeft(Sens);
                })
            });

        case "player_input_build_rotate":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.BuildRotate(Sens);
                })
            });

        case "player_input_primary_fire":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.PrimaryFire(Sens);
                })
            });

        case "player_input_secondary_fire":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.SecondaryFire(Sens);
                })
            });

        case "gamemode_set":
            return(new List <object> {
                Name, new Action <string>(delegate(string GameModeName){
                    if (Game.Self.GetTree().GetNetworkPeer() != null && Game.Self.GetTree().GetNetworkUniqueId() == 1)
                    {
                        Scripting.LoadGameMode(GameModeName);
                    }
                    else
                    {
                        Console.Print("Error: Cannot set gamemode as client");
                    }
                })
            });

        case "gamemode_get":
            return(new List <object> {
                Name, new Func <string>(() => { return Scripting.GamemodeName; })
            });

        case "chunk_render_distance_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Distance){
                    if (Distance < 2d)
                    {
                        Console.Print("Cannot set render distance value lower than two chunks");
                        return;
                    }
                    Game.ChunkRenderDistance = (int)Distance;
                    Game.PossessedPlayer.UnloadAndRequestChunks();
                })
            });

        case "chunk_render_distance_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Convert.ToDouble(Game.ChunkRenderDistance); })
            });

        case "save":
            return(new List <object> {
                Name, new Action(delegate(){
                    Building.SaveWorld("TestSave");
                })
            });

        case "load":
            return(new List <object> {
                Name, new Action(delegate(){
                    Building.LoadWorld("TestSave");
                })
            });

        default:
            throw new System.ArgumentException("Invalid GetDelCall name arg '" + Name + "'");
        }
    }
コード例 #29
0
ファイル: API.cs プロジェクト: triptych/SkyOfSteel
    static List <object> GetDelCall(string Name)
    {
        switch (Name)
        {
        case "print":
            return(new List <object> {
                Name, new Action <string>(delegate(string ToPrint){ Console.Print(ToPrint); })
            });

        case "log":
            return(new List <object> {
                Name, new Action <string>(delegate(string ToLog){ Console.Log(ToLog); })
            });

        case "host":
            return(new List <object> {
                Name, new Action(delegate(){
                    Net.Host();
                })
            });

        case "connect":
            return(new List <object> {
                Name, new Action <string>(delegate(string Ip){
                    if (Ip == "" || Ip == "localhost" || Ip == "undefined")
                    {
                        Ip = "127.0.0.1";
                    }
                    Net.ConnectTo(Ip);
                })
            });

        case "ms_get":
            return(new List <object> {
                Name, new Func <int>(() => { return OS.GetTicksMsec(); })
            });

        case "peerlist_get":
            return(new List <object> {
                Name, new Func <Jurassic.Library.ArrayInstance>(() => {
                    Jurassic.Library.ArrayInstance Out = Scripting.ConsoleEngine.Array.Construct();
                    foreach (int Id in Net.PeerList)
                    {
                        Out.Push(Id);
                    }
                    return Out;
                })
            });

        case "bind":
            return(new List <object> {
                Name, new Action <string, string>(delegate(string FunctionName, string InputString){
                    Bindings.Bind(FunctionName, InputString);
                })
            });

        case "unbind":
            return(new List <object> {
                Name, new Action <string>(delegate(string FunctionName){
                    Bindings.UnBind(FunctionName);
                })
            });

        case "player_input_forward_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.ForwardMove(Sens);
                })
            });

        case "player_input_forward_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.ForwardSens; })
            });

        case "player_input_backward_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.BackwardMove(Sens);
                })
            });

        case "player_input_backward_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.BackwardSens; })
            });

        case "player_input_right_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.RightMove(Sens);
                })
            });

        case "player_input_right_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.RightSens; })
            });

        case "player_input_left_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LeftMove(Sens);
                })
            });

        case "player_input_left_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.LeftSens; })
            });

        case "player_input_sprint_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.Sprint(Sens);
                })
            });

        case "player_input_sprint_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.IsSprinting ? 1d : 0d; })
            });

        case "player_input_jump_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.Jump(Sens);
                })
            });

        case "player_input_jump_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.IsJumping ? 1d : 0d; })
            });

        case "player_input_inventory_up":
            return(new List <object> {
                Name, new Action(delegate(){
                    Game.PossessedPlayer.InventoryUp();
                })
            });

        case "player_input_inventory_down":
            return(new List <object> {
                Name, new Action(delegate(){
                    Game.PossessedPlayer.InventoryDown();
                })
            });

        case "player_input_look_up":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookUp(Sens);
                })
            });

        case "player_input_look_down":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookDown(Sens);
                })
            });

        case "player_input_look_right":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookRight(Sens);
                })
            });

        case "player_input_look_left":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookLeft(Sens);
                })
            });

        case "player_input_primary_fire":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.PrimaryFire(Sens);
                })
            });

        default:
            throw new System.ArgumentException("Invalid GetDelCall name arg '" + Name + "'");
        }
    }
コード例 #30
0
ファイル: API.cs プロジェクト: TdoubleAV/SkyOfSteel
 public static bool Bind(string InputString, string FunctionName)
 {
     return(Bindings.Bind(InputString, FunctionName));
 }