Beispiel #1
0
        public static List <LayerPalettePair> BuildDwarfLayers(CreatureStats Stats, Random Random)
        {
            var r = new List <LayerPalettePair>();

            foreach (var layerType in LayerLibrary.EnumerateLayerTypes())
            {
                if (layerType.Fundamental)
                {
                    if (r.Any(l => l.Layer.Type == layerType.Name))
                    {
                        continue;
                    }

                    if (layerType.Gendered && Stats.Gender != Gender.Nonbinary)
                    {
                        r.Add(new LayerPalettePair {
                            Layer = SelectRandomLayer(Stats, Random, layerType.Name, l => l.Names.Contains(Stats.Gender.ToString())), Palette = null
                        });
                    }
                    else
                    {
                        r.Add(new LayerPalettePair {
                            Layer = SelectRandomLayer(Stats, Random, layerType.Name), Palette = null
                        });
                    }
                }
            }

            return(r);
        }
Beispiel #2
0
 private int GetLayerPrecedence(Layer Layer)
 {
     if (LayerLibrary.GetLayerType(Layer.Type).HasValue(out var type))
     {
         return(type.Precedence);
     }
     return(0);
 }
Beispiel #3
0
        private static Layer FindLayerOrDefault(String Type, String Name)
        {
            var r = LayerLibrary.EnumerateLayersOfType(Type).Where(l => l.Names.Contains(Name)).FirstOrDefault();

            if (r == null)
            {
                r = LayerLibrary.EnumerateLayersOfType(Type).Where(l => l.Names.Contains("default")).FirstOrDefault();
            }
            return(r);
        }
Beispiel #4
0
 public static void AssignPalettes(Dictionary <String, Palette> ChosenPalettes, List <LayerPalettePair> Layers)
 {
     foreach (var layer in Layers)
     {
         if (layer.Palette == null)
         {
             if (LayerLibrary.GetLayerType(layer.Layer.Type).HasValue(out var layerType) && ChosenPalettes.ContainsKey(layerType.PaletteType))
             {
                 layer.Palette = ChosenPalettes[layerType.PaletteType];
             }
             else
             {
                 layer.Palette = LayerLibrary.BasePalette;
             }
         }
     }
Beispiel #5
0
        private static Layer SelectRandomLayer(CreatureStats Stats, Random Random, String Type, Func <Layer, bool> Filter = null)
        {
            if (Filter == null)
            {
                Filter = __pass;
            }

            var layers = LayerLibrary.EnumerateLayersOfType(Type).Where(l => Filter(l));

            if (layers.Count() > 0)
            {
                return(layers.SelectRandom(Random));
            }
            else
            {
                return(LayerLibrary.EnumerateLayersOfType(Type).Where(l => l.Names.Contains("default")).FirstOrDefault());
            }
        }
Beispiel #6
0
 private static Layer FindLayer(String Type, String Name)
 {
     return(LayerLibrary.EnumerateLayersOfType(Type).Where(l => l.Names.Contains(Name)).FirstOrDefault());
 }