Example #1
0
 public ClientControl(TheClient client, ClientControlViewModel viewModel)
 {
     InitializeComponent();
     DataContext = _viewModel = viewModel;
     _client     = client;
     Initialize();
 }
Example #2
0
        static void Main(string[] args)
        {
            try
            {
                TheClient.Start();
                ////Address address = new Address("amqp://*****:*****@localhost:5672/");
                //Connection connection = new Connection(address);
                //Session session = new Session(connection);
                //ReceiverLink receiver = new ReceiverLink(session, "theExchange", "theQueue");

                //Console.WriteLine("Receiver connected to broker.");
                //Message message = receiver.Receive();
                //Console.WriteLine("Received " + message.GetBody<string>());
                //receiver.Accept(message);

                //receiver.Close();
                //session.Close();
                //connection.Close();
                Console.WriteLine("Listening...");
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
Example #3
0
        public override bool ParseBytesAndExecute(byte[] data)
        {
            if (data.Length < 4 + 4)
            {
                SysConsole.Output(OutputType.WARNING, "Invalid packet len: " + data.Length);
                return(false);
            }
            int spot = Utilities.BytesToInt(Utilities.BytesPartial(data, 0, 4));

            if (spot < 0 || spot > TheClient.Items.Count)
            {
                SysConsole.Output(OutputType.WARNING, "Bad spot:" + spot);
                return(false);
            }
            byte[] dat = Utilities.BytesPartial(data, 4, data.Length - 4);
            try
            {
                ItemStack item = new ItemStack(TheClient, dat);
                TheClient.Items.Insert(spot, item);
                TheClient.UpdateInventoryMenu();
                return(true);
            }
            catch (Exception ex)
            {
                SysConsole.Output("Spawning item", ex);
                return(false);
            }
        }
Example #4
0
        public override void Render()
        {
            if (!Visible)
            {
                return;
            }
            TheClient.SetEnts();
            BEPUutilities.RigidTransform rt = new BEPUutilities.RigidTransform(GetPosition().ToBVector(), GetOrientation());
            BEPUutilities.Vector3        bmin;
            BEPUutilities.Vector3        bmax;
            BEPUutilities.RigidTransform.Transform(ref ModelMin, ref rt, out bmin);
            BEPUutilities.RigidTransform.Transform(ref ModelMax, ref rt, out bmax);
            if (TheClient.MainWorldView.CFrust != null && !TheClient.MainWorldView.CFrust.ContainsBox(bmin, bmax))
            {
                return;
            }
            Matrix4d orient = GetOrientationMatrix();
            Matrix4d mat    = (Matrix4d.Scale(ClientUtilities.ConvertD(scale)) * orient * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition())));

            TheClient.MainWorldView.SetMatrix(2, mat);
            TheClient.Rendering.SetMinimumLight(0.0f);
            if (model.Meshes[0].vbo.Tex == null)
            {
                TheClient.Textures.White.Bind();
            }
            model.Draw(); // TODO: Animation?
        }
Example #5
0
 public override void Render()
 {
     if (!Visible || model.Meshes.Count == 0)
     {
         return;
     }
     TheClient.SetEnts();
     RigidTransform rt = new RigidTransform(Body.Position, Body.Orientation);
     BEPUutilities.Vector3 bmin;
     BEPUutilities.Vector3 bmax;
     RigidTransform.Transform(ref ModelMin, ref rt, out bmin);
     RigidTransform.Transform(ref ModelMax, ref rt, out bmax);
     if (TheClient.MainWorldView.CFrust != null && !TheClient.MainWorldView.CFrust.ContainsBox(bmin, bmax))
     {
         return;
     }
     Matrix4d orient = GetOrientationMatrix();
     Matrix4d mat = transform * (Matrix4d.Scale(ClientUtilities.ConvertD(scale)) * orient * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition())));
     TheClient.MainWorldView.SetMatrix(2, mat);
     TheClient.Rendering.SetMinimumLight(0.0f);
     if (model.Meshes[0].vbo.Tex == null)
     {
         TheClient.Textures.White.Bind();
     }
     if (TheClient.CVars.r_fast.ValueB || !TheClient.CVars.r_lighting.ValueB)
     {
         OpenTK.Vector4 sadj = TheRegion.GetSunAdjust();
         float skyl = TheRegion.GetSkyLightBase(GetPosition() + new Location(0, 0, ModelMax.Z));
         TheClient.Rendering.SetColor(new OpenTK.Vector4(sadj.X * skyl, sadj.Y * skyl, sadj.Z * skyl, 1.0f));
     }
     model.Draw(); // TODO: Animation(s)?
 }
Example #6
0
        public SingleplayerMenuScreen(Client tclient) : base(tclient)
        {
            ResetOnRender = false;
            AddChild(new UIButton("ui/menus/buttons/basic", "Back", TheClient.FontSets.SlightlyBigger, () => TheClient.ShowMainMenu(), UIAnchor.BOTTOM_LEFT, () => 350, () => 70, () => 10, () => - 100));
            int start = 150;
            IEnumerable <string> found    = Directory.EnumerateDirectories(Environment.CurrentDirectory);
            HashSet <string>     fullList = new HashSet <string>();

            foreach (string fnd in found)
            {
                string str = fnd.Substring(Environment.CurrentDirectory.Length).Replace('\\', '/').Replace("/", "");
                fullList.Add(str);
            }
            fullList.Add("server_default");
            fullList.Remove("server_menu");
            foreach (string fnd in fullList)
            {
                string str  = fnd;
                int    curr = start;
                if (str.StartsWith("server_"))
                {
                    str = str.Substring("server_".Length);
                    AddChild(new UIButton("ui/menus/buttons/sp", "== " + str + " ==", TheClient.FontSets.Standard, () =>
                    {
                        UIConsole.WriteLine("Opening singleplayer game: " + str);
                        TheClient.Network.Disconnect(TheClient.Network.ConnectionThread, TheClient.Network.ConnectionSocket, TheClient.Network.ChunkSocket);
                        if (TheClient.LocalServer != null)
                        {
                            UIConsole.WriteLine("Shutting down pre-existing server.");
                            TheClient.LocalServer.ShutDown();
                            TheClient.LocalServer = null;
                        }
                        TheClient.LocalServer = new Server(28010);
                        Server.Central        = TheClient.LocalServer;
                        TheClient.ShowLoading();
                        TheClient.Schedule.StartAsyncTask(() =>
                        {
                            try
                            {
                                TheClient.LocalServer.StartUp(str, () =>
                                {
                                    TheClient.Schedule.ScheduleSyncTask(() =>
                                    {
                                        TheClient.Network.Connect("localhost", "28010", false, str);
                                    }, 1.0);
                                });
                            }
                            catch (Exception ex)
                            {
                                Utilities.CheckException(ex);
                                SysConsole.Output("Running singleplayer game server", ex);
                            }
                        });
                    }, UIAnchor.TOP_LEFT, () => 600, () => 70, () => 10, () => curr));
                    start += 100;
                }
            }
            AddChild(new UILabel("^!^e^0  Voxalia\nSingleplayer", TheClient.FontSets.SlightlyBigger, UIAnchor.TOP_CENTER, () => 0, () => 0));
        }
Example #7
0
        public override void Render()
        {
            TheClient.SetVox();
            Matrix4d mat = Matrix4d.CreateTranslation(-ClientUtilities.ConvertD(Offset)) * GetTransformationMatrix();

            TheClient.MainWorldView.SetMatrix(2, mat);
            vbo.Render(false);
        }
Example #8
0
 public void RenderPlants()
 {
     if (TheClient.CVars.r_plants.ValueB)
     {
         TheClient.SetEnts();
         RenderGrass();
     }
 }
Example #9
0
        static async Task Main(string[] args)
        {
            TheClient client = new TheClient("[replace with namespace]", "[replace with connection name]", "[replace with key name]", "[replace with key]");

            await client.DoQueryForThings();

            Console.WriteLine(await client.PerformSignificantWork("hello world"));
            Console.ReadLine();
        }
Example #10
0
 public override void Render()
 {
     if (NeedsRender)
     {
         NeedsRender = false;
         if (Text != pText)
         {
             Destroy();
             pText = Text;
         }
         size = TheClient.FontSets.Standard.MeasureFancyLinesOfText(Text);
         if (GLTexture <= 0)
         {
             GLTexture = GL.GenTexture();
             GL.BindTexture(TextureTarget.Texture2D, GLTexture);
             GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)size.X + 2, (int)size.Y + 2, 0, OpenTK.Graphics.OpenGL4.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
             GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureCompareMode, (int)TextureCompareMode.CompareRefToTexture);
             GLFBO = GL.GenFramebuffer();
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, GLFBO);
             GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, GLTexture, 0);
             GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
         }
         GL.BindFramebuffer(FramebufferTarget.Framebuffer, GLFBO);
         if (!TheClient.MainWorldView.BufferDontTouch)
         {
             GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
         }
         GL.Disable(EnableCap.DepthTest);
         GL.Disable(EnableCap.CullFace);
         GL.Viewport(0, 0, (int)size.X, (int)size.Y);
         GL.ClearBuffer(ClearBuffer.Color, 0, new float[] { BackColor.X, BackColor.Y, BackColor.Z, BackColor.W });
         TheClient.Ortho = Matrix4.CreateOrthographicOffCenter(0, (float)size.X, (float)size.Y, 0, -1, 1);
         TheClient.FontSets.Standard.DrawColoredText("^0" + Text, new Location(1, 1, 0), int.MaxValue, 1, true, "^r^0");
         GL.BindFramebuffer(FramebufferTarget.Framebuffer, TheClient.MainWorldView.cFBO);
         TheClient.MainWorldView.SetViewPort();
         GL.Enable(EnableCap.DepthTest);
         GL.Enable(EnableCap.CullFace);
         if (!TheClient.MainWorldView.BufferDontTouch)
         {
             GL.DrawBuffer(TheClient.MainWorldView.BufferMode);
         }
     }
     NeedsRender     = true; // TEMP.
     TheClient.isVox = true;
     TheClient.SetEnts();
     GL.BindTexture(TextureTarget.Texture2D, GLTexture);
     GL.Disable(EnableCap.CullFace);
     TheClient.Rendering.RenderBillboard(Position, Scale * new Location(size.X * -0.01, size.Y * 0.01, 1f), TheClient.MainWorldView.CameraPos, TheClient.MainWorldView, (float)Math.PI * 0.5f);
     GL.Enable(EnableCap.CullFace);
 }
Example #11
0
        public override bool ParseBytesAndExecute(byte[] data)
        {
            if (data.Length < 1)
            {
                return(false);
            }
            TextChannel tc = (TextChannel)data[0];

            TheClient.WriteMessage(tc, FileHandler.encoding.GetString(data, 1, data.Length - 1));
            return(true);
        }
Example #12
0
        public override void Render()
        {
            TheClient.SetEnts();
            TheClient.Textures.White.Bind();
            Matrix4d mat = Matrix4d.Scale(0.05f, 0.2f, 0.05f) * GetTransformationMatrix();

            TheClient.MainWorldView.SetMatrix(2, mat);
            TheClient.Rendering.SetColor(GColor);
            model.Draw();
            TheClient.Rendering.SetColor(Color4.White);
        }
 public override void Render()
 {
     TheClient.SetEnts();
     if (TheClient.RenderTextures)
     {
         TheClient.Textures.White.Bind();
     }
     if (model != null)
     {
         TheClient.Rendering.SetMinimumLight(0f);
         BEPUutilities.Matrix matang = BEPUutilities.Matrix.CreateFromQuaternion(Angles);
         //matang.Transpose();
         Matrix4d matang4 = new Matrix4d(matang.M11, matang.M12, matang.M13, matang.M14,
                                         matang.M21, matang.M22, matang.M23, matang.M24,
                                         matang.M31, matang.M32, matang.M33, matang.M34,
                                         matang.M41, matang.M42, matang.M43, matang.M44);
         Matrix4d mat = matang4 * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition()));
         TheClient.MainWorldView.SetMatrix(2, mat);
         model.Draw(); // TODO: Animation?
         if (model.Name == "projectiles/arrow.dae")
         {
             float offs = 0.1f;
             BEPUutilities.Vector3 offz;
             BEPUutilities.Quaternion.TransformZ(offs, ref Angles, out offz);
             BEPUutilities.Vector3 offx;
             BEPUutilities.Quaternion.TransformX(offs, ref Angles, out offx);
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => ppos + new Location(offz),
                                                  (o) => Position + new Location(offz), (o) => 1f, 1f, Location.One,
                                                  Location.One, true, TheClient.Textures.GetTexture("common/smoke"), 0.5f);
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => ppos - new Location(offz),
                                                  (o) => Position - new Location(offz), (o) => 1f, 1f, Location.One,
                                                  Location.One, true, TheClient.Textures.GetTexture("common/smoke"), 0.5f);
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => ppos + new Location(offx),
                                                  (o) => Position + new Location(offx), (o) => 1f, 1f, Location.One,
                                                  Location.One, true, TheClient.Textures.GetTexture("common/smoke"), 0.5f);
             TheClient.Particles.Engine.AddEffect(ParticleEffectType.LINE, (o) => ppos - new Location(offx),
                                                  (o) => Position - new Location(offx), (o) => 1f, 1f, Location.One,
                                                  Location.One, true, TheClient.Textures.GetTexture("common/smoke"), 0.5f);
             ppos = Position;
         }
     }
     else
     {
         TheClient.Rendering.SetMinimumLight(1f);
         TheClient.Rendering.SetColor(Color4.DarkRed);
         TheClient.Rendering.RenderCylinder(GetPosition(), GetPosition() - Velocity / 20f, 0.01f);
         TheClient.Particles.Engine.AddEffect(ParticleEffectType.CYLINDER, (o) => ppos, (o) => Position, (o) => 0.01f, 2f,
                                              Location.One, Location.One, true, TheClient.Textures.GetTexture("white"));
         ppos = Position;
         TheClient.Rendering.SetColor(Color4.White);
     }
 }
Example #14
0
 public override void Render()
 {
     if (vbo == null)
     {
         return;
     }
     TheClient.SetVox();
     OpenTK.Matrix4d mat = OpenTK.Matrix4d.Scale(ClientUtilities.ConvertD(scale)) * OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(shapeOffs)) * GetTransformationMatrix();
     TheClient.MainWorldView.SetMatrix(2, mat);
     TheClient.Rendering.SetColor(Color, TheClient.MainWorldView);
     vbo.Render();
     TheClient.Rendering.SetColor(Color4.White, TheClient.MainWorldView);
 }
Example #15
0
 public void RenderGrass()
 {
     if (TheClient.MainWorldView.FBOid == FBOID.FORWARD_SOLID)
     {
         TheClient.Engine.Shaders3D.s_forw_grass = TheClient.Engine.Shaders3D.s_forw_grass.Bind();
         GL.Uniform1(6, (float)TheClient.GlobalTickTimeLocal);
         GL.Uniform4(12, new Vector4(ClientUtilities.Convert(TheClient.MainWorldView.FogCol), TheClient.MainWorldView.FogAlpha));
         float fogDist = 1.0f / TheClient.FogMaxDist();
         fogDist *= fogDist;
         GL.Uniform1(13, fogDist);
         //GL.Uniform2(14, new Vector2(TheClient.CVars.r_znear.ValueF, TheClient.ZFar()));
         GL.UniformMatrix4(1, false, ref TheClient.MainWorldView.PrimaryMatrix);
     }
     else if (TheClient.MainWorldView.FBOid == FBOID.MAIN)
     {
         TheClient.Engine.Shaders3D.s_fbo_grass = TheClient.Engine.Shaders3D.s_fbo_grass.Bind();
         GL.UniformMatrix4(1, false, ref TheClient.MainWorldView.PrimaryMatrix);
     }
     else if (TheClient.MainWorldView.FBOid == FBOID.SHADOWS && TheClient.MainWorldView.TranspShadows)
     {
         TheClient.Engine.Shaders3D.s_shadow_grass = TheClient.Engine.Shaders3D.s_shadow_grass.Bind();
     }
     else
     {
         return;
     }
     GL.ActiveTexture(TextureUnit.Texture3);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture2);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture1);
     GL.BindTexture(TextureTarget.Texture2DArray, 0);
     GL.ActiveTexture(TextureUnit.Texture0);
     GL.BindTexture(TextureTarget.Texture2DArray, TheClient.GrassTextureID);
     GL.Uniform1(6, (float)GlobalTickTimeLocal);
     GL.Uniform3(7, ClientUtilities.Convert(ActualWind));
     GL.Uniform1(8, TheClient.CVars.r_plantdistance.ValueF * TheClient.CVars.r_plantdistance.ValueF);
     TheClient.Rendering.SetColor(GetSunAdjust(), TheClient.MainWorldView);
     foreach (Chunk chunk in chToRender)
     {
         if (chunk.Plant_VAO != -1)
         {
             Matrix4d mat = Matrix4d.CreateTranslation(ClientUtilities.ConvertD(chunk.WorldPosition.ToLocation() * Chunk.CHUNK_SIZE));
             TheClient.MainWorldView.SetMatrix(2, mat);
             GL.BindVertexArray(chunk.Plant_VAO);
             GL.DrawElements(PrimitiveType.Points, chunk.Plant_C, DrawElementsType.UnsignedInt, IntPtr.Zero);
         }
     }
     TheClient.isVox = true;
     TheClient.SetEnts();
 }
Example #16
0
 public void RenderSimpler()
 {
     if (!Visible || model.Meshes.Count == 0)
     {
         return;
     }
     TheClient.SetEnts();
     Matrix4d mat = GetTransformationMatrix();
     TheClient.MainWorldView.SetMatrix(2, mat);
     if (model.Meshes[0].vbo.Tex == null)
     {
         TheClient.Textures.White.Bind();
     }
     model.Draw(); // TODO: Animation?
 }
Example #17
0
        public override bool ParseBytesAndExecute(byte[] data)
        {
            if (data.Length < 1)
            {
                return(false);
            }
            TextChannel tc = (TextChannel)data[0];

            if (tc <= TextChannel.ALWAYS || tc >= TextChannel.COUNT)
            {
                SysConsole.Output(OutputType.WARNING, "Invalid TEXTCHANEL specified: " + tc);
                return(false);
            }
            TheClient.WriteMessage(tc, FileHandler.encoding.GetString(data, 1, data.Length - 1));
            return(true);
        }
Example #18
0
        /// <summary>
        /// General entity render.
        /// </summary>
        public override void Render()
        {
            if (!Visible || model.Meshes.Count == 0)
            {
                return;
            }
            TheClient.SetEnts();
            RigidTransform rt = new RigidTransform(Body.Position, Body.Orientation);

            RigidTransform.Transform(ref ModelMin, ref rt, out BEPUutilities.Vector3 bmin);
            RigidTransform.Transform(ref ModelMax, ref rt, out BEPUutilities.Vector3 bmax);
            if (TheClient.MainWorldView.CFrust != null && !TheClient.MainWorldView.CFrust.ContainsBox(new Location(bmin), new Location(bmax)))
            {
                return;
            }
            double maxr   = TheClient.CVars.r_modeldistance.ValueF;
            double distsq = GetPosition().DistanceSquared(TheClient.MainWorldView.RenderRelative);

            if (GenBlockShadows && distsq > maxr * maxr) // TODO: LOD-able option?
            {
                // TODO: Rotation?
                model.DrawLOD(GetPosition() + ClientUtilities.ConvertD(transform.ExtractTranslation()), TheClient.MainWorldView);
                return;
            }
            Matrix4d orient = GetOrientationMatrix();
            Matrix4d mat    = (Matrix4d.Scale(ClientUtilities.ConvertD(scale)) * transform
                               * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(new Location(Body.CollisionInformation.LocalPosition)))
                               * orient * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition())));

            TheClient.MainWorldView.SetMatrix(2, mat);
            if (!TheClient.MainWorldView.RenderingShadows)
            {
                TheClient.Rendering.SetMinimumLight(0.0f, TheClient.MainWorldView);
            }
            if (model.Meshes[0].vbo.Tex == null)
            {
                TheClient.Textures.White.Bind();
            }
            if (!TheClient.MainWorldView.RenderingShadows && ((TheClient.CVars.r_fast.ValueB && !TheClient.CVars.r_forward_lights.ValueB) || !TheClient.CVars.r_lighting.ValueB))
            {
                OpenTK.Vector4 sadj = TheRegion.GetSunAdjust();
                float          skyl = TheRegion.GetSkyLightBase(GetPosition() + new Location(0, 0, ModelMax.Z));
                TheClient.Rendering.SetColor(new OpenTK.Vector4(sadj.X * skyl, sadj.Y * skyl, sadj.Z * skyl, 1.0f), TheClient.MainWorldView);
            }
            model.Draw(); // TODO: Animation(s)?
        }
Example #19
0
        public override void Render()
        {
            TheClient.SetEnts();
            TheClient.Rendering.SetColor(TheClient.Rendering.AdaptColor(ClientUtilities.Convert(GetPosition()), color));
            TheClient.Rendering.SetMinimumLight(0.0f);
            // TODO: Prevent model flipping (Possibly related to animation?)
            Matrix4d mat = PreRot * Matrix4d.CreateRotationZ((Direction.Yaw * Utilities.PI180)) * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition()));

            TheClient.MainWorldView.SetMatrix(2, mat);
            model.CustomAnimationAdjustments = new Dictionary <string, Matrix4>(SavedAdjustmentsOTK);
            model.Draw(aHTime, hAnim, aTTime, tAnim, aLTime, lAnim);
            TheClient.Rendering.SetColor(Color4.White);
            // TODO: Render held item!
            if (IsTyping)
            {
                TheClient.Textures.GetTexture("ui/game/typing").Bind(); // TODO: store!
                TheClient.Rendering.RenderBillboard(GetPosition() + new Location(0, 0, 4), new Location(2), TheClient.MainWorldView.CameraPos);
            }
        }
 public override void Render()
 {
     TheClient.SetEnts();
     TheClient.Rendering.SetColor(TheClient.Rendering.AdaptColor(ClientUtilities.Convert(GetPosition()), color));
     TheClient.Rendering.SetMinimumLight(0.0f);
     ActualModelRender();
     if (ShouldShine)
     {
         TheClient.Rendering.EnableShine(false);
         TheClient.Rendering.SetColor(new Vector4(ShineColor.X, ShineColor.Y, ShineColor.Z, ShineColor.W * 0.25f));
         ActualModelRender();
         TheClient.Rendering.DisableShine();
     }
     TheClient.Rendering.SetColor(Color4.White);
     if (IsTyping)
     {
         TheClient.Textures.GetTexture("ui/game/typing").Bind(); // TODO: store!
         TheClient.Rendering.RenderBillboard(GetPosition() + new Location(0, 0, 4), new Location(2), TheClient.MainWorldView.CameraPos);
     }
 }
Example #21
0
        private static async Task Main()
        {
            try
            {
                const string ipAddress = "40.76.93.179";
                //const string ipAddress = "127.0.0.1";
                const int port = 500;

                var client = new TheClient(ipAddress, port);
                await client.Connect();

                Console.WriteLine("done....");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.ReadKey();
            }
        }
Example #22
0
        public void AddGame(string name)
        {
            int ypos = CurrentY;

            CurrentY += 100;
            AddChild(new UIButton("ui/menus/buttons/sp", "== " + name + " ==", TheClient.FontSets.Standard, () =>
            {
                UIConsole.WriteLine("Opening singleplayer game: " + name);
                TheClient.Network.Disconnect();
                if (TheClient.LocalServer != null)
                {
                    UIConsole.WriteLine("Shutting down pre-existing server.");
                    TheClient.LocalServer.ShutDown();
                    TheClient.LocalServer = null;
                }
                TheClient.LocalServer = new Server(28010);
                Server.Central        = TheClient.LocalServer;
                TheClient.ShowLoading();
                TheClient.Schedule.StartAsyncTask(() =>
                {
                    try
                    {
                        TheClient.LocalServer.StartUp(name, () =>
                        {
                            TheClient.Schedule.ScheduleSyncTask(() =>
                            {
                                TheClient.Network.Connect("localhost", "28010", false, name);
                            }, 1.0);
                        });
                    }
                    catch (Exception ex)
                    {
                        Utilities.CheckException(ex);
                        SysConsole.Output("Running singleplayer game server", ex);
                    }
                });
            }, new UIPositionHelper(Client.MainUI).Anchor(UIAnchor.TOP_LEFT).ConstantXY(10, ypos).ConstantWidthHeight(600, 70)));
        }
Example #23
0
        public override void Render()
        {
            if (model == null)
            {
                return;
            }
            TheClient.SetEnts();
            if (TheClient.RenderTextures)
            {
                TheClient.Textures.White.Bind();
            }
            TheClient.Rendering.SetMinimumLight(0f);
            BEPUutilities.Matrix matang = BEPUutilities.Matrix.CreateFromQuaternion(Angles);
            //matang.Transpose();
            Matrix4d matang4 = new Matrix4d(matang.M11, matang.M12, matang.M13, matang.M14,
                                            matang.M21, matang.M22, matang.M23, matang.M24,
                                            matang.M31, matang.M32, matang.M33, matang.M34,
                                            matang.M41, matang.M42, matang.M43, matang.M44);
            Matrix4d mat = matang4 * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(GetPosition()));

            TheClient.MainWorldView.SetMatrix(2, mat);
            model.Draw(); // TODO: Animation?
        }
Example #24
0
        public void SetMoveSpeed(CharacterController cc, UserInputSet uis)
        {
            float speedmod = (float)new Vector2(uis.XMove, uis.YMove).Length() * 2;

            speedmod *= (1f + uis.SprintOrWalk * 0.5f);
            if (Click)
            {
                ItemStack  item = TheClient.GetItemForSlot(TheClient.QuickBarPos);
                bool       has  = item.SharedAttributes.ContainsKey("charge");
                BooleanTag bt   = has ? BooleanTag.TryFor(item.SharedAttributes["charge"]) : null;
                if (bt != null && bt.Internal && item.SharedAttributes.ContainsKey("cspeedm"))
                {
                    NumberTag nt = NumberTag.TryFor(item.SharedAttributes["cspeedm"]);
                    if (nt != null)
                    {
                        speedmod *= (float)nt.Internal;
                    }
                }
            }
            RigidTransform transf = new RigidTransform(Vector3.Zero, Body.Orientation);
            BoundingBox    box;

            cc.Body.CollisionInformation.Shape.GetBoundingBox(ref transf, out box);
            Location pos = new Location(cc.Body.Position) + new Location(0, 0, box.Min.Z);
            Material mat = TheRegion.GetBlockMaterial(pos + new Location(0, 0, -0.05f));

            speedmod         *= (float)mat.GetSpeedMod();
            cc.StandingSpeed  = CBStandSpeed * speedmod;
            cc.CrouchingSpeed = CBCrouchSpeed * speedmod;
            float frictionmod = 1f;

            frictionmod     *= (float)mat.GetFrictionMod();
            cc.SlidingForce  = CBSlideForce * frictionmod * Mass;
            cc.AirForce      = CBAirForce * frictionmod * Mass;
            cc.TractionForce = CBTractionForce * frictionmod * Mass;
            cc.VerticalMotionConstraint.MaximumGlueForce = CBGlueForce * Mass;
        }
Example #25
0
        // TODO: Merge with base.Render() as much as possible!
        public override void Render()
        {
            View3D.CheckError("Render - Player - Pre");
            Location renderrelpos = GetWeldSpot();

            if (TheClient.IsMainMenu || !TheClient.CVars.r_drawself.ValueB)
            {
                return;
            }
            TheClient.SetEnts();
            if (TheClient.CVars.n_debugmovement.ValueB)
            {
                if (ServerLocation.IsInfinite() || ServerLocation.IsNaN() || renderrelpos.IsInfinite() || renderrelpos.IsNaN())
                {
                    SysConsole.Output(OutputType.WARNING, "NaN server data");
                }
                else
                {
                    TheClient.Rendering.RenderLine(ServerLocation, renderrelpos);
                    View3D.CheckError("Render - Player - Line");
                    TheClient.Rendering.RenderLineBox(ServerLocation + new Location(-0.2), ServerLocation + new Location(0.2));
                    if (View3D.CheckError("Render - Player - LineBox"))
                    {
                        SysConsole.Output(OutputType.DEBUG, "Caught: " + (ServerLocation + new Location(-0.2)) + "::: " + (ServerLocation + new Location(0.2)));
                    }
                }
            }
            if (TheClient.VR != null)
            {
                return;
            }
            View3D.CheckError("Render - Player - 0");
            OpenTK.Matrix4d mat = OpenTK.Matrix4d.Scale(1.5f)
                                  * OpenTK.Matrix4d.CreateRotationZ((Direction.Yaw * Utilities.PI180))
                                  * PlayerAngleMat
                                  * OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
            TheClient.MainWorldView.SetMatrix(2, mat);
            TheClient.Rendering.SetMinimumLight(0.0f);
            model.CustomAnimationAdjustments = new Dictionary <string, OpenTK.Matrix4>(SavedAdjustmentsOTK)
            {
                // TODO: safe (no-collision) rotation check?
                { "spine04", GetAdjustmentOTK("spine04") * OpenTK.Matrix4.CreateRotationX(-(float)(Direction.Pitch / 2f * Utilities.PI180)) }
            };
            View3D.CheckError("Render - Player - 1");
            if (!TheClient.MainWorldView.RenderingShadows && TheClient.CVars.g_firstperson.ValueB)
            {
                model.CustomAnimationAdjustments["neck01"] = GetAdjustmentOTK("neck01") * OpenTK.Matrix4.CreateRotationX(-(float)(160f * Utilities.PI180));
            }
            else
            {
                model.CustomAnimationAdjustments["neck01"] = GetAdjustmentOTK("neck01");
            }
            model.Draw(aHTime, hAnim, aTTime, tAnim, aLTime, lAnim);
            Model mod   = TheClient.GetItemForSlot(TheClient.QuickBarPos).Mod;
            bool  hasjp = HasJetpack();

            View3D.CheckError("Render - Player - 2");
            if (!hasjp && tAnim != null && mod != null)
            {
                mat = OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
                TheClient.MainWorldView.SetMatrix(2, mat);
                Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>(SavedAdjustments);
                // TODO: Logic of this rotation math?
                Matrix rotforw = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, ((float)(Direction.Pitch / 2f * Utilities.PI180) % 360f)));
                adjs["spine04"] = GetAdjustment("spine04") * rotforw;
                SingleAnimationNode hand = tAnim.GetNode("metacarpal2.r");
                Matrix m4 = Matrix.CreateScale(1.5f, 1.5f, 1.5f)
                            * (Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-Direction.Yaw + 90) * Utilities.PI180) % 360f))
                               * hand.GetBoneTotalMatrix(aTTime, adjs))
                            * Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-90) * Utilities.PI180) % 360f));
                OpenTK.Matrix4 bonemat = new OpenTK.Matrix4((float)m4.M11, (float)m4.M12, (float)m4.M13, (float)m4.M14,
                                                            (float)m4.M21, (float)m4.M22, (float)m4.M23, (float)m4.M24,
                                                            (float)m4.M31, (float)m4.M32, (float)m4.M33, (float)m4.M34,
                                                            (float)m4.M41, (float)m4.M42, (float)m4.M43, (float)m4.M44);
                GL.UniformMatrix4(100, false, ref bonemat);
                mod.LoadSkin(TheClient.Textures);
                mod.Draw();
                bonemat = OpenTK.Matrix4.Identity;
                GL.UniformMatrix4(100, false, ref bonemat);
            }
            View3D.CheckError("Render - Player - 3");
            if (hasjp)
            {
                // TODO: Abstractify!
                Model jetp = GetHeldItem().Mod;
                mat = OpenTK.Matrix4d.CreateTranslation(ClientUtilities.ConvertD(renderrelpos));
                TheClient.MainWorldView.SetMatrix(2, mat);
                Dictionary <string, Matrix> adjs = new Dictionary <string, Matrix>();
                Matrix rotforw = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, ((float)(Direction.Pitch / 2f * Utilities.PI180) % 360f)));
                adjs["spine04"] = GetAdjustment("spine04") * rotforw;
                SingleAnimationNode spine = tAnim.GetNode("spine04");
                Matrix m4 = Matrix.CreateScale(1.5f, 1.5f, 1.5f)
                            * (Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)((-Direction.Yaw + 90) * Utilities.PI180) % 360f))
                               * spine.GetBoneTotalMatrix(aTTime, adjs))
                            * Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)((90) * Utilities.PI180) % 360f));
                OpenTK.Matrix4 bonemat = new OpenTK.Matrix4((float)m4.M11, (float)m4.M12, (float)m4.M13, (float)m4.M14, (float)m4.M21, (float)m4.M22, (float)m4.M23, (float)m4.M24,
                                                            (float)m4.M31, (float)m4.M32, (float)m4.M33, (float)m4.M34, (float)m4.M41, (float)m4.M42, (float)m4.M43, (float)m4.M44);
                GL.UniformMatrix4(100, false, ref bonemat);
                jetp.LoadSkin(TheClient.Textures);
                jetp.Draw();
                bonemat = OpenTK.Matrix4.Identity;
                GL.UniformMatrix4(100, false, ref bonemat);
            }
            View3D.CheckError("Render - Player - 4");
            if (IsTyping)
            {
                TheClient.Textures.GetTexture("ui/game/typing").Bind(); // TODO: store!
                TheClient.Rendering.RenderBillboard(renderrelpos + new Location(0, 0, 4), new Location(2), TheClient.MainWorldView.CameraPos);
            }
            View3D.CheckError("Render - Player - Post");
        }
Example #26
0
 /// <summary>
 /// Closes the connection.
 /// </summary>
 public void CloseConnection()
 {
     TheClient.Close();
 }
Example #27
0
 public override void FullRender(double delta, int xoff, int yoff)
 {
     base.FullRender(delta, xoff, yoff);
     TheClient.RenderLoader(TheClient.Window.Width - 100f, 100f, 100f, delta);
 }
        public SingleplayerMenuScreen(Client tclient) : base(tclient)
        {
            AddChild(new UIButton("ui/menus/buttons/basic", "Back", TheClient.FontSets.SlightlyBigger, () => TheClient.ShowMainMenu(), UIAnchor.BOTTOM_LEFT, () => 350, () => 70, () => 10, () => - 100));
            int           start = 150;
            List <string> found = TheClient.Files.ListFolders("saves");

            foreach (string str in found)
            {
                if (str.LastIndexOf('/') == "/saves/".Length - 1)
                {
                    AddChild(new UIButton("ui/menus/buttons/sp", "== " + str.Substring("/saves/".Length) + " ==", TheClient.FontSets.Standard, () => UIConsole.WriteLine("OPEN " + str), UIAnchor.TOP_LEFT, () => 600, () => 70, () => 10, () => start));
                    start += 100;
                }
            }
            AddChild(new UILabel("^!^e^0  Voxalia\nSingleplayer", TheClient.FontSets.SlightlyBigger, UIAnchor.TOP_CENTER, () => 0, () => 0));
        }
Example #29
0
 public override void Render(ViewUI2D view, double delta)
 {
     base.Render(view, delta);
     TheClient.RenderLoader(TheClient.Window.Width - 100f, 100f, 100f, delta);
 }
Example #30
0
 public override ItemStack GetHeldItem()
 {
     return(TheClient.GetItemForSlot(TheClient.QuickBarPos));
 }