예제 #1
0
        protected AnimalRecord CreateAnimalRecord(ThingDef def, Gender gender)
        {
            double baseCost = costCalculator.GetBaseThingCost(def, null);

            if (baseCost == 0)
            {
                return(null);
            }

            AnimalRecord result = new AnimalRecord();

            result.ThingDef = def;
            result.Gender   = gender;
            result.Cost     = baseCost;
            try {
                Pawn pawn = CreatePawn(def, gender);
                if (pawn == null)
                {
                    return(null);
                }
                else
                {
                    result.Thing = pawn;
                }
            }
            catch (Exception e) {
                Logger.Warning("Failed to create a pawn for animal database record: " + def.defName, e);
                return(null);
            }
            return(result);
        }
예제 #2
0
 protected void AddAnimalRecord(AnimalRecord animal)
 {
     if (!animalDictionary.ContainsKey(animal.Key))
     {
         animals.Add(animal);
         animalDictionary.Add(animal.Key, animal);
     }
 }
        public void AddAnimal(AnimalRecord record)
        {
            SelectedAnimal existingAnimal = FindSelectedAnimal(record.Key);

            if (existingAnimal != null)
            {
                existingAnimal.Count++;
            }
            else
            {
                SelectedAnimal animal = new SelectedAnimal();
                animal.Record = record;
                animal.Count  = 1;
                animals.Add(animal);
            }
        }
예제 #4
0
 protected void Initialize()
 {
     foreach (var def in DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => {
         if (def.race != null && def.race.Animal == true)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }))
     {
         if (def.race.hasGenders)
         {
             AnimalRecord femaleRecord = CreateAnimalRecord(def, Gender.Female);
             if (femaleRecord != null)
             {
                 AddAnimalRecord(femaleRecord);
             }
             AnimalRecord maleRecord = CreateAnimalRecord(def, Gender.Male);
             if (maleRecord != null)
             {
                 AddAnimalRecord(maleRecord);
             }
         }
         else
         {
             AnimalRecord record = CreateAnimalRecord(def, Gender.None);
             if (record != null)
             {
                 AddAnimalRecord(record);
             }
         }
     }
 }
 public static void Draw(Rect rect, AnimalRecord animal)
 {
     Draw(rect, animal.Thing, Color.white);
 }