示例#1
0
        public void GrowCotton(int value, int x, int y, int z, int pollPass)
        {
            if (Terrain.ExtractLight(base.SubsystemTerrain.Terrain.GetCellValueFast(x, y + 1, z)) < 9)
            {
                return;
            }
            int data = Terrain.ExtractData(value);
            int size = CottonBlock.GetSize(data);

            if (size >= 2)
            {
                return;
            }
            Replacement value3;

            if (CottonBlock.GetIsWild(data))
            {
                if (size < 2)
                {
                    int data2  = CottonBlock.SetSize(CottonBlock.SetIsWild(data, isWild: true), size + 1);
                    int value2 = Terrain.ReplaceData(value, data2);
                    Dictionary <Point3, Replacement> toReplace = m_toReplace;
                    Point3 key = new Point3(x, y, z);
                    value3 = new Replacement
                    {
                        Value         = value2,
                        RequiredValue = value
                    };
                    toReplace[key] = value3;
                }
                return;
            }
            int cellValueFast = base.SubsystemTerrain.Terrain.GetCellValueFast(x, y - 1, z);

            if (Terrain.ExtractContents(cellValueFast) == 168)
            {
                int   data3     = Terrain.ExtractData(cellValueFast);
                bool  hydration = SoilBlock.GetHydration(data3);
                int   nitrogen  = SoilBlock.GetNitrogen(data3);
                int   num       = 6;
                float num2      = 0.8f;
                if (nitrogen > 0)
                {
                    num  -= 2;
                    num2 -= 0.4f;
                }
                if (hydration)
                {
                    num  -= 2;
                    num2 -= 0.4f;
                }
                if (pollPass % MathUtils.Max(num, 1) == 0)
                {
                    int data4 = CottonBlock.SetSize(data, MathUtils.Min(size + 1, 2));
                    if (m_random.Float(0f, 1f) < num2 && size == 1)
                    {
                        data4 = CottonBlock.SetIsWild(data4, isWild: true);
                    }
                    int value4 = Terrain.ReplaceData(value, data4);
                    value3 = (m_toReplace[new Point3(x, y, z)] = new Replacement
                    {
                        Value = value4,
                        RequiredValue = value
                    });
                    if (size + 1 == 2)
                    {
                        int data5  = SoilBlock.SetNitrogen(data3, MathUtils.Max(nitrogen - 1, 0));
                        int value5 = Terrain.ReplaceData(cellValueFast, data5);
                        Dictionary <Point3, Replacement> toReplace2 = m_toReplace;
                        Point3 key2 = new Point3(x, y - 1, z);
                        value3 = new Replacement
                        {
                            Value         = value5,
                            RequiredValue = cellValueFast
                        };
                        toReplace2[key2] = value3;
                    }
                }
            }
            else
            {
                int value6 = Terrain.ReplaceData(value, CottonBlock.SetIsWild(data, isWild: true));
                Dictionary <Point3, Replacement> toReplace3 = m_toReplace;
                Point3 key3 = new Point3(x, y, z);
                value3 = new Replacement
                {
                    Value         = value6,
                    RequiredValue = value
                };
                toReplace3[key3] = value3;
            }
        }
示例#2
0
        public static int GenerateRandomPlantValue(Random random, int groundValue, int temperature, int humidity, int y)
        {
            switch (Terrain.ExtractContents(groundValue))
            {
            case 2:
            case 8:
                if (humidity >= 6)
                {
                    if (!(random.Float(0f, 1f) < (float)humidity / 60f))
                    {
                        break;
                    }
                    int result = Terrain.MakeBlockValue(19, 0, TallGrassBlock.SetIsSmall(0, isSmall: false));
                    if (!SubsystemWeather.IsPlaceFrozen(temperature, y))
                    {
                        float num = random.Float(0f, 1f);
                        if (num < 0.04f)
                        {
                            result = Terrain.MakeBlockValue(20);
                        }
                        else if (num < 0.07f)
                        {
                            result = Terrain.MakeBlockValue(24);
                        }
                        else if (num < 0.09f)
                        {
                            result = Terrain.MakeBlockValue(25);
                        }
                        else if (num < 0.17f)
                        {
                            result = Terrain.MakeBlockValue(174, 0, RyeBlock.SetIsWild(RyeBlock.SetSize(0, 7), isWild: true));
                        }
                        else if (num < 0.19f)
                        {
                            result = Terrain.MakeBlockValue(204, 0, CottonBlock.SetIsWild(CottonBlock.SetSize(0, 2), isWild: true));
                        }
                    }
                    return(result);
                }
                if (random.Float(0f, 1f) < 0.025f)
                {
                    if (random.Float(0f, 1f) < 0.2f)
                    {
                        return(Terrain.MakeBlockValue(99, 0, 0));
                    }
                    return(Terrain.MakeBlockValue(28, 0, 0));
                }
                break;

            case 7:
                if (humidity < 8 && random.Float(0f, 1f) < 0.01f)
                {
                    if (random.Float(0f, 1f) < 0.05f)
                    {
                        return(Terrain.MakeBlockValue(99, 0, 0));
                    }
                    return(Terrain.MakeBlockValue(28, 0, 0));
                }
                break;
            }
            return(0);
        }
示例#3
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.CellFace = raycastResult.CellFace;
            if (raycastResult.CellFace.Face == 4)
            {
                switch (Terrain.ExtractData(value))
                {
                case 0:
                    result.Value = Terrain.MakeBlockValue(19, 0, TallGrassBlock.SetIsSmall(0, isSmall: true));
                    break;

                case 1:
                    result.Value = Terrain.MakeBlockValue(20, 0, FlowerBlock.SetIsSmall(0, isSmall: true));
                    break;

                case 2:
                    result.Value = Terrain.MakeBlockValue(24, 0, FlowerBlock.SetIsSmall(0, isSmall: true));
                    break;

                case 3:
                    result.Value = Terrain.MakeBlockValue(25, 0, FlowerBlock.SetIsSmall(0, isSmall: true));
                    break;

                case 4:
                    result.Value = Terrain.MakeBlockValue(174, 0, RyeBlock.SetSize(RyeBlock.SetIsWild(0, isWild: false), 0));
                    break;

                case 5:
                    result.Value = Terrain.MakeBlockValue(174, 0, RyeBlock.SetSize(RyeBlock.SetIsWild(0, isWild: false), 0));
                    break;

                case 6:
                    result.Value = Terrain.MakeBlockValue(204, 0, CottonBlock.SetSize(CottonBlock.SetIsWild(0, isWild: false), 0));
                    break;

                case 7:
                    result.Value = Terrain.MakeBlockValue(131, 0, BasePumpkinBlock.SetSize(BasePumpkinBlock.SetIsDead(0, isDead: false), 0));
                    break;
                }
            }
            return(result);
        }