Exemplo n.º 1
0
        public static bool PreFix()
        {
            TreeGrowth TreeSyst = (TreeGrowth)GameObject.FindObjectOfType(typeof(TreeGrowth));

            TreeSyst.FillTileChance.Min = TileChancesMin;
            TreeSyst.FillTileChance.Max = TilecChanceMax;

            TreeSyst.GrowToNewTileChance.Min = NewTileChanceMin;
            TreeSyst.GrowToNewTileChance.Max = NewTileChanceMax;

            TreeSyst.MaxTreesOnMap = MaxTrees;
            return(true);
        }
Exemplo n.º 2
0
        public bool GrowthAppliesNow(TreeGrowth growth)
        {
            if (!GrowthAppliesEver(growth))
            {
                return(false);
            }
            int currentTicks = TimeHolder.DisplayedTime.CurrentYearTicks;

            if ((growth.timing_start != -1 && growth.timing_start > currentTicks) || (growth.timing_end != -1 && growth.timing_end < currentTicks))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
    public override bool GetValue(MapDataStore.Tile tile, MeshLayer layer, out T value)
    {
        //let's just get rid of dead trees right away
        if (tile.special == TiletypeSpecial.DEAD ||
            tile.special == TiletypeSpecial.SMOOTH_DEAD)
        {
            value = default(T);
            return(false);
        }
        int growthLayer = int.MaxValue;

        switch (layer)
        {
        case MeshLayer.GrowthMaterial:
        case MeshLayer.GrowthCutout:
        case MeshLayer.GrowthTransparent:
            growthLayer = 0;
            break;

        case MeshLayer.GrowthMaterial1:
        case MeshLayer.GrowthCutout1:
        case MeshLayer.GrowthTransparent1:
            growthLayer = 1;
            break;

        case MeshLayer.GrowthMaterial2:
        case MeshLayer.GrowthCutout2:
        case MeshLayer.GrowthTransparent2:
            growthLayer = 2;
            break;

        case MeshLayer.GrowthMaterial3:
        case MeshLayer.GrowthCutout3:
        case MeshLayer.GrowthTransparent3:
            growthLayer = 3;
            break;

        default:
            break;
        }
        MatPairStruct mat = tile.material;

        if (mat.mat_type != PlantType ||
            mat.mat_index < 0 ||
            DFConnection.Instance.NetPlantRawList == null ||
            DFConnection.Instance.NetPlantRawList.plant_raws.Count <= mat.mat_index ||
            DFConnection.Instance.NetPlantRawList.plant_raws[mat.mat_index].growths.Count <= growthLayer)
        {
            value = default(T);
            return(false);
        }
        TreeGrowth growth = DFConnection.Instance.NetPlantRawList.plant_raws[mat.mat_index].growths[growthLayer];

        if (!tile.GrowthAppliesNow(growth))
        {
            value = default(T);
            return(false);
        }

        int currentTicks = TimeHolder.DisplayedTime.CurrentYearTicks;

        GrowthPrint print      = null;
        int         printIndex = 0;

        for (int i = 0; i < growth.prints.Count; i++)
        {
            var tempPrint = growth.prints[i];
            if (!((tempPrint.timing_start != -1 && tempPrint.timing_start > currentTicks) || (tempPrint.timing_end != -1 && tempPrint.timing_end < currentTicks)))
            {
                print      = tempPrint;
                printIndex = i;
            }
        }
        if (print == null)
        {
            value = default(T);
            return(false);
        }
        BuildingStruct growthIndex = new BuildingStruct(mat.mat_index, growthLayer, printIndex);
        Content        cont;

        if (growthMatcher.TryGetValue(growthIndex, out cont))
        {
            value = cont.GetValue(tile, layer);
            return(true);
        }
        value = default(T);
        return(false);
    }
Exemplo n.º 4
0
 public bool GrowthAppliesNow(TreeGrowth growth)
 {
     if (!GrowthAppliesEver(growth))
         return false;
     int currentTicks = TimeHolder.DisplayedTime.CurrentYearTicks;
     if ((growth.timing_start != -1 && growth.timing_start > currentTicks) || (growth.timing_end != -1 && growth.timing_end < currentTicks))
     {
         return false;
     }
     return true;
 }
Exemplo n.º 5
0
        public bool GrowthAppliesEver(TreeGrowth growth)
        {
            if (special == TiletypeSpecial.DEAD
                || special == TiletypeSpecial.SMOOTH_DEAD)
            {
                return false;
            }
            switch (tiletypeMaterial)
            {
                case TiletypeMaterial.PLANT:
                    switch (shape)
                    {
                        case TiletypeShape.SAPLING:
                            if (!growth.sapling)
                                return false;
                            break;
                        case TiletypeShape.SHRUB:
                            //so far as I can understand, this is always on
                            break;
                        default:
                            return false;
                    }
                    break;
                case TiletypeMaterial.ROOT:
                    if (!growth.roots)
                        return false;
                    break;
                case TiletypeMaterial.TREE_MATERIAL:
                    switch (shape)
                    {
                        case TiletypeShape.WALL:
                        case TiletypeShape.RAMP:
                        case TiletypeShape.TRUNK_BRANCH:
                            if (!growth.trunk)
                                return false;
                            break;
                        case TiletypeShape.BRANCH:
                            if (special == TiletypeSpecial.SMOOTH)
                                return false;
                            if (direction == "--------")
                            {
                                if (!growth.light_branches)
                                    return false;
                            }
                            else if (!growth.heavy_branches)
                                return false;
                            break;
                        case TiletypeShape.TWIG:
                            if (!growth.twigs)
                                return false;
                            break;
                        default:
                            return false;
                    }
                    break;
                case TiletypeMaterial.MUSHROOM:
                    if (!growth.cap)
                        return false;
                    break;
                default:
                    return false;
            }

            if ((growth.trunk_height_start != -1 && growth.trunk_height_start > trunkPercent) || (growth.trunk_height_end != -1 && growth.trunk_height_end < trunkPercent))
                return false;

            return true;
        }
Exemplo n.º 6
0
 public static void OnGenerateTrees(TreeGrowth treeGrowth)
 {
     Merlin.Dispatch(mod => mod.OnGenerateTrees(treeGrowth));
 }
Exemplo n.º 7
0
        public bool GrowthAppliesEver(TreeGrowth growth)
        {
            if (special == TiletypeSpecial.DEAD ||
                special == TiletypeSpecial.SMOOTH_DEAD)
            {
                return(false);
            }
            switch (tiletypeMaterial)
            {
            case TiletypeMaterial.PLANT:
                switch (shape)
                {
                case TiletypeShape.SAPLING:
                    if (!growth.sapling)
                    {
                        return(false);
                    }
                    break;

                case TiletypeShape.SHRUB:
                    //so far as I can understand, this is always on
                    break;

                default:
                    return(false);
                }
                break;

            case TiletypeMaterial.ROOT:
                if (!growth.roots)
                {
                    return(false);
                }
                break;

            case TiletypeMaterial.TREE_MATERIAL:
                switch (shape)
                {
                case TiletypeShape.WALL:
                case TiletypeShape.RAMP:
                case TiletypeShape.TRUNK_BRANCH:
                    if (!growth.trunk)
                    {
                        return(false);
                    }
                    break;

                case TiletypeShape.BRANCH:
                    if (special == TiletypeSpecial.SMOOTH)
                    {
                        return(false);
                    }
                    if (direction == "--------")
                    {
                        if (!growth.light_branches)
                        {
                            return(false);
                        }
                    }
                    else if (!growth.heavy_branches)
                    {
                        return(false);
                    }
                    break;

                case TiletypeShape.TWIG:
                    if (!growth.twigs)
                    {
                        return(false);
                    }
                    break;

                default:
                    return(false);
                }
                break;

            case TiletypeMaterial.MUSHROOM:
                if (!growth.cap)
                {
                    return(false);
                }
                break;

            default:
                return(false);
            }

            if ((growth.trunk_height_start != -1 && growth.trunk_height_start > trunkPercent) || (growth.trunk_height_end != -1 && growth.trunk_height_end < trunkPercent))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 8
0
 public virtual void OnGenerateTrees(TreeGrowth treeGrowth)
 {
 }
Exemplo n.º 9
0
 public override void OnGenerateTrees(TreeGrowth treeGrowth)
 {
     treeGrowth.MaxTreesOnMap = 3200;
 }