Example #1
0
        public override void ProcessInventoryItem(IInventory inventory, int slotIndex, int value, int count, int processCount, out int processedValue, out int processedCount)
        {
            processedValue = value;
            processedCount = count;
            if (processCount == 1)
            {
                int data = Terrain.ExtractData(inventory.GetSlotValue(slotIndex));
                MusketBlock.LoadState  loadState  = MusketBlock.GetLoadState(data);
                BulletBlock.BulletType?bulletType = MusketBlock.GetBulletType(data);
                switch (loadState)
                {
                case MusketBlock.LoadState.Empty:
                    loadState  = MusketBlock.LoadState.Gunpowder;
                    bulletType = null;
                    break;

                case MusketBlock.LoadState.Gunpowder:
                    loadState  = MusketBlock.LoadState.Wad;
                    bulletType = null;
                    break;

                case MusketBlock.LoadState.Wad:
                {
                    loadState = MusketBlock.LoadState.Loaded;
                    int data2 = Terrain.ExtractData(value);
                    bulletType = BulletBlock.GetBulletType(data2);
                    break;
                }
                }
                processedValue = 0;
                processedCount = 0;
                inventory.RemoveSlotItems(slotIndex, 1);
                inventory.AddSlotItems(slotIndex, Terrain.MakeBlockValue(212, 0, MusketBlock.SetBulletType(MusketBlock.SetLoadState(data, loadState), bulletType)), 1);
            }
        }
        public override IEnumerable <CraftingRecipe> GetProceduralCraftingRecipes()
        {
            int isDead = 0;

            while (isDead <= 1)
            {
                int num;
                for (int rot = 0; rot <= 1; rot = num)
                {
                    CraftingRecipe craftingRecipe = new CraftingRecipe
                    {
                        ResultCount       = 1,
                        ResultValue       = 251,
                        RequiredHeatLevel = 1f,
                        Description       = "еКБ©до╧ожЮ"
                    };
                    int data  = BasePumpkinBlock.SetIsDead(BasePumpkinBlock.SetSize(0, 7), isDead != 0);
                    int value = SetDamage(Terrain.MakeBlockValue(131, 0, data), rot);
                    craftingRecipe.Ingredients[0] = "pumpkin:" + Terrain.ExtractData(value).ToString(CultureInfo.InvariantCulture);
                    craftingRecipe.Ingredients[1] = "waterbucket";
                    yield return(craftingRecipe);

                    num = rot + 1;
                }
                num    = isDead + 1;
                isDead = num;
            }
        }
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int?color = GetColor(Terrain.ExtractData(value));
            BlockPlacementData result;

            if (raycastResult.CellFace.Face < 4)
            {
                int data = AttachedSignBlock.SetFace(AttachedSignBlock.SetColor(0, color), raycastResult.CellFace.Face);
                result          = default(BlockPlacementData);
                result.Value    = Terrain.MakeBlockValue(m_attachedSignBlockIndex, 0, data);
                result.CellFace = raycastResult.CellFace;
                return(result);
            }
            Vector3 forward   = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num       = float.MinValue;
            int     direction = 0;

            for (int i = 0; i < 8; i++)
            {
                float num2 = Vector3.Dot(forward, m_directions[i]);
                if (num2 > num)
                {
                    num       = num2;
                    direction = i;
                }
            }
            int data2 = SetHanging(SetDirection(SetColor(0, color), direction), raycastResult.CellFace.Face == 5);

            result          = default(BlockPlacementData);
            result.Value    = Terrain.MakeBlockValue(BlockIndex, 0, data2);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Example #4
0
        public static int DecodeResult(string result)
        {
            var strArray = result.Split(':');

            return(Terrain.MakeBlockValue(BlocksManager.FindBlockByTypeName(strArray[0], true).BlockIndex, 0,
                                          strArray.Length >= 2 ? int.Parse(strArray[1], CultureInfo.InvariantCulture) : 0));
        }
Example #5
0
        public override IEnumerable <int> GetCreativeValues()
        {
            int color = 0;

            while (color < 8)
            {
                int num;
                for (int altitude = 0; altitude < 2; altitude = num)
                {
                    for (int flickering = 0; flickering < 2; flickering = num)
                    {
                        for (int shape = 0; shape < 8; shape = num)
                        {
                            yield return(Terrain.MakeBlockValue(215, 0, SetColor(SetAltitude(SetShape(SetFlickering(0, flickering != 0), (Shape)shape), altitude), color)));

                            num = shape + 1;
                        }
                        num = flickering + 1;
                    }
                    num = altitude + 1;
                }
                num   = color + 1;
                color = num;
            }
        }
 public override void OnExplosion(int value, int x, int y, int z, float damage)
 {
     if (damage > BlocksManager.Blocks[8].ExplosionResilience * m_random.Float(0f, 1f))
     {
         base.SubsystemTerrain.ChangeCell(x, y, z, Terrain.MakeBlockValue(2, 0, 0));
     }
 }
Example #7
0
        public override IEnumerable <CraftingRecipe> GetProceduralCraftingRecipes()
        {
            foreach (EggType eggType in ((EggBlock)BlocksManager.Blocks[118]).EggTypes)
            {
                if (eggType.NutritionalValue > 0f)
                {
                    int rot = 0;
                    while (rot <= 1)
                    {
                        CraftingRecipe craftingRecipe = new CraftingRecipe
                        {
                            ResultCount       = 1,
                            ResultValue       = Terrain.MakeBlockValue(118, 0, SetEggType(SetIsCooked(0, isCooked: true), eggType.EggTypeIndex)),
                            RemainsCount      = 1,
                            RemainsValue      = Terrain.MakeBlockValue(91),
                            RequiredHeatLevel = 1f,
                            Description       = "Cook an egg to increase its nutritional value"
                        };
                        int data  = SetEggType(SetIsLaid(0, isLaid: true), eggType.EggTypeIndex);
                        int value = SetDamage(Terrain.MakeBlockValue(118, 0, data), rot);
                        craftingRecipe.Ingredients[0] = "egg:" + Terrain.ExtractData(value).ToString(CultureInfo.InvariantCulture);
                        craftingRecipe.Ingredients[1] = "waterbucket";
                        yield return(craftingRecipe);

                        int num = rot + 1;
                        rot = num;
                    }
                }
            }
        }
Example #8
0
 public override void MeasureOverride(Vector2 parentAvailableSize)
 {
     m_blockIconWidget.IsVisible = false;
     m_labelWidget.IsVisible     = false;
     if (!string.IsNullOrEmpty(m_ingredient))
     {
         CraftingRecipesManager.DecodeIngredient(m_ingredient, out string craftingId, out int?data);
         Block[] array = BlocksManager.FindBlocksByCraftingId(craftingId);
         if (array.Length != 0)
         {
             Block block = array[(int)(1.0 * Time.RealTime) % array.Length];
             if (block != null)
             {
                 m_blockIconWidget.Value     = Terrain.MakeBlockValue(block.BlockIndex, 0, data.HasValue ? data.Value : 4);
                 m_blockIconWidget.Light     = 15;
                 m_blockIconWidget.IsVisible = true;
             }
         }
     }
     else if (m_resultValue != 0)
     {
         m_blockIconWidget.Value     = m_resultValue;
         m_blockIconWidget.Light     = 15;
         m_labelWidget.Text          = m_resultCount.ToString();
         m_blockIconWidget.IsVisible = true;
         m_labelWidget.IsVisible     = true;
     }
     base.MeasureOverride(parentAvailableSize);
 }
 public void UpdateFluidIsTop(TerrainChunk chunk)
 {
     _ = m_subsystemTerrain.Terrain;
     for (int i = 0; i < 16; i++)
     {
         for (int j = 0; j < 16; j++)
         {
             int num  = TerrainChunk.CalculateCellIndex(i, 255, j);
             int num2 = 0;
             int num3 = 255;
             while (num3 >= 0)
             {
                 int cellValueFast = chunk.GetCellValueFast(num);
                 int num4          = Terrain.ExtractContents(cellValueFast);
                 if (num4 != 0 && num4 != num2 && BlocksManager.Blocks[num4] is FluidBlock)
                 {
                     int data = Terrain.ExtractData(cellValueFast);
                     chunk.SetCellValueFast(num, Terrain.MakeBlockValue(num4, 0, FluidBlock.SetIsTop(data, isTop: true)));
                 }
                 num2 = num4;
                 num3--;
                 num--;
             }
         }
     }
 }
Example #10
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward  = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num      = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2     = Vector3.Dot(forward, Vector3.UnitX);
            float   num3     = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4     = Vector3.Dot(forward, -Vector3.UnitX);
            int     rotation = 0;

            if (num == MathUtils.Max(num, num2, num3, num4))
            {
                rotation = 2;
            }
            else if (num2 == MathUtils.Max(num, num2, num3, num4))
            {
                rotation = 3;
            }
            else if (num3 == MathUtils.Max(num, num2, num3, num4))
            {
                rotation = 0;
            }
            else if (num4 == MathUtils.Max(num, num2, num3, num4))
            {
                rotation = 1;
            }
            bool isUpsideDown         = raycastResult.CellFace.Face == 5;
            int  data                 = Terrain.ExtractData(value);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.MakeBlockValue(BlockIndex, 0, SetIsUpsideDown(SetRotation(data, rotation), isUpsideDown));
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Example #11
0
 public override IEnumerable <int> GetCreativeValues()
 {
     foreach (int enumValue in EnumUtils.GetEnumValues(typeof(BulletType)))
     {
         yield return(Terrain.MakeBlockValue(214, 0, SetBulletType(0, (BulletType)enumValue)));
     }
 }
Example #12
0
        public override IEnumerable <CraftingRecipe> GetProceduralCraftingRecipes()
        {
            int color = 0;

            while (color < 8)
            {
                CraftingRecipe craftingRecipe = new CraftingRecipe
                {
                    ResultCount       = 4,
                    ResultValue       = Terrain.MakeBlockValue(182, 0, SetColor(0, color)),
                    RemainsCount      = 1,
                    RemainsValue      = Terrain.MakeBlockValue(90),
                    RequiredHeatLevel = 0f,
                    Description       = LanguageControl.Get(GetType().Name, 1)
                };
                craftingRecipe.Ingredients[0] = "glass";
                craftingRecipe.Ingredients[1] = "glass";
                craftingRecipe.Ingredients[2] = "glass";
                craftingRecipe.Ingredients[4] = "paintbucket:" + color.ToString(CultureInfo.InvariantCulture);
                craftingRecipe.Ingredients[6] = "copperingot";
                craftingRecipe.Ingredients[7] = "copperingot";
                craftingRecipe.Ingredients[8] = "copperingot";
                yield return(craftingRecipe);

                int num = color + 1;
                color = num;
            }
        }
Example #13
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int num   = Terrain.ExtractContents(value);
            int data  = Terrain.ExtractData(value);
            int num2  = Terrain.ExtractContents(raycastResult.Value);
            int data2 = Terrain.ExtractData(raycastResult.Value);
            BlockPlacementData result;

            if (num2 == num && ((GetIsTop(data2) && raycastResult.CellFace.Face == 5) || (!GetIsTop(data2) && raycastResult.CellFace.Face == 4)))
            {
                int             value2         = Terrain.MakeBlockValue(m_fullBlockIndex, 0, 0);
                IPaintableBlock paintableBlock = BlocksManager.Blocks[m_fullBlockIndex] as IPaintableBlock;
                if (paintableBlock != null)
                {
                    int?color = GetColor(data);
                    value2 = paintableBlock.Paint(subsystemTerrain, value2, color);
                }
                CellFace cellFace = raycastResult.CellFace;
                cellFace.Point -= CellFace.FaceToPoint3(cellFace.Face);
                result          = default(BlockPlacementData);
                result.Value    = value2;
                result.CellFace = cellFace;
                return(result);
            }
            bool isTop = (raycastResult.CellFace.Face >= 4) ? (raycastResult.CellFace.Face == 5) : (raycastResult.HitPoint().Y - (float)raycastResult.CellFace.Y > 0.5f);

            result          = default(BlockPlacementData);
            result.Value    = Terrain.MakeBlockValue(BlockIndex, 0, SetIsTop(data, isTop));
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Example #14
0
        public void SetDraw(int draw)
        {
            int data  = Terrain.ExtractData(m_inventory.GetSlotValue(m_slotIndex));
            int value = Terrain.MakeBlockValue(200, 0, CrossbowBlock.SetDraw(data, draw));

            m_inventory.RemoveSlotItems(m_slotIndex, 1);
            m_inventory.AddSlotItems(m_slotIndex, value, 1);
        }
Example #15
0
        public override IEnumerable <int> GetCreativeValues()
        {
            yield return(Terrain.MakeBlockValue(BlockIndex, 0, SetHydration(0, hydration: false)));

            yield return(Terrain.MakeBlockValue(BlockIndex, 0, SetHydration(0, hydration: true)));

            yield return(Terrain.MakeBlockValue(BlockIndex, 0, SetHydration(SetNitrogen(0, 3), hydration: true)));
        }
Example #16
0
        public override IEnumerable <int> GetCreativeValues()
        {
            yield return(Terrain.MakeBlockValue(237, 0, SetMode(SetMaxExtension(0, 7), PistonMode.Pushing)));

            yield return(Terrain.MakeBlockValue(237, 0, SetMode(SetMaxExtension(0, 7), PistonMode.Pulling)));

            yield return(Terrain.MakeBlockValue(237, 0, SetMode(SetMaxExtension(0, 7), PistonMode.StrictPulling)));
        }
Example #17
0
        public override IEnumerable <int> GetCreativeValues()
        {
            yield return(Terrain.MakeBlockValue(204, 0, SetIsWild(SetSize(0, 2), isWild: true)));

            yield return(Terrain.MakeBlockValue(204, 0, SetIsWild(SetSize(0, 1), isWild: false)));

            yield return(Terrain.MakeBlockValue(204, 0, SetIsWild(SetSize(0, 2), isWild: false)));
        }
Example #18
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = ((raycastResult.CellFace.Face < 4) ? Terrain.MakeBlockValue(BlockIndex, 0, SetFace(0, raycastResult.CellFace.Face)) : 0);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Example #19
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.MakeBlockValue(139, 0, SetMountingFace(Terrain.ExtractData(value), raycastResult.CellFace.Face));
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Example #20
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.CellFace = raycastResult.CellFace;
            result.Value    = Terrain.MakeBlockValue(209, 0, 3);
            return(result);
        }
Example #21
0
 public override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List <BlockDropValue> dropValues, out bool showDebris)
 {
     dropValues.Add(new BlockDropValue
     {
         Value = Terrain.MakeBlockValue(253, 0, 0),
         Count = 1
     });
     showDebris = true;
 }
Example #22
0
 public override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List <BlockDropValue> dropValues, out bool showDebris)
 {
     showDebris = true;
     dropValues.Add(new BlockDropValue
     {
         Value = Terrain.MakeBlockValue(189, 0, Terrain.ExtractData(oldValue)),
         Count = 1
     });
 }
Example #23
0
        public override IEnumerable <int> GetCreativeValues()
        {
            var list = EnumUtils.GetEnumValues(typeof(BulletType));

            for (int i = 0; i < list.Count; i++)
            {
                yield return(Terrain.MakeBlockValue(214, 0, SetBulletType(0, (BulletType)list[i])));
            }
        }
        public void FreezeThawAndDepositSnow(TerrainChunk chunk)
        {
            Terrain terrain = SubsystemTerrain.Terrain;

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    if (m_random.Int() % 2 == 0)
                    {
                        continue;
                    }
                    int topHeightFast = chunk.GetTopHeightFast(i, j);
                    int cellValueFast = chunk.GetCellValueFast(i, topHeightFast, j);
                    int num           = Terrain.ExtractContents(cellValueFast);
                    int num2          = chunk.Origin.X + i;
                    int num3          = topHeightFast;
                    int num4          = chunk.Origin.Y + j;
                    PrecipitationShaftInfo precipitationShaftInfo = GetPrecipitationShaftInfo(num2, num4);
                    if (precipitationShaftInfo.Type == PrecipitationType.Snow)
                    {
                        if (num == 18)
                        {
                            int  cellContents  = terrain.GetCellContents(num2 + 1, num3, num4);
                            int  cellContents2 = terrain.GetCellContents(num2 - 1, num3, num4);
                            int  cellContents3 = terrain.GetCellContents(num2, num3, num4 - 1);
                            int  cellContents4 = terrain.GetCellContents(num2, num3, num4 + 1);
                            bool num5          = cellContents != 18 && cellContents != 0;
                            bool flag          = cellContents2 != 18 && cellContents2 != 0;
                            bool flag2         = cellContents3 != 18 && cellContents3 != 0;
                            bool flag3         = cellContents4 != 18 && cellContents4 != 0;
                            if (num5 | flag | flag2 | flag3)
                            {
                                SubsystemTerrain.ChangeCell(num2, num3, num4, Terrain.MakeBlockValue(62));
                            }
                        }
                        else if (precipitationShaftInfo.Intensity > 0.5f && SubsystemSnowBlockBehavior.CanSupportSnow(cellValueFast) && (num != 62 || ShaftHasSnowOnIce(num2, num4)) && num3 + 1 < 255)
                        {
                            SubsystemTerrain.ChangeCell(num2, num3 + 1, num4, Terrain.MakeBlockValue(61));
                        }
                    }
                    else
                    {
                        switch (num)
                        {
                        case 61:
                            SubsystemTerrain.DestroyCell(0, num2, num3, num4, 0, noDrop: true, noParticleSystem: true);
                            break;

                        case 62:
                            SubsystemTerrain.DestroyCell(0, num2, num3, num4, 0, noDrop: false, noParticleSystem: true);
                            break;
                        }
                    }
                }
            }
        }
Example #25
0
 public override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List <BlockDropValue> dropValues, out bool showDebris)
 {
     showDebris = DestructionDebrisScale > 0f;
     dropValues.Add(new BlockDropValue
     {
         Value = Terrain.MakeBlockValue(oldValue, 0, SetDirection(Terrain.ExtractData(oldValue), 0)),
         Count = 1
     });
 }
        public override int GetDamageDestructionValue(int value)
        {
            if (m_isRotten)
            {
                return(0);
            }
            int data = Terrain.ExtractData(value);

            return(SetDamage(Terrain.MakeBlockValue(244, 0, data), 0));
        }
        public override IEnumerable <int> GetCreativeValues()
        {
            yield return(Terrain.MakeBlockValue(BlockIndex, 0, SetSize(SetIsDead(0, isDead: true), 1)));

            yield return(Terrain.MakeBlockValue(BlockIndex, 0, SetSize(SetIsDead(0, isDead: true), 3)));

            yield return(Terrain.MakeBlockValue(BlockIndex, 0, SetSize(SetIsDead(0, isDead: true), 5)));

            yield return(Terrain.MakeBlockValue(BlockIndex, 0, SetSize(SetIsDead(0, isDead: true), 7)));
        }
Example #28
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward = componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation.ToForwardVector();

            return(new BlockPlacementData
            {
                CellFace = raycastResult.CellFace,
                Value = Terrain.MakeBlockValue(Index, 0, SetRailType(0, MathUtils.Abs(forward.X) < MathUtils.Abs(forward.Z) ? 4 : 5))
            });
        }
Example #29
0
        public override IEnumerable <int> GetCreativeValues()
        {
            List <int> list = new List <int>();

            foreach (int enumValue in EnumUtils.GetEnumValues(typeof(SeedType)))
            {
                list.Add(Terrain.MakeBlockValue(173, 0, enumValue));
            }
            return(list);
        }
 public static int DecodeResult(string result)
 {
     if (!string.IsNullOrEmpty(result))
     {
         string[] array = result.Split(new char[] { ':' }, StringSplitOptions.None);
         Block    block = BlocksManager.FindBlockByTypeName(array[0], throwIfNotFound: true);
         return(Terrain.MakeBlockValue(data: (array.Length >= 2) ? int.Parse(array[1], CultureInfo.InvariantCulture) : 0, contents: block.BlockIndex, light: 0));
     }
     return(0);
 }