Ejemplo n.º 1
0
        protected override void WorldTick(Chunk chunk, Vector3I position)
        {
            if (position.Y == 255)
            {
                return;
            }

            else if (!chunk[position.X, position.Y + 1, position.Z].Transparent)
            {
                chunk.Edit(position.X, position.Y, position.Z, ItemCache.Get <Block>("winecrash:dirt"));
            }
        }
Ejemplo n.º 2
0
        protected override void WorldTick(Chunk chunk, Vector3I position)
        {
            if (position.Y != 255 && !chunk[position.X, position.Y + 1, position.Z].Transparent)// || chunk.GetLightLevel(position.X, position.Y + 1, position.Z) < GrassPropagationLevel)
            {
                return;
            }

            int gx;
            int gy;
            int gz;

            for (int z = -1; z < 2; z++)
            {
                gz = position.Z + z;

                for (int y = -1; y < 2; y++)
                {
                    gy = position.Y + y;

                    if (gy == 256 || gy == -1)
                    {
                        continue;
                    }

                    for (int x = -1; x < 2; x++)
                    {
                        if (x == 0 && z == 0)
                        {
                            continue;
                        }

                        gx = position.X + x;

                        if (World.GetBlock(World.LocalToGlobal(chunk.Position.XY, new Vector3I(gx, gy, gz)))?.Identifier == "winecrash:grass")
                        {
                            chunk.Edit(position.X, position.Y, position.Z, ItemCache.Get <Block>("winecrash:grass"));
                            return;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void RunGameDebug()
        {
            MainMenu.Hide();

            Input.LockMode      = CursorLockModes.Lock;
            Input.CursorVisible = false;

            new Shader("assets/shaders/cursor/Cursor.vert", "assets/shaders/cursor/Cursor.frag");
            WObject   playerWobj = new WObject("Player");
            RigidBody rb         = playerWobj.AddModule <RigidBody>();

            rb.UseGravity = false;
            BoxCollider bc = playerWobj.AddModule <BoxCollider>();

            bc.Extents = new Vector3D(0.4F, 0.9F, 0.4F);

            playerWobj.AddModule <Player>();

            //FreeCam.FreeCTRL = true;

            Camera.Main.WObject.AddModule <FreeCam>();

            Camera.Main._FarClip = 1000.0F;
            Camera.Main.FOV      = 80.0F;

            playerWobj.Position = Vector3F.Up * 80F;

            Database db = Database.Load("assets/items/items.json");

            db.ParseItems();

            new Shader("assets/shaders/chunk/Chunk.vert", "assets/shaders/chunk/Chunk.frag");
            new Shader("assets/shaders/itemUnlit/ItemUnlit.vert", "assets/shaders/itemUnlit/ItemUnlit.frag");

            Chunk.ChunkTexture = ItemCache.BuildChunkTexture(out int xsize, out int ysize);
            Chunk.TexWidth     = xsize;
            Chunk.TexHeight    = ysize;
            CreateSkybox();

            WObject worldwobj = new WObject("World");

            worldwobj.AddModule <World>();


            new WObject("Debug").AddModule <DebugMenu>();
            new WObject("EscapeMenu").AddModule <EscapeMenu>();

            WObject crosshair = new WObject("Crosshair");

            crosshair.Parent = Engine.GUI.Canvas.Main.WObject;
            Engine.GUI.Image reticule = crosshair.AddModule <Engine.GUI.Image>();
            reticule.Picture   = new Texture("assets/textures/crosshair.png");
            reticule.KeepRatio = true;
            reticule.Material.SourceColorBlending = OpenTK.Graphics.OpenGL4.BlendingFactorSrc.OneMinusDstColor;
            reticule.MinAnchor = new Vector2F(0.48F, 0.48F);
            reticule.MaxAnchor = new Vector2F(0.52F, 0.52F);

            reticule.MaxSize = Vector3F.One * 30.0F;

            WObject itembar = new WObject("Item Bar");

            itembar.Parent = Canvas.Main.WObject;
            Image bar = itembar.AddModule <Image>();

            bar.Picture   = new Texture("assets/textures/itembar.png");
            bar.KeepRatio = true;
            bar.MinAnchor = new Vector2F(0.35F, 0.005F);
            bar.MaxAnchor = new Vector2F(0.65F, 0.08F);
            bar.Color     = new Color256(1.0, 1.0, 1.0, 0.8F);

            Mesh mesh = Mesh.LoadFile("assets/models/BlockCube.obj", MeshFormats.Wavefront);

            for (int i = 0; i < ItemCache.TotalItems; i++)
            {
                Cube item = ItemCache.Get <Cube>(i);

                if (!(item is Cube))
                {
                    continue;
                }

                WObject cube = new WObject("Cube");

                cube.Parent = itembar;
                Model    model = cube.AddModule <Model>();
                Material mat   = new Material(Shader.Find("ItemUnlit"));
                mat.SetData <Vector2>("offset", new Vector2D(0, (double)i / ItemCache.TotalItems));
                mat.SetData <Vector2>("tiling", new Vector2D(1.0, 1.0 / ItemCache.TotalItems));
                mat.SetData <Vector3>("lightDir", new Vector3D(0.8, 1.0, -0.6));
                mat.SetData <Vector4>("ambiant", new Color256(0.0, 0.0, 0.0, 1.0));
                mat.SetData <Vector4>("lightColor", new Color256(2.0, 2.0, 2.0, 1.0));
                mat.SetData <Texture>("albedo", Texture.Find("Cache"));
                mat.SetData <Vector4>("color", Color256.White);

                model.Renderer.Mesh     = mesh;
                model.Renderer.Material = mat;
                model.KeepRatio         = true;

                cube.Scale   *= 1.1F;
                cube.Rotation = new Engine.Quaternion(-21, 45, -20);

                float shift = i * 0.1093F;

                model.MinAnchor = new Vector2F(0.0175F + shift, 0.0F);
                model.MaxAnchor = new Vector2F(0.11F + shift, 1.0F);
            }

            WObject itemcursor = new WObject("Item Cursor");

            itemcursor.Parent = bar.WObject;
            Image itemcurs = itemcursor.AddModule <Image>();

            itemcurs.Picture   = new Texture("assets/textures/barcursor.png");
            itemcurs.Color     = new Color256(0.4, 0.4, 1.0, 1.0F);
            itemcurs.MinAnchor = new Vector2F(0.0F, 0.0F);
            itemcurs.MaxAnchor = new Vector2F(0.125F, 1.0F);
            itemcurs.KeepRatio = true;
        }
Ejemplo n.º 4
0
 protected override void WorldTick(Chunk chunk, Vector3I position)
 {
     chunk.Edit(position.X, position.Y, position.Z, ItemCache.Get <Block>("winecrash:log"));
 }