Example #1
0
        private void DrawSide(BlockSide side, SideTile part, Vector3 offset, bool isLid)
        {
            if (part.Sprite > 0)
            {
                if (_isCol && (!part.Wall && !isLid))
                {
                    if (_block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_DOWNLEFT && _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_DOWNRIGHT &&
                        _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_UPLEFT && _block.SlopeType.Slope != MapGeometry.SLOPE_DIAGONAL_UPRIGHT)
                    {
                        return;
                    }
                }

                BlockSide modifiedSide = ModifySide(side, part);

                ushort sprite = part.Sprite;

                string   materialName = string.Format("gbh/bil/{0}", sprite);
                Material material     = MaterialManager.FindMaterial(materialName);

                var bank = GetBank(material.BaseName);
                bank.ReserveSpace(side.Vertices.Length, (side.Vertices.Length == 4) ? 6 : 4);

                int vertIndex = bank.numVertex;

                bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 0, offset, part, material);
                bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 1, offset, part, material);
                bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 2, offset, part, material);

                bank.indices[bank.numIndex++] = (short)(vertIndex + 0);
                bank.indices[bank.numIndex++] = (short)(vertIndex + 1);
                bank.indices[bank.numIndex++] = (short)(vertIndex + 2);

                if (side.Vertices.Length == 4)
                {
                    bank.vertices[bank.numVertex++] = GetVertex(modifiedSide, 3, offset, part, material);

                    bank.indices[bank.numIndex++] = (short)(vertIndex + 2);
                    bank.indices[bank.numIndex++] = (short)(vertIndex + 3);
                    bank.indices[bank.numIndex++] = (short)(vertIndex + 0);
                }
            }
        }
Example #2
0
        public static void RenderPass(GraphicsDevice device, Effect effect, Camera camera)
        {
            // set up the effect
            device.DepthStencilState = DepthStencilState.Default;
            device.RasterizerState   = _normalState;

            effect.Parameters["World"].SetValue(Matrix.Identity);

            foreach (var cell in CellManager.ActivatedCells)
            {
                if (camera.BoundingFrustum.Intersects(cell.Bounds))
                {
                    foreach (var bankStuff in cell.Banks)
                    {
                        //var image = ImageManager.FindImage(bankStuff.Key);
                        var material = MaterialManager.FindMaterial(bankStuff.Key);
                        var bank     = bankStuff.Value;

                        effect.Parameters["ColorMap"].SetValue(material.DiffuseImage.Texture);
                        effect.Techniques[0].Passes[0].Apply();

                        if (bank.vertexBuffer != null)
                        {
                            device.Indices = bank.indexBuffer;
                            device.SetVertexBuffer(bank.vertexBuffer);
                            device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, bank.vertices.Length, 0, bank.indices.Length / 3);
                        }
                        else
                        {
                            if (bank.vertices.Length >= 3)
                            {
                                device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, bank.vertices, 0, bank.vertices.Length, bank.indices, 0, bank.indices.Length / 3);
                            }
                        }
                    }
                }
            }
        }
Example #3
0
        public static void Initialize()
        {
            // set the current culture to the invariant culture
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // initialize the logging service
            Log.Initialize(LogLevel.All);
            Log.AddListener(new ConsoleLogListener());
            Log.AddListener(new GameLogListener());
            Log.AddListener(new FileLogListener("GBHGame.log", false));

            Log.Write(LogLevel.Info, "GBH2 v0 initializing");
            Log.Write(LogLevel.Critical, "jeremych is an egghead and a nabsalad");

            ConVar.Initialize();
            FileSystem.Initialize();
            Win32System.Initialize();
            MapGeometry.Initialize();
            //StyleManager.Load("Styles/bil.sty");
            //MapManager.Load("Maps/MP1-comp.gmp");
            Camera.Initialize();
            NetManager.Initialize(29960);
            Client.Initialize();
            Server.Initialize();

            GameWindow.Initialize();

            com_maxFPS      = ConVar.Register("com_maxFPS", 0, "Maximum framerate for the game loop.", ConVarFlags.Archived);
            timescale       = ConVar.Register("timescale", 1.0f, "Scale time by this amount", ConVarFlags.Cheat);
            sv_running      = ConVar.Register("sv_running", true, "Is the server running?", ConVarFlags.ReadOnly);
            cl_running      = ConVar.Register("cl_running", false, "Is the client running?", ConVarFlags.ReadOnly);
            sv_paused       = ConVar.Register("sv_paused", false, "Is the server paused?", ConVarFlags.ReadOnly);
            cl_paused       = ConVar.Register("cl_paused", false, "Is the client paused?", ConVarFlags.ReadOnly);
            net_showpackets = ConVar.Register("net_showpackets", false, "Show network packets.", ConVarFlags.None);
            mapname         = ConVar.Register("mapname", "", "Current mapname", ConVarFlags.ReadOnly);
            nickname        = ConVar.Register("nickname", Environment.GetEnvironmentVariable("username"), "Your nickname", ConVarFlags.Archived);

            Renderer.Initialize();
            MaterialManager.ReadMaterialFile("base.material");
            MaterialManager.ReadMaterialFile("Styles/bil.material");
            ConsoleRenderer.Initialize();
            //StyleManager.CreateTextures(Renderer.Device);
            MapRenderer.Initialize(Renderer.Device);
            DeferredRenderer.Initialize(Renderer.Device);
            Renderer2D.Initialize(Renderer.Device);

            // jeez, people these days just need to get a *proper* nickname
            if (ConVar.GetValue <string>("nicknamee") == Environment.GetEnvironmentVariable("username"))
            {
                Log.Write(LogLevel.Info, "It looks it's your first time running GBH2. Please type 'nickname <WANTED NICKNAME>' to set your nickname.");
            }

            var     path  = Directory.GetCurrentDirectory() + "\\config.ini";
            IniFile ini   = new IniFile(path);
            var     value = ini.IniReadValue("CONFIG", "nickname");

            if (value != null)
            {
                ConVar.SetValue <string>("nicknamee", value);
            }
        }
Example #4
0
 public override RenderEntity GetRenderEntity()
 {
     return(new RenderEntity()
     {
         Position = Position, Heading = Rotation.Z, Size = new Vector2(0.5f, 0.5f), Sprite = MaterialManager.FindMaterial("x1")
     });
 }