Exemplo n.º 1
0
        private static ThingDef BaseSlimeDef(SlimeGeneratorDef slimeGenerator)
        {
            var thingDef = new ThingDef();

            foreach (var fieldInfo in typeof(ThingDef).GetFields())
            {
                try
                {
                    var newField = thingDef.GetType().GetField(fieldInfo.Name);
                    newField.SetValue(thingDef, fieldInfo.GetValue(slimeGenerator.slimeTypeDef.originThingDef));
                }
                catch { }
            }
            thingDef.defName = slimeGenerator.defName;
            thingDef.label   = slimeGenerator.label;
            if (slimeGenerator.description?.Length > 0)
            {
                thingDef.description = slimeGenerator.description;
            }
            else
            {
                thingDef.description = slimeGenerator.slimeTypeDef.originThingDef.description;
            }
            AssignNewVariables(ref thingDef, slimeGenerator.slimeTypeDef.originThingDef);
            AdjustStatBases(ref thingDef, slimeGenerator.statModifiers);
            if (slimeGenerator.butcherThings.butcherBasic != null)
            {
                thingDef.butcherProducts = slimeGenerator.butcherThings.butcherBasic;
            }
            if (slimeGenerator.butcherThings.butcherSpecialized != null)
            {
                var compProperties = new CompProperties_ExtraButcherProducts
                {
                    butcherSpecialized = slimeGenerator.butcherThings.butcherSpecialized
                };
                thingDef.comps.Add(compProperties);
            }
            if (slimeGenerator.slimeTypeDef.growthStages != null)
            {
                var compProperties = new CompProperties_ExtraGraphics
                {
                    growthStages        = slimeGenerator.slimeTypeDef.growthStages,
                    totalAbsorbableMass = slimeGenerator.slimeTypeDef.totalAbsorbableMass
                };
                thingDef.comps.Add(compProperties);
            }
            return(thingDef);
        }
Exemplo n.º 2
0
        private static PawnKindDef BaseSlimeKindDef(SlimeGeneratorDef slimeGenerator)
        {
            var pawnKind = new PawnKindDef();

            foreach (var fieldInfo in typeof(PawnKindDef).GetFields())
            {
                try
                {
                    var newField = pawnKind.GetType().GetField(fieldInfo.Name);
                    newField.SetValue(pawnKind, fieldInfo.GetValue(slimeGenerator.slimeTypeDef.originPawnKind));
                }
                catch { }
            }
            AssignNewVariables(ref pawnKind, slimeGenerator.slimeTypeDef.originPawnKind);
            pawnKind.defName = slimeGenerator.defName;
            pawnKind.label   = slimeGenerator.label;
            if (slimeGenerator.description?.Length > 0)
            {
                pawnKind.description = slimeGenerator.description;
            }
            else
            {
                pawnKind.description = slimeGenerator.slimeTypeDef.originThingDef.description;
            }
            foreach (var lifeStage in pawnKind.lifeStages)
            {
                if (slimeGenerator.color != null)
                {
                    lifeStage.bodyGraphicData.color = new Color(slimeGenerator.color.r, slimeGenerator.color.g, slimeGenerator.color.b, slimeGenerator.color.a);
                }
                else
                {
                    lifeStage.bodyGraphicData.color = new Color(slimeGenerator.sourceThingDef.stuffProps.color.r, slimeGenerator.sourceThingDef.stuffProps.color.g,
                                                                slimeGenerator.sourceThingDef.stuffProps.color.b, slimeGenerator.sourceThingDef.stuffProps.color.a);
                }
            }
            Utils.slimePawnKindDefs.Add(pawnKind);
            return(pawnKind);
        }