Example #1
0
    /**
     * Copies properties from another tile entity of this type into this one.
     */

    public void CopyLootContainerDataFromOther(TileEntityBlockTransformer _other)
    {
        this.lootListIndex             = _other.lootListIndex;
        this.containerSize             = _other.containerSize;
        this.items                     = ItemStack.Clone(_other.items);
        this.bTouched                  = _other.bTouched;
        this.worldTimeTouched          = _other.worldTimeTouched;
        this.bPlayerBackpack           = _other.bPlayerBackpack;
        this.bPlayerStorage            = _other.bPlayerStorage;
        this.bUserAccessing            = _other.bUserAccessing;
        this.collection                = _other.collection;
        this.tQueue                    = _other.tQueue;
        this.useHash                   = _other.useHash;
        this.requiresPower             = _other.requiresPower;
        this.requiresHeat              = _other.requiresHeat;
        this.powerSources              = _other.powerSources;
        this.heatSources               = _other.heatSources;
        this.requiresNearbyBlocks      = _other.requiresNearbyBlocks;
        this.nearbyBlockNames          = _other.nearbyBlockNames;
        this.nearbyBlockTags           = _other.nearbyBlockTags;
        this.nearbyBlockRequireAllTags = _other.nearbyBlockRequireAllTags;
        this.nearbyBlockRange          = _other.nearbyBlockRange;
        this.nearbyBlocksNeeded        = _other.nearbyBlocksNeeded;
        this.hasPower                  = false;
        this.hasHeat                   = false;
        this.hasNearbyBlocks           = false;
        this.userAccessing             = false;
        this.CalculateLookupCoordinates();
        this.random = RandomStatic.Range(0, 5);
    }
Example #2
0
    /**
     * Reads data into the tile entity when loaded.
     */

    public override void read(BinaryReader _br, StreamModeRead _eStreamMode)
    {
        base.read(_br, _eStreamMode);
        string collectionString = _br.ReadString();

        this.collection = TransformationCollection.Read(collectionString, useHash);
        string tQueueString = _br.ReadString();

        this.tQueue                    = tQueue.Read(tQueueString, useHash);
        this.requiresPower             = _br.ReadBoolean();
        this.powerSources              = StringHelpers.WriteStringToList(_br.ReadString());
        this.requiresHeat              = _br.ReadBoolean();
        this.heatSources               = StringHelpers.WriteStringToList(_br.ReadString());
        this.requiresNearbyBlocks      = _br.ReadBoolean();
        this.nearbyBlockTags           = StringHelpers.WriteStringToList(_br.ReadString());
        this.nearbyBlockRequireAllTags = _br.ReadBoolean();
        this.nearbyBlockNames          = StringHelpers.WriteStringToList(_br.ReadString());
        this.nearbyBlocksNeeded        = _br.ReadInt32();
        this.nearbyBlockRange          = StringHelpers.WriteStringToVector3i(_br.ReadString());

        // After read:
        this.hasPower        = false;
        this.hasHeat         = false;
        this.hasNearbyBlocks = false;
        this.userAccessing   = false;
        this.CalculateLookupCoordinates();
        this.random = RandomStatic.Range(0, 20);
    }
Example #3
0
        private void Panel3_Paint(object sender, PaintEventArgs e)
        {
            IEnumerator enumerator   = null;
            Graphics    graphics     = e.Graphics;
            Pen         pen          = new Pen(Color.Gray);
            ClsTerrain  selectedItem = (ClsTerrain)this.GroupSelect.SelectedItem;
            int         num          = 0;

            do
            {
                int num1 = 0;
                do
                {
                    int num2 = num1;
                    int num3 = num;
                    if (selectedItem != null)
                    {
                        e.Graphics.DrawImage(Art.GetLand(selectedItem.TileID), checked (this.StaticGrid[num2, num3].X - 22), checked (this.StaticGrid[num2, num3].Y - 22));
                    }
                    e.Graphics.DrawLine(pen, checked (this.StaticGrid[num2, num3].X - 22), this.StaticGrid[num2, num3].Y, this.StaticGrid[num2, num3].X, checked (this.StaticGrid[num2, num3].Y + 22));
                    e.Graphics.DrawLine(pen, this.StaticGrid[num2, num3].X, checked (this.StaticGrid[num2, num3].Y + 22), checked (this.StaticGrid[num2, num3].X + 22), this.StaticGrid[num2, num3].Y);
                    e.Graphics.DrawLine(pen, checked (this.StaticGrid[num2, num3].X + 22), this.StaticGrid[num2, num3].Y, this.StaticGrid[num2, num3].X, checked (this.StaticGrid[num2, num3].Y - 22));
                    e.Graphics.DrawLine(pen, this.StaticGrid[num2, num3].X, checked (this.StaticGrid[num2, num3].Y - 22), checked (this.StaticGrid[num2, num3].X - 22), this.StaticGrid[num2, num3].Y);
                    num1++;
                }while (num1 <= 12);
                num++;
            }while (num <= 12);
            pen = new Pen(Color.Red);
            int num4 = Convert.ToInt32(decimal.Add(new decimal(6L), this.Yaxis.Value));
            int num5 = Convert.ToInt32(decimal.Add(new decimal(6L), this.Xaxis.Value));

            e.Graphics.DrawLine(pen, checked (this.StaticGrid[num4, num5].X - 22), this.StaticGrid[num4, num5].Y, this.StaticGrid[num4, num5].X, checked (this.StaticGrid[num4, num5].Y + 22));
            e.Graphics.DrawLine(pen, this.StaticGrid[num4, num5].X, checked (this.StaticGrid[num4, num5].Y + 22), checked (this.StaticGrid[num4, num5].X + 22), this.StaticGrid[num4, num5].Y);
            e.Graphics.DrawLine(pen, checked (this.StaticGrid[num4, num5].X + 22), this.StaticGrid[num4, num5].Y, this.StaticGrid[num4, num5].X, checked (this.StaticGrid[num4, num5].Y - 22));
            e.Graphics.DrawLine(pen, this.StaticGrid[num4, num5].X, checked (this.StaticGrid[num4, num5].Y - 22), checked (this.StaticGrid[num4, num5].X - 22), this.StaticGrid[num4, num5].Y);
            try
            {
                enumerator = this.ListBox2.Items.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    RandomStatic current = (RandomStatic)enumerator.Current;
                    int          y       = checked (6 + current.Y);
                    int          x       = checked (6 + current.X);
                    Bitmap       @static = Art.GetStatic(current.TileID);
                    Point        point   = new Point(checked ((int)Math.Round((double)this.StaticGrid[y, x].X - (double)@static.Width / 2)), checked (checked (this.StaticGrid[y, x].Y - @static.Height) + 22));
                    e.Graphics.DrawImage(@static, point);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    ((IDisposable)enumerator).Dispose();
                }
            }
            graphics = null;
        }
Example #4
0
    /**
     * Loads the tile entity data when instantiated from placing a block.
     */

    public TileEntityBlockTransformer(Chunk _chunk) : base(_chunk)
    {
        this.tQueue          = new TransformationQueue();
        this.useHash         = true;
        this.hasPower        = false;
        this.hasHeat         = false;
        this.hasNearbyBlocks = false;
        this.random          = RandomStatic.Range(0, 5);
    }
Example #5
0
        private int CreateTetrahedron(SceneBrep scene, Matrix4 m, Vector3 center, float size)
        {
            int[] v = new int[4];
            float z = (float)(size * Math.Sqrt(0.5));

            Vector3 A = new Vector3(size, 0.0f, -z);
            Vector3 B = new Vector3(-size, 0.0f, -z);
            Vector3 C = new Vector3(0.0f, size, z);
            Vector3 D = new Vector3(0.0f, -size, z);

            // vertices:
            v[0] = scene.AddVertex(Vector3.TransformPosition(A, m));
            v[1] = scene.AddVertex(Vector3.TransformPosition(B, m));
            v[2] = scene.AddVertex(Vector3.TransformPosition(C, m));
            v[3] = scene.AddVertex(Vector3.TransformPosition(D, m));

            // normal vectors:
            scene.SetNormal(v[0], Vector3.TransformVector(A, m).Normalized());
            scene.SetNormal(v[1], Vector3.TransformVector(B, m).Normalized());
            scene.SetNormal(v[2], Vector3.TransformVector(C, m).Normalized());
            scene.SetNormal(v[3], Vector3.TransformVector(D, m).Normalized());

            // texture coordinates:
            scene.SetTxtCoord(v[0], new Vector2(1.0f, 0.0f));
            scene.SetTxtCoord(v[1], new Vector2(0.0f, 0.0f));
            scene.SetTxtCoord(v[2], new Vector2(1.0f, 1.0f));
            scene.SetTxtCoord(v[3], new Vector2(0.0f, 1.0f));

            // colors:
            long seed = (long)Math.Min(long.MaxValue, (m.Row3.LengthSquared * 10000.0f));

            seed = RandomStatic.numericRecipes(seed);
            float r = (seed & 255) / 255.0f;

            seed = RandomStatic.numericRecipes(seed);
            float g = (seed & 255) / 255.0f;

            seed = RandomStatic.numericRecipes(seed);
            float b = (seed & 255) / 255.0f;

            scene.SetColor(v[0], new Vector3(r, g, b));
            r = Math.Min(r + 0.2f, 1.0f);
            scene.SetColor(v[1], new Vector3(r, g, b));
            g = Math.Min(g + 0.2f, 1.0f);
            scene.SetColor(v[2], new Vector3(r, g, b));
            b = Math.Min(b + 0.2f, 1.0f);
            scene.SetColor(v[3], new Vector3(r, g, b));

            // triangle faces:
            scene.AddTriangle(v[0], v[1], v[2]);
            scene.AddTriangle(v[2], v[1], v[3]);
            scene.AddTriangle(v[1], v[0], v[3]);
            scene.AddTriangle(v[2], v[3], v[0]);

            return(4);
        }
Example #6
0
        /// <summary>
        /// Apply the relevant value-modulation in the given Intersection instance.
        /// Simple variant, w/o an integration support.
        /// </summary>
        /// <param name="inter">Data object to modify.</param>
        /// <returns>Hash value (texture signature) for adaptive subsampling.</returns>
        public long Apply(Intersection inter)
        {
            double u = inter.TextureCoord.X * Fu;
            double v = inter.TextureCoord.Y * Fv;

            long ui = (long)Math.Floor(u);
            long vi = (long)Math.Floor(v);

            if (((ui + vi) & 1) != 0)
            {
                Array.Copy(Color2, inter.SurfaceColor, Math.Min(Color2.Length, inter.SurfaceColor.Length));
            }

            return(ui + RandomStatic.numericRecipes(vi));
        }
Example #7
0
    /**
     *	Retrieves all outputs from the item collection in a list, based on probabilities.
     */

    public List <ItemStack> GetAllOutputsAfterProbabilityCalculation()
    {
        List <ItemStack> list = new List <ItemStack>();

        if (!this.HasOutputs())
        {
            return(list);
        }

        foreach (TransformerItemOutput transformerItemOutput in this.inputsOutputs[this.outputs])
        {
            double randomDouble = RandomStatic.Next();
            if (randomDouble <= transformerItemOutput.prob)
            {
                list.Add(transformerItemOutput.itemStack);
            }
        }

        return(list);
    }
Example #8
0
        private void ListBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            RandomStatic selectedItem = (RandomStatic)this.ListBox2.SelectedItem;

            if (selectedItem != null)
            {
                RandomStatic randomStatic = selectedItem;
                this.VScrollBar1.Value = randomStatic.TileID;
                if (Art.GetStatic(randomStatic.TileID) != null)
                {
                    this.PictureBox1.Image            = Art.GetStatic(randomStatic.TileID);
                    this.PropertyGrid1.SelectedObject = TileData.ItemTable[randomStatic.TileID];
                }
                this.TileID.Text = StringType.FromInteger(randomStatic.TileID);
                this.Xaxis.Value = new decimal(randomStatic.X);
                this.Yaxis.Value = new decimal(randomStatic.Y);
                this.Zaxis.Value = new decimal(randomStatic.Z);
                this.HueID.Text  = StringType.FromInteger(randomStatic.Hue);
                randomStatic     = null;
            }
        }
Example #9
0
        private void ToolBar_NavClick(object sender, EventArgs e)
        {
            ToolStripButton button = sender as ToolStripButton;

            if (button == null)
            {
                return;
            }
            short        num          = Convert.ToInt16(this.Xaxis.Value);
            short        y            = Convert.ToInt16(this.Yaxis.Value);
            RandomStatic selectedItem = (RandomStatic)this.ListBox2.SelectedItem;

            if (selectedItem != null)
            {
                num = selectedItem.X;
                y   = selectedItem.Y;
            }
            object tag = button.Tag;

            if (ObjectType.ObjTst(tag, 1, false) == 0)
            {
                y   = checked ((short)(checked (y - 1)));
                num = checked ((short)(checked (num - 1)));
            }
            else if (ObjectType.ObjTst(tag, 2, false) == 0)
            {
                y = checked ((short)(checked (y - 1)));
            }
            else if (ObjectType.ObjTst(tag, 3, false) == 0)
            {
                y   = checked ((short)(checked (y - 1)));
                num = checked ((short)(checked (num + 1)));
            }
            else if (ObjectType.ObjTst(tag, 4, false) == 0)
            {
                num = checked ((short)(checked (num - 1)));
            }
            else if (ObjectType.ObjTst(tag, 5, false) != 0)
            {
                if (ObjectType.ObjTst(tag, 6, false) == 0)
                {
                    num = checked ((short)(checked (num + 1)));
                }
                else if (ObjectType.ObjTst(tag, 7, false) == 0)
                {
                    y   = checked ((short)(checked (y + 1)));
                    num = checked ((short)(checked (num - 1)));
                }
                else if (ObjectType.ObjTst(tag, 8, false) == 0)
                {
                    y = checked ((short)(checked (y + 1)));
                }
                else if (ObjectType.ObjTst(tag, 9, false) == 0)
                {
                    y   = checked ((short)(checked (y + 1)));
                    num = checked ((short)(checked (num + 1)));
                }
            }
            this.Xaxis.Value = new decimal(num);
            this.Yaxis.Value = new decimal(y);
            if (selectedItem != null)
            {
                selectedItem.X = num;
                selectedItem.Y = y;
            }
            this.Panel3.Refresh();
        }