Exemple #1
0
        /// Load all plant definitions
        public static void LoadPlantsFromCode()
        {
            Defs.plants = new Dictionary <string, TilableDef>();

            Defs.AddPlant(new TilableDef {
                uid            = "carrot",
                layer          = Layer.Plant,
                pathCost       = .95f,
                blockPlant     = true,
                nutriments     = 2f,
                blockStackable = true,
                type           = TilableType.Plant,
                cuttable       = true,
                graphics       = new GraphicDef {
                    textureName = "carrot"
                },
                plantDef = new PlantDef {
                    probability  = .1f,
                    minFertility = .1f
                }
            });

            Defs.AddPlant(new TilableDef {
                uid            = "grass",
                layer          = Layer.Plant,
                pathCost       = .95f,
                blockPlant     = true,
                nutriments     = 1f,
                cuttable       = true,
                blockStackable = true,
                type           = TilableType.Grass,
                graphics       = new GraphicDef {
                    textureName = "grass"
                },
                plantDef = new PlantDef {
                    probability  = .5f,
                    minFertility = .1f
                }
            });
            Defs.AddPlant(new TilableDef {
                uid            = "tree",
                layer          = Layer.Plant,
                type           = TilableType.Tree,
                blockPath      = true,
                blockStackable = true,
                cuttable       = true,
                blockPlant     = true,
                graphics       = new GraphicDef {
                    textureName = "tree",
                    size        = new Vector2(2, 3f),
                    pivot       = new Vector2(.5f, 0)
                },
                plantDef = new PlantDef {
                    probability  = .1f,
                    minFertility = .2f
                }
            });
        }
Exemple #2
0
        /// Load all tasks definitions
        public static void LoadTasksFromCode()
        {
            Defs.tasks = new Dictionary <string, TaskDef>();

            Defs.AddTask(new TaskDef {
                uid      = "task_sleep",
                taskType = TaskType.Sleep
            });

            Defs.AddTask(new TaskDef {
                uid        = "task_cut",
                taskType   = TaskType.Cut,
                targetType = TargetType.Adjacent,
            });

            Defs.AddTask(new TaskDef {
                uid        = "task_harvest",
                taskType   = TaskType.Harvest,
                targetType = TargetType.Adjacent,
            });

            Defs.AddTask(new TaskDef {
                uid        = "task_dirt",
                taskType   = TaskType.Dirt,
                targetType = TargetType.Adjacent,
            });

            Defs.AddTask(new TaskDef {
                uid        = "task_sow",
                taskType   = TaskType.Sow,
                targetType = TargetType.Adjacent,
            });

            Defs.AddTask(new TaskDef {
                uid        = "haul_recipe",
                taskType   = TaskType.HaulRecipe,
                targetType = TargetType.Adjacent,
            });

            Defs.AddTask(new TaskDef {
                uid      = "task_idle",
                taskType = TaskType.Idle
            });

            Defs.AddTask(new TaskDef {
                uid      = "task_eat",
                taskType = TaskType.Eat
            });
        }
Exemple #3
0
        /// Load all plant definitions
        public static void LoadStackablesFromCode()
        {
            Defs.stackables = new Dictionary <string, TilableDef>();

            Defs.AddStackable(new TilableDef {
                uid            = "logs",
                layer          = Layer.Stackable,
                blockStackable = true,
                graphics       = new GraphicDef {
                    textureName = "logs_stack",
                    color       = new Color(112 / 255f, 78 / 255f, 46 / 255f, 1f)
                },
                maxStack = 25
            });
        }
Exemple #4
0
 /// Load all mountains definitions
 public static void LoadMountainsFromCode()
 {
     Defs.mountains = new Dictionary <string, TilableDef>();
     Defs.AddMountain(
         new TilableDef {
         uid            = "mountain",
         blockPath      = true,
         blockStackable = true,
         supportRoof    = true,
         blockBuilding  = true,
         blockPlant     = true,
         layer          = Layer.Mountain,
         graphics       = new GraphicDef {
             textureName = "mountain",
             color       = new Color(72 / 255f, 72 / 255f, 72 / 255f, 1f)
         }
     }
         );
 }
Exemple #5
0
        /// Load all plant definitions
        public static void LoadAnimalsFromCode()
        {
            Defs.animals = new Dictionary <string, AnimalDef>();

            Defs.AddAnimal(new AnimalDef {
                uid       = "human",
                shortDesc = "Weid animal.",

                /*graphics = new GraphicDef{
                 *      textureName = "chicken_front"
                 * },*/
                graphics = new GraphicDef()
            });

            Defs.AddAnimal(new AnimalDef {
                uid       = "chicken",
                shortDesc = "A chicken (Gallus gallus domesticus) is a kind of domesticated bird. It is raised in many places for its meat and eggs.",
                graphics  = new GraphicDef {
                    textureName = "chicken_front",
                    size        = new Vector2(.7f, .7f)
                },
            });
        }
Exemple #6
0
        /// Load all plant definitions
        public static void LoadBuildingsFromCode()
        {
            Defs.buildings = new Dictionary <string, TilableDef>();
            RecipeDef recipe = new RecipeDef();

            recipe.reqs.Add(
                Defs.stackables["logs"],
                2
                );

            Defs.AddBuilding(new TilableDef {
                uid            = "wood_wall",
                layer          = Layer.Building,
                type           = TilableType.BuildingConnected,
                blockPath      = true,
                blockStackable = true,
                blockPlant     = true,
                graphics       = new GraphicDef {
                    textureName = "wall"
                },
                recipeDef = recipe
            });
        }
Exemple #7
0
        /// Load all ground definitions
        public static void LoadGroundsFromCode()
        {
            Defs.grounds         = new Dictionary <string, TilableDef>();
            Defs.groundsByHeight = new SortedDictionary <float, TilableDef>();

            /* Water */
            Defs.AddGround(
                new TilableDef {
                uid       = "water",
                layer     = Layer.Ground,
                blockPath = true,
                graphics  = new GraphicDef {
                    textureName  = "water",
                    materialName = "grounds",
                    isInstanced  = false,
                    drawPriority = 0,
                },
                groundDef = new GroundDef {
                    maxHeight = .30f
                }
            }
                );

            /* Dirt */
            Defs.AddGround(
                new TilableDef {
                uid       = "dirt",
                layer     = Layer.Ground,
                fertility = 1f,
                graphics  = new GraphicDef {
                    textureName  = "dirt",
                    materialName = "grounds",
                    isInstanced  = false,
                    drawPriority = 1
                },
                groundDef = new GroundDef {
                    maxHeight = .5f
                }
            }
                );

            /* Rocks */
            Defs.AddGround(
                new TilableDef {
                uid      = "rocks",
                layer    = Layer.Ground,
                pathCost = 1.05f,
                graphics = new GraphicDef {
                    textureName  = "rocks",
                    materialName = "grounds",
                    isInstanced  = false,
                    drawPriority = 2
                },
                groundDef = new GroundDef {
                    maxHeight = .75f
                }
            }
                );

            foreach (TilableDef tilableDef in Defs.grounds.Values)
            {
                Defs.groundsByHeight.Add(tilableDef.groundDef.maxHeight, tilableDef);
            }
        }
Exemple #8
0
        /// Load all color definitions
        public static void LoadColorPalletsFromCode()
        {
            Defs.colorPallets      = new Dictionary <string, ColorPaletteDef>();
            Defs.namedColorPallets = new Dictionary <string, NamedColorPaletteDef>();

            Defs.AddColorPalette(new ColorPaletteDef {
                uid    = "human_hair",
                colors = new List <Color> {
                    new Color(150 / 255f, 150 / 255f, 150 / 255f, 1),
                    new Color(179 / 255f, 75 / 255f, 165 / 255f, 1),
                    new Color(87 / 255f, 75 / 255f, 179 / 255f, 1),
                    new Color(76 / 255f, 179 / 255f, 130 / 255f, 1),
                    new Color(90 / 255f, 175 / 255f, 75 / 255f, 1),
                    new Color(177 / 255f, 179 / 255f, 76 / 255f, 1),
                    new Color(117 / 255f, 49 / 255f, 29 / 255f, 1),
                    new Color(31 / 255f, 17 / 255f, 12 / 255f, 1),
                }
            });


            Defs.AddColorPalette(new ColorPaletteDef {
                uid    = "human_body",
                colors = new List <Color> {
                    new Color(190 / 255f, 160 / 255f, 135 / 255f, 1f),
                    new Color(70 / 255f, 50 / 255f, 25 / 255f, 1f),
                    new Color(39 / 255f, 29 / 255f, 8 / 255f, 1f),
                    new Color(220 / 255f, 220 / 255f, 220 / 255f, 1f),
                    new Color(161 / 255f, 128 / 255f, 68 / 255f, 1f),
                    new Color(215 / 255f, 167 / 255f, 208 / 255f, 1f)
                }
            });


            Defs.AddColorPalette(new NamedColorPaletteDef {
                uid    = "cols_vitals",
                colors = new Dictionary <string, Color> {
                    { "Health", new Color(51 / 255f, 12 / 255f, 12 / 255f, 1) },
                    { "Energy", new Color(20 / 255f, 38 / 255f, 12 / 255f, 1) },
                    { "Mana", new Color(12 / 255f, 23 / 255f, 51 / 255f, 1) },
                    { "Joy", new Color(51 / 255f, 12 / 255f, 50 / 255f, 1) },
                    { "Hunger", new Color(51 / 255f, 12 / 255f, 50 / 255f, 1) },
                }
            });

            Defs.AddColorPalette(new ColorPaletteDef {
                uid    = "cols_leafsGreen",
                colors = new List <Color> {
                    new Color(161 / 255f, 195 / 255f, 73 / 255f, 1f),
                    new Color(135 / 255f, 163 / 255f, 48 / 255f, 1f),
                    new Color(189 / 255f, 198 / 255f, 103 / 255f, 1f)
                }
            });
            Defs.AddColorPalette(new ColorPaletteDef {
                uid    = "cols_leafsOrange",
                colors = new List <Color> {
                    new Color(187 / 255f, 102 / 255f, 0 / 255f, 1f),
                    new Color(170 / 255f, 80 / 255f, 66 / 48f, 1f),
                    new Color(186 / 255f, 90 / 255f, 49 / 255f, 1f)
                }
            });
            Defs.AddColorPalette(new ColorPaletteDef {
                uid    = "cols_wood",
                colors = new List <Color> {
                    new Color(112 / 255f, 78 / 255f, 46 / 255f, 1f),
                    new Color(54 / 255f, 48 / 255f, 32 / 48f, 1f)
                }
            });
        }
Exemple #9
0
        /// Load all plant definitions
        public static void LoadMenuOrdersFromCode()
        {
            Defs.orders = new Dictionary <string, MenuOrderDef>();

            Defs.AddMenuOrder(
                new MenuOrderDef {
                uid        = "cancel",
                name       = "Cancel orders",
                shortDesc  = "Cancel all orders is a designated area",
                selector   = SelectorType.AreaTile,
                layer      = Layer.Orders,
                sprite     = Res.sprites["order_to_cancel"],
                actionArea = (RectI rect) => {
                    foreach (Vector2Int position in rect)
                    {
                        foreach (Tilable tilable in Loki.map.GetAllTilablesAt(position))
                        {
                            tilable.ClearOrder();
                        }
                    }
                },
                keyCode = KeyCode.C,
            }
                );

            Defs.AddMenuOrder(
                new MenuOrderDef {
                uid        = "cut_wood",
                name       = "Cut Wood",
                shortDesc  = "Cut all trees in a designated area.",
                selector   = SelectorType.AreaTile,
                layer      = Layer.Orders,
                sprite     = Res.sprites["order_to_cut"],
                actionArea = (RectI rect) => {
                    foreach (Vector2Int position in rect)
                    {
                        Plant plant = (Plant)Loki.map.grids[Layer.Plant].GetTilableAt(position);
                        if (plant != null && plant.def.cuttable && plant.def.type == TilableType.Tree)
                        {
                            //plant.OrderToCut();
                            plant.AddOrder(Defs.orders["cut_wood"]);
                        }
                    }
                },
                graphics = new GraphicDef {
                    textureName = "order_to_cut"
                },
                keyCode = KeyCode.W,
            }
                );
            Defs.AddMenuOrder(
                new MenuOrderDef {
                uid        = "cut_plants",
                name       = "Cut Plants",
                layer      = Layer.Orders,
                shortDesc  = "Cut all plants in a designated area.",
                selector   = SelectorType.AreaTile,
                sprite     = Res.sprites["order_to_cut_plant"],
                actionArea = (RectI rect) => {
                    foreach (Vector2Int position in rect)
                    {
                        Plant plant = (Plant)Loki.map.grids[Layer.Plant].GetTilableAt(position);
                        if (plant != null && plant.def.cuttable)
                        {
                            plant.AddOrder(Defs.orders["cut_plants"]);
                        }
                    }
                },
                graphics = new GraphicDef {
                    textureName = "order_to_cut_plant"
                },
                keyCode = KeyCode.D,
            }
                );
            Defs.AddMenuOrder(
                new MenuOrderDef {
                uid        = "harvest_plants",
                name       = "Haverst Plants",
                layer      = Layer.Orders,
                shortDesc  = "Harvest all plants in a designated area.",
                selector   = SelectorType.AreaTile,
                sprite     = Res.sprites["order_harvest"],
                actionArea = (RectI rect) => {
                    foreach (Vector2Int position in rect)
                    {
                        Plant plant = (Plant)Loki.map.grids[Layer.Plant].GetTilableAt(position);
                        if (plant != null && plant.def.cuttable && plant.def.type == TilableType.Plant)
                        {
                            plant.AddOrder(Defs.orders["harvest_plants"]);
                        }
                    }
                },
                graphics = new GraphicDef {
                    textureName = "order_harvest"
                },
                keyCode = KeyCode.H,
            }
                );
        }