Exemple #1
0
 public void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
 {
     if (RemainCount <= 0)
     {
         dropValue.Value = Terrain.ReplaceData(Terrain.ReplaceLight(blockValue, 0), Terrain.ExtractData(blockValue) | 16384);
     }
 }
Exemple #2
0
        public override void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
        {
            var item = elementblock.GetDevice(Utils.Terrain, x, y, z);

            if (item is IHarvestingItem block)
            {
                block.OnItemHarvested(x, y, z, blockValue, ref dropValue, ref newBlockValue);
            }
        }
Exemple #3
0
        public override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List <BlockDropValue> dropValues, out bool showDebris)
        {
            int  num    = 0;
            int  data   = 0;
            int  data2  = Terrain.ExtractData(oldValue);
            int  size   = GetSize(data2);
            bool isWild = GetIsWild(data2);

            if (isWild)
            {
                num  = ((size > 2 && Random.Float(0f, 1f) < 0.33f) ? 1 : 0);
                data = 4;
            }
            else
            {
                switch (size)
                {
                case 5:
                    num  = 1;
                    data = 4;
                    break;

                case 6:
                    num  = Random.Int(1, 2);
                    data = 4;
                    break;

                case 7:
                    num  = Random.Int(1, 3);
                    data = 5;
                    break;
                }
            }
            showDebris = true;
            BlockDropValue item;

            for (int i = 0; i < num; i++)
            {
                item = new BlockDropValue
                {
                    Value = Terrain.MakeBlockValue(173, 0, data),
                    Count = 1
                };
                dropValues.Add(item);
            }
            if (size == 7 && !isWild && Random.Bool(0.5f))
            {
                item = new BlockDropValue
                {
                    Value = 248,
                    Count = 1
                };
                dropValues.Add(item);
            }
        }
        public override void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
        {
            T blockData = GetBlockData(new Point3(x, y, z));

            if (blockData != null)
            {
                int num = FindFreeItemId();
                m_itemsData.Add(num, (T)blockData.Copy());
                dropValue.Value = Terrain.ReplaceData(dropValue.Value, num);
            }
        }
Exemple #5
0
 public override void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
 {
     if (y > 80 && SubsystemWeather.IsPlaceFrozen(base.SubsystemTerrain.Terrain.GetSeasonalTemperature(x, z), y))
     {
         dropValue.Value = Terrain.MakeBlockValue(62);
     }
     else
     {
         base.OnItemHarvested(x, y, z, blockValue, ref dropValue, ref newBlockValue);
     }
 }
Exemple #6
0
        public virtual void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List <BlockDropValue> dropValues, out bool showDebris)
        {
            showDebris = (DestructionDebrisScale > 0f);
            if (toolLevel < RequiredToolLevel)
            {
                return;
            }
            BlockDropValue item;

            if (DefaultDropContent != 0)
            {
                int num = (int)DefaultDropCount;
                if (Random.Bool(DefaultDropCount - (float)num))
                {
                    num++;
                }
                for (int i = 0; i < num; i++)
                {
                    item = new BlockDropValue
                    {
                        Value = Terrain.MakeBlockValue(DefaultDropContent),
                        Count = 1
                    };
                    dropValues.Add(item);
                }
            }
            int num2 = (int)DefaultExperienceCount;

            if (Random.Bool(DefaultExperienceCount - (float)num2))
            {
                num2++;
            }
            for (int j = 0; j < num2; j++)
            {
                item = new BlockDropValue
                {
                    Value = Terrain.MakeBlockValue(248),
                    Count = 1
                };
                dropValues.Add(item);
            }
        }
Exemple #7
0
        public void DestroyCell(int toolLevel, int x, int y, int z, int newValue, bool noDrop, bool noParticleSystem)
        {
            int   cellValue = Terrain.GetCellValue(x, y, z);
            int   num       = Terrain.ExtractContents(cellValue);
            Block block     = BlocksManager.Blocks[num];

            if (num != 0)
            {
                bool showDebris = true;
                if (!noDrop)
                {
                    m_dropValues.Clear();
                    block.GetDropValues(this, cellValue, newValue, toolLevel, m_dropValues, out showDebris);
                    for (int i = 0; i < m_dropValues.Count; i++)
                    {
                        BlockDropValue dropValue = m_dropValues[i];
                        if (dropValue.Count > 0)
                        {
                            SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(Terrain.ExtractContents(dropValue.Value));
                            for (int j = 0; j < blockBehaviors.Length; j++)
                            {
                                blockBehaviors[j].OnItemHarvested(x, y, z, cellValue, ref dropValue, ref newValue);
                            }
                            if (dropValue.Count > 0 && Terrain.ExtractContents(dropValue.Value) != 0)
                            {
                                Vector3 position = new Vector3(x, y, z) + new Vector3(0.5f);
                                m_subsystemPickables.AddPickable(dropValue.Value, dropValue.Count, position, null, null);
                            }
                        }
                    }
                }
                if (showDebris && !noParticleSystem && m_subsystemViews.CalculateDistanceFromNearestView(new Vector3(x, y, z)) < 16f)
                {
                    m_subsystemParticles.AddParticleSystem(block.CreateDebrisParticleSystem(this, new Vector3((float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f), cellValue, 1f));
                }
            }
            ChangeCell(x, y, z, newValue);
        }
        public override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List <BlockDropValue> dropValues, out bool showDebris)
        {
            int data = Terrain.ExtractData(oldValue);

            if (GetSize(data) == 2)
            {
                BlockDropValue item = new BlockDropValue
                {
                    Value = Terrain.MakeBlockValue(173, 0, 6),
                    Count = Random.Int(1, 2)
                };
                dropValues.Add(item);
                if (!GetIsWild(data))
                {
                    int num = Random.Int(1, 2);
                    for (int i = 0; i < num; i++)
                    {
                        item = new BlockDropValue
                        {
                            Value = Terrain.MakeBlockValue(205, 0, 0),
                            Count = 1
                        };
                        dropValues.Add(item);
                    }
                    if (Random.Bool(0.5f))
                    {
                        item = new BlockDropValue
                        {
                            Value = Terrain.MakeBlockValue(248),
                            Count = 1
                        };
                        dropValues.Add(item);
                    }
                }
            }
            showDebris = true;
        }
Exemple #9
0
 public override void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
 {
     newBlockValue   = Terrain.MakeBlockValue(m_fluidBlock.BlockIndex);
     dropValue.Value = 0;
     dropValue.Count = 0;
 }
Exemple #10
0
 public virtual void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
 {
 }