示例#1
0
        void Awake()
        {
            var comp = parent.Map?.GetComponent <MorphTracker>();

            if (comp == null)
            {
                MorphGroupDef group    = parent.def.GetMorphOfRace()?.@group;
                var           aTracker = Pawn.GetAspectTracker();
                if (aTracker == null)
                {
                    return;
                }
                var aspectDef = group?.aspectDef;
                if (aspectDef == null)
                {
                    return;
                }

                var aspect = aTracker.GetAspect(aspectDef);
                if (aspect == null)
                {
                    aspect = aspectDef.CreateInstance();

                    //add an small offset so minSeverity in hediffStages works as expected
                    aTracker.Add(aspect);
                }
            }
        }
示例#2
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;
        }
示例#3
0
        /// <summary> Get the number of morphs belonging to the given group active in the map. </summary>
        public int GetGroupCount([NotNull] MorphGroupDef group)
        {
            if (group == null)
            {
                throw new ArgumentNullException(nameof(group));
            }
            int counter = 0;

            foreach (MorphDef morphDef in group.MorphsInGroup)
            {
                counter += this[morphDef];
            }

            return(counter);
        }
示例#4
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);
        }