Exemple #1
0
        private void RecalculateMorphCount(MorphTracker tracker)
        {
            MorphDef      myMorph       = parent.def.GetMorphOfRace();
            AspectTracker aspectTracker = Pawn.GetAspectTracker();

            if (aspectTracker == null)
            {
                return;
            }
            MorphGroupDef group     = myMorph?.group;
            AspectDef     aspectDef = group?.aspectDef;

            if (aspectDef == null)
            {
                return;
            }

            Aspect aspect = aspectTracker.GetAspect(aspectDef);

            if (aspect == null) //if the hediff is missing for some reason add it again
            {
                aspect = aspectDef.CreateInstance();
                aspectTracker.Add(aspect);
            }

            aspect.StageIndex = tracker.GetGroupCount(group) - 1;
        }
Exemple #2
0
        private int GetFeralPawnInfluence([NotNull] MorphTracker tracker, [NotNull] MorphGroupDef group)
        {
            if (Pawn?.Faction == null)
            {
                return(0);
            }
            var animals = tracker.map.mapPawns.SpawnedPawnsInFaction(Pawn.Faction);
            int counter = 0;

            foreach (Pawn animal in animals.MakeSafe())
            {
                if (group.AnimalRaces.Contains(animal.def))
                {
                    counter++;
                }
            }

            return(counter);
        }
Exemple #3
0
        private void MorphCountChanged(MorphTracker sender, MorphDef morph)
        {
            MorphDef myMorph = parent.def.GetMorphOfRace();

            if (myMorph?.group == null)
            {
                return;
            }
            if (myMorph.group != morph?.group)
            {
                return;
            }

            var           pawn          = (Pawn)parent;
            AspectTracker aspectTracker = pawn.GetAspectTracker();

            if (aspectTracker == null)
            {
                return;
            }
            AspectDef aspectDef = morph?.group?.aspectDef;

            if (aspectDef == null)
            {
                return;
            }

            Aspect aspect = aspectTracker.GetAspect(aspectDef);

            if (aspect == null) //if the aspect is missing for some reason add it again
            {
                aspect = aspectDef.CreateInstance();
                aspectTracker.Add(aspect);
            }

            var comp = pawn.Map?.GetComponent <MorphTracker>();

            aspect.StageIndex = (comp?.GetGroupCount(morph.group) ?? 0) - 1;
            //stage should always be equal to the number of morphs in the group active in the same map
        }