Example #1
0
        private void AnimalPawnCompsBodyDefImport()
        {
            // ReSharper disable once PossibleNullReferenceException
            foreach (BodyAnimDef def in DefDatabase <BodyAnimDef> .AllDefsListForReading)
            {
                string target = def.thingTarget;
                if (target.NullOrEmpty())
                {
                    continue;
                }

                ThingDef thingDef = ThingDef.Named(target);
                if (thingDef == null)
                {
                    continue;
                }
                //if (DefDatabase<BodyAnimDef>
                //   .AllDefsListForReading.Any(x => x.defName.Contains(thingDef.defName))) continue;
                if (thingDef.HasComp(typeof(CompBodyAnimator)))
                {
                    continue;
                }

                CompProperties_BodyAnimator animator = new CompProperties_BodyAnimator
                {
                    compClass      = typeof(CompBodyAnimator),
                    bodyDrawers    = def.bodyDrawers,
                    handType       = def.handType,
                    quadruped      = def.quadruped,
                    bipedWithHands = def.bipedWithHands
                };

                thingDef.comps?.Add(animator);
            }
        }
Example #2
0
        private void AnimalPawnCompsImportFromAnimationTargetDefs()
        {
            // ReSharper disable once PossibleNullReferenceException
            foreach (AnimationTargetDef def in DefDatabase <AnimationTargetDef> .AllDefsListForReading)
            {
                if (def.CompLoaderTargets.NullOrEmpty())
                {
                    continue;
                }

                foreach (CompLoaderTargets pawnSets in def.CompLoaderTargets)
                {
                    if (pawnSets == null)
                    {
                        continue;
                    }

                    if (pawnSets.thingTargets.NullOrEmpty())
                    {
                        continue;
                    }

                    foreach (string target in pawnSets.thingTargets)
                    {
                        ThingDef thingDef = ThingDef.Named(target);
                        if (thingDef == null)
                        {
                            continue;
                        }
                        //if (DefDatabase<BodyAnimDef>
                        //   .AllDefsListForReading.Any(x => x.defName.Contains(thingDef.defName))) continue;
                        if (thingDef.HasComp(typeof(CompBodyAnimator)))
                        {
                            continue;
                        }

                        CompProperties_BodyAnimator bodyAnimator = new CompProperties_BodyAnimator
                        {
                            compClass   = typeof(CompBodyAnimator),
                            bodyDrawers = pawnSets.bodyDrawers,
                            handType    = pawnSets.handType,
                            // footType = pawnSets.footType,
                            // pawType = pawnSets.pawType,
                            quadruped      = pawnSets.quadruped,
                            bipedWithHands = pawnSets.bipedWithHands
                        };
                        thingDef.comps?.Add(bodyAnimator);
                    }
                }
            }

            this.LaserLoad();
        }