Пример #1
0
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);
            CompPropertiesWaterSource propsw = props as CompPropertiesWaterSource;
            if (propsw != null)
            {
                this.props = propsw;
            }

            if (propsw.unlimitedSource)
            {
                propsw.capacity = 999f;
                StoredLitres = 999f;
            }
            else if (propsw.startsWith > 0)
            {
                if (propsw.startsWith > propsw.capacity)
                {
                    propsw.startsWith = propsw.capacity;
                }
                StoredLitres = propsw.startsWith;
            }

            // Assume that any Building that has a CompWaterSource is enough to fulfil
            // concept knowledge about water-producing buildings.
            if (this.parent as Building != null)
            {
                ConceptDatabase.KnowledgeDemonstrated(DefDatabase<ConceptDef>.GetNamedSilentFail("Dehydration_NeedWaterSource"),
                                                      KnowledgeAmount.Total);
            }
        }
Пример #2
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     CompProperties_Charges cprops = props as CompProperties_Charges;
     if (cprops != null)
     {
         this.cprops = cprops;
     }
 }
Пример #3
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     CompPropertiesWaterDrinker propsw = props as CompPropertiesWaterDrinker;
     if (propsw != null)
     {
         this.props = propsw;
     }
 }
Пример #4
0
 public override void Initialize( CompProperties vprops )
 {
     base.Initialize( vprops );
     props = vprops as CompProperties_ManagerStation;
     if ( props == null )
     {
         Log.Warning( "props went horribly wrong." );
         props = new CompProperties_ManagerStation { Speed = 250 };
     }
 }
 public override void Initialize( CompProperties props )
 {
     base.Initialize( props );
     if(
         ( properties != null )&&
         ( !properties.growthLabel.NullOrEmpty() )
     )
     {
         growthLabel = properties.growthLabel;
     }
 }
 public override void Initialize(CompProperties vprops)
 {
     base.Initialize(vprops);
     this.props = (vprops as CompPropertiesAnimalCrypto);
     if (this.props == null)
     {
     #if DEBUG
         Log.Warning("Props went horribly wrong.");
     #endif
         this.props.maxSizeAllowance = 1.5f;
     }
 }
Пример #7
0
 public override void Initialize(CompProperties vprops)
 {
     base.Initialize(vprops);
     this.props = (vprops as CompPropertiesSnow);
     if (this.props == null)
     {
         Log.Warning("Props went horribly wrong.");
         this.props.snowDepth = 1f;
         this.props.snowRadius = 5f;
         this.props.heatSuckMinTemperature = -10f;
         this.props.coldPerSecond = 200f;
     }
 }
Пример #8
0
 public override void Initialize(CompProperties vprops)
 {
     base.Initialize(vprops);
     this.reloaderProp = (vprops as CompProperties_Reloader);
     if (this.reloaderProp != null)
     {
         this.count = this.reloaderProp.roundPerMag;
     }
     else
     {
         Log.Warning("Could not find a CompProperties_Reloader for CompReloader.");
         this.count = 9876;
     }
 }
Пример #9
0
        //provides a new Compglower
        public static CompGlower newCompGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius)
        {
            CompGlower Comp_NewGlower = new CompGlower();
            Comp_NewGlower.parent = parent;


            CompProperties CompProp_New = new CompProperties();
            CompProp_New.compClass = typeof(CompGlower);
            CompProp_New.glowColor = glowColour;
            CompProp_New.glowRadius = glowRadius;

            Comp_NewGlower.Initialize(CompProp_New);

            return Comp_NewGlower;
        }
Пример #10
0
 public override void Initialize(CompProperties vprops)
 {
     base.Initialize(vprops);
     this.compProp = (vprops as CompProperties_ExtraDamage);
     if (this.compProp != null)
     {
         this.damageDef = this.compProp.damageDef;
         this.damageAmount = this.compProp.damageAmount;
         this.chanceToProc = this.compProp.chanceToProc;
     }
     else
     {
         Log.Warning("Could not find a CompProperties_ExtraDamage for CompExtraDamage.");
         this.count = 9876;
     }
 }
Пример #11
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     flickComp = parent.GetComp <CompFlickable>();
 }
Пример #12
0
        public override void Initialize(CompProperties props)
        {
            var providerProps = (CompPowerProviderProperties)props;

            _provider = new PowerProvider(providerProps.maxEnergy, providerProps.maxRate, providerProps.maxEnergy, this);
        }
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="props"></param>
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     DmgAmount = dmgAmount;
 }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     SetDefaultTargetMineral();
 }
Пример #15
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     this.numberOfMoons = Current.Game.GetComponent <Gamecomp_SatellitesInOrbit>().numberOfSatellites;
 }
        public void ChangeColor( int index )
        {
            ColorInt colour = ColorProps.color[ index ].value;
            ColorIndex = index;
            GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc;

            var currentGlower = CompGlower;

            // Current lit state from existing glower
            bool wasLit = currentGlower.Lit;

            // Turn off glower
            currentGlower.Lit = false;

            // New glower
            var newGlower = new CompGlower();
            if( newGlower == null )
            {
                Log.Error( "Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to create new CompGlower!" );
                return;
            }
            newGlower.parent = parent;

            // Glower properties
            var newProps = new CompProperties();
            if( newProps == null )
            {
                Log.Error( "Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to create new CompProperties!" );
                return;
            }
            newProps.compClass = typeof( CompGlower );
            newProps.glowColor = colour;
            newProps.glowRadius = lightRadius;

            // Add properties to glower
            newGlower.Initialize( newProps );

            // Fetch the comps list
            var allComps = parent.GetComps();
            if( allComps == null )
            {
                Log.Error( "Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to get list of comps!" );
                return;
            }

            // Remove existing glower
            allComps.Remove( currentGlower );

            // Add new glower
            allComps.Add( newGlower );

            // Store comps list
            parent.SetComps( allComps );

            // Update glow grid
            newGlower.Lit = false;
            Find.GlowGrid.MarkGlowGridDirty( parent.Position );
            Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.GroundGlow );
            Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.Things );

            // Turn light on if appropriate
            newGlower.Lit |= ( wasLit ) && ( PowerTrader.PowerOn );
        }
Пример #17
0
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);

            wearTicks = Props.workTicksPerHealthPercent;
        }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     prop = (CompProperties_UseResearchTechBlueprint)props;
 }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     wakeUpSignalTag = Props.wakeUpSignalTag;
 }
Пример #20
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     prop = (Prop.VoidNetTempControllerProp)props;
 }
Пример #21
0
        public override void Initialize(CompProperties initialProps)
        {
            base.Initialize(initialProps);

            AddCustomHediffs();
        }
Пример #22
0
 /// <summary>Initializes this instance with the specified properties.</summary>
 /// <param name="props">The properties.</param>
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     Assert(parent is Pawn, "parent is Pawn");
 }
Пример #23
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     LongEventHandler.ExecuteWhenFinished(InitTurret);
 }
Пример #24
0
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);

            carrier = parent as Pawn;
        }
Пример #25
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     LongEventHandler.ExecuteWhenFinished(InitAvailableFireModes);
 }
        public void changeColor(int index)
        {
            ColorInt colour = compProps.color[index].value;

            ColorIndex = index;
            GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc;

            // Current lit state from base compGlower
            bool wasLit = oldGlower.Lit;

            // Turn off old glower
            oldGlower.Lit = false;

            // Turn off replaced glower
            if (compGlower != null)
            {
                // Current lit state from base replacement compGlower
                wasLit = compGlower.Lit;

                // Turn off replacement compGlower
                compGlower.Lit = false;
            }

            // New glower
            CompGlower newGlower = new CompGlower();

            if (newGlower == null)
            {
                Log.Message(parent.def.defName + " - Unable to create new compGlower!");
                return;
            }
            newGlower.parent = parent;

            // Glower properties
            CompProperties newProps = new CompProperties();

            if (newProps == null)
            {
                Log.Message(parent.def.defName + " - Unable to create new compProperties!");
                return;
            }
            newProps.compClass  = typeof(CompGlower);
            newProps.glowColor  = colour;
            newProps.glowRadius = lightRadius;

            // Add properties to glower
            newGlower.Initialize(newProps);


            // Fetch the comps list
            List <ThingComp> allComps = typeof(ThingWithComps).GetField("comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(parent) as List <ThingComp>;

            if (allComps == null)
            {
                Log.Message(parent.def.defName + " - Could not get list of comps!");
                return;
            }


            // Remove default glower
            allComps.Remove(oldGlower);

            // Remove current glower
            if (compGlower != null)
            {
                allComps.Remove(compGlower);
            }

            // Add new glower
            allComps.Add(newGlower);
            compGlower = newGlower;

            // Store comps list
            typeof(ThingWithComps).GetField("comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(parent, allComps);


            // Update glow grid
            compGlower.Lit = false;
            Find.GlowGrid.MarkGlowGridDirty(parent.Position);
            Find.MapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.GroundGlow);
            Find.MapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.Things);

            if ((wasLit) && (compPower.PowerOn))
            {
                // Turn it on if it the old glower was on
                compGlower.Lit = true;
            }
        }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     forcedHandler = new SurvivalToolForcedHandler();
 }
Пример #28
0
 public override void Initialize(CompProperties p)
 {
     base.Initialize(p);
     customProps = (CompProperties_ChemicalExplosive)p;
 }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     this.colorOne = Color.HSVToRGB(Rand.Value, 1, 1);
     this.colorTwo = Color.HSVToRGB(Rand.Value, 1, 1);
 }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     this.skill = DefDatabase <SkillDef> .GetRandom();
 }
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);

            EnergyPercentageRange = new FloatRange(Props.lowerEnergyPercentage, Props.upperEnergyPercentage);
        }
Пример #32
0
 public override void Initialize(CompProperties compProperties)
 {
     base.Initialize(compProperties);
     SetRadius = Props.maxRadius;
 }
Пример #33
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     //SetLookAround();
 }
Пример #34
0
 /// <summary>
 /// called to initialize this comp
 /// </summary>
 /// <param name="props">The props.</param>
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
 }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     prop = (CompProp_UseVoidEnergyBeginning_Key)props;
 }
Пример #36
0
        private void InjectOverridesIntoPawns()
        {
            var thingDefsToInjectInto = DefDatabase<ThingDef>.AllDefs.Where( thingDef => (
                ( thingDef.inspectorTabs != null ) &&
                ( thingDef.inspectorTabs.Contains( typeof( RimWorld.ITab_Pawn_Prisoner ) ) )
            ) ).ToList();

            foreach( var thingDef in thingDefsToInjectInto )
            {
                thingDef.inspectorTabs.Remove( typeof( RimWorld.ITab_Pawn_Prisoner ) );
                thingDef.inspectorTabs.Add( typeof( ITab_Pawn_Prisoner ) );

                if( thingDef.inspectorTabsResolved != null )
                {
                    foreach( var iTab in thingDef.inspectorTabsResolved )
                    {
                        if( iTab is RimWorld.ITab_Pawn_Prisoner )
                        {
                            thingDef.inspectorTabsResolved.Remove( iTab );
                            break;
                        }
                    }
                    thingDef.inspectorTabsResolved.Add( ITabManager.GetSharedInstance( typeof( ITab_Pawn_Prisoner ) ) );
                }

                if( thingDef.comps == null )
                {
                    thingDef.comps = new List<CompProperties>();
                }
                if( !thingDef.HasComp( typeof( CompPrisoner ) ) )
                {
                    var compProperties = new CompProperties();
                    compProperties.compClass = typeof( CompPrisoner );
                    thingDef.comps.Add( compProperties );
                }
            }
        }
Пример #37
0
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);

            this.SetupThingWithCompsSpawnVehicleDef();
        }
        public override void Initialize(CompProperties p)
        {
            base.Initialize(p);

            this.doAutoAttack = DefaultAutoAttack;
        }
Пример #39
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     GeneticInformation = ParentReferences.ThisGeneticInformation ?? new GeneticInformation();
 }
Пример #40
0
        public override void Initialize(CompProperties props)
        {
            base.Initialize(props);
            Pawn pawn = this.parent as Pawn;

            if (!initialized)
            {
                this.hasEnchantment = this.Props.hasEnchantment;
                if (!this.hasEnchantment)
                {
                    this.hasEnchantment = this.MadeFromEnchantedStuff;
                }

                this.arcaneDmg     = this.Props.arcaneDmg;
                this.arcaneDmgTier = this.Props.arcaneDmgTier;
                this.arcaneRes     = this.Props.arcaneRes;
                this.arcaneResTier = this.Props.arcaneResTier;

                this.maxMP           = this.Props.maxMP;
                this.maxMPTier       = this.Props.maxMPTier;
                this.mpRegenRate     = this.Props.mpRegenRate;
                this.mpRegenRateTier = this.Props.mpRegenRateTier;
                this.coolDown        = this.Props.coolDown;
                this.coolDownTier    = this.Props.coolDownTier;
                this.mpCost          = this.Props.mpCost;
                this.mpCostTier      = this.Props.mpCostTier;
                this.xpGain          = this.Props.xpGain;
                this.xpGainTier      = this.Props.xpGainTier;

                if (MadeFromEnchantedStuff && this.EnchantedStuff != null)
                {
                    this.maxMP       += this.EnchantedStuff.maxEnergyOffset;
                    this.mpRegenRate += this.EnchantedStuff.energyRegenOffset;
                    this.coolDown    += this.EnchantedStuff.cooldownOffset;
                    this.mpCost      += this.EnchantedStuff.energyCostOffset;
                    this.xpGain      += this.EnchantedStuff.xpGainOffset;
                    this.arcaneRes   += this.EnchantedStuff.arcaneResOffset;
                    this.arcaneDmg   += this.EnchantedStuff.arcaneDmgOffset;
                }

                this.healthRegenRate = this.Props.healthRegenRate;

                this.enchantmentAction  = this.Props.enchantedAction;
                this.arcaneSpectre      = this.Props.arcaneSpectre;
                this.phantomShift       = this.Props.phantomShift;
                this.arcalleumCooldown  = this.Props.arcalleumCooldown;
                this.enchantmentThought = this.Props.enchantmentThought;

                this.skillTier = this.Props.skillTier;

                this.hediff         = this.Props.hediff;
                this.hediffSeverity = this.Props.hediffSeverity;

                if (this.parent.def.tickerType == TickerType.Rare)
                {
                    Find.TickManager.RegisterAllTickabilityFor(this.parent);
                }

                if (this.parent.def.tickerType == TickerType.Never)
                {
                    this.parent.def.tickerType = TickerType.Rare;
                    Find.TickManager.RegisterAllTickabilityFor(this.parent);
                }

                if (this.Props.hasAbility && !abilitiesInitialized)
                {
                    InitializeAbilities(this.parent as Apparel);
                }

                this.initialized = true;
            }
        }
Пример #41
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     this.fuel      = this.Props.fuelCapacity * this.Props.initialFuelPercent;
     this.flickComp = this.parent.GetComp <CompFlickable>();
 }
        public void changeColor( int index )
        {
            ColorInt colour = compProps.color[ index ].value;
            ColorIndex = index;
            GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc;

            // Current lit state from base compGlower
            bool wasLit = oldGlower.Lit;

            // Turn off old glower
            oldGlower.Lit = false;

            // Turn off replaced glower
            if( compGlower != null )
            {
                // Current lit state from base replacement compGlower
                wasLit = compGlower.Lit;

                // Turn off replacement compGlower
                compGlower.Lit = false;
            }

            // New glower
            CompGlower newGlower = new CompGlower();
            if( newGlower == null )
            {
                Log.Message( parent.def.defName + " - Unable to create new compGlower!" );
                return;
            }
            newGlower.parent = parent;

            // Glower properties
            CompProperties newProps = new CompProperties();
            if( newProps == null )
            {
                Log.Message( parent.def.defName + " - Unable to create new compProperties!" );
                return;
            }
            newProps.compClass = typeof( CompGlower );
            newProps.glowColor = colour;
            newProps.glowRadius = lightRadius;

            // Add properties to glower
            newGlower.Initialize( newProps );

            // Fetch the comps list
            List<ThingComp> allComps = typeof( ThingWithComps ).GetField( "comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance ).GetValue( parent ) as List<ThingComp>;
            if( allComps == null )
            {
                Log.Message( parent.def.defName + " - Could not get list of comps!" );
                return;
            }

            // Remove default glower
            allComps.Remove( oldGlower );

            // Remove current glower
            if( compGlower != null )
            {
                allComps.Remove( compGlower );
            }

            // Add new glower
            allComps.Add( newGlower );
            compGlower = newGlower;

            // Store comps list
            typeof( ThingWithComps ).GetField( "comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance ).SetValue( parent, allComps );

            // Update glow grid
            compGlower.Lit = false;
            Find.GlowGrid.MarkGlowGridDirty( parent.Position );
            Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.GroundGlow );
            Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.Things );

            if( ( wasLit )&&( compPower.PowerOn ) )
            {
                // Turn it on if it the old glower was on
                compGlower.Lit = true;
            }
        }
Пример #43
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     gender = Gender.Male;
 }
        // Replace the comp props with a new one with different values
        // must replace comp props as comps share props for things of the
        // same class.  We need to make a unique copy for the building.
        public void ChangeColor( int index )
        {
            ColorInt colour = ColorProps.color[ index ].value;
            ColorIndex = index;
            GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc;

            // Get glower
            var glower = CompGlower;

            // Current lit state of glower
            bool wasLit = glower.Lit;

            // Turn off glower
            glower.Lit = false;

            // New glower properties
            var newProps = new CompProperties();
            if( newProps == null )
            {
                CCL_Log.Error( "CompColoredLight unable to create new CompProperties!", parent.def.defName );
                return;
            }

            // Set the new properties values
            newProps.compClass = typeof( CompGlower );
            newProps.glowColor = colour;
            newProps.glowRadius = lightRadius;

            // Initialize comp with new properties
            glower.Initialize( newProps );

            // Update glow grid
            Find.GlowGrid.MarkGlowGridDirty( parent.Position );
            Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.GroundGlow );
            Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.Things );

            // Turn light on if appropriate
            glower.Lit = wasLit;
        }
        public static void ProductionInfo(ref IEnumerable <StatDrawEntry> __result, RaceProperties __instance, ThingDef parentDef, StatRequest req)
        {
            if (!Settings.extra_display_stats)
            {
                return;
            }

            // Create a modifyable list
            List <StatDrawEntry> NewList = new List <StatDrawEntry>();

            // copy vanilla entries into the new list
            // since original method returns enumerator instead of collection, to actually get values iterator should be iterated; also this method should not be used for enumerators that change condition when called - it may be bad a idea for work givers / drivers
            foreach (StatDrawEntry entry in __result)
            {
                NewList.Add(entry);
            }

            int             startOrder   = 2150;
            StatCategoryDef StatCategory = StatCategoryDefOf.PawnMisc;

            Pawn pawn = null;

            if (req.HasThing && req.Thing is Pawn)
            {
                pawn = (req.Thing as Pawn);
            }

            if (pawn == null)
            {
                return;
            }

            foreach (ThingComp comp in pawn.AllComps)
            {
                CompProperties c = comp.props;
                if (c is CompProperties_Shearable shearable)
                {
                    NewList.Add(new StatDrawEntry(StatCategory, "WoolType".Translate(), shearable.woolDef.LabelCap, "Stat_Race_WoolType_Desc".Translate(), startOrder--, null, new Dialog_InfoCard.Hyperlink[1]
                    {
                        new Dialog_InfoCard.Hyperlink(shearable.woolDef)
                    }));
                    TaggedString woolStat = shearable.woolAmount + " / " + string.Format("{0:0.#}", shearable.shearIntervalDays) + "LetterDay".Translate();
                    if (shearable.shearIntervalDays != 1)
                    {
                        woolStat += " (" + string.Format("{0:0.#}", shearable.woolAmount / shearable.shearIntervalDays) + "/" + "LetterDay".Translate() + ")";
                    }
                    NewList.Add(new StatDrawEntry(StatCategory, "WoolAmount".Translate(), woolStat, "Stat_Race_WoolAmount_Desc".Translate(), startOrder--));
                }
                else if (c is CompProperties_Milkable milkable)
                {
                    NewList.Add(new StatDrawEntry(StatCategory, "MilkType".Translate(), milkable.milkDef.LabelCap, "Stat_Race_MilkType_Desc".Translate(), startOrder--, null, new Dialog_InfoCard.Hyperlink[1]
                    {
                        new Dialog_InfoCard.Hyperlink(milkable.milkDef)
                    }));
                    String milkStat = milkable.milkAmount + " / " + string.Format("{0:0.#}", milkable.milkIntervalDays) + "LetterDay".Translate();
                    if (milkable.milkIntervalDays != 1)
                    {
                        milkStat += " (" + string.Format("{0:0.#}", milkable.milkAmount / milkable.milkIntervalDays) + "/" + "LetterDay".Translate() + ")";
                    }
                    NewList.Add(new StatDrawEntry(StatCategory, "MilkAmount".Translate(), milkStat, "Stat_Race_MilkAmount_Desc".Translate(), startOrder--));
                    NewList.Add(new StatDrawEntry(StatCategory, "MilkFemale".Translate(), milkable.milkFemaleOnly ? "Yes".Translate() : "No".Translate(), "MilkFemaleExplanation".Translate(), startOrder--));
                }
                // catch all for custom comps based on CompHasGatherableBodyResource abstract
                else if (comp is CompHasGatherableBodyResource resource)
                {
                    ThingDef ResourceDef = (ThingDef)AccessTools.Method(comp.GetType(), "get_ResourceDef").Invoke(resource, null);
                    Log.Warning("AL: resource " + ResourceDef);
                    if (ResourceDef == null)
                    {
                        Log.Warning("Animals Logic: " + parentDef.defName + " has a custom comp for body resources but no resource def.");
                        continue;
                    }
                    NewList.Add(new StatDrawEntry(StatCategory, "AL_ResourceType".Translate(), ResourceDef.LabelCap, "AL_ResourceType_Desc".Translate(), startOrder--, null, new Dialog_InfoCard.Hyperlink[1]
                    {
                        new Dialog_InfoCard.Hyperlink(ResourceDef)
                    }));

                    int ResourceAmount = (int)AccessTools.Method(comp.GetType(), "get_ResourceAmount").Invoke(resource, null);
                    int GatherResourcesIntervalDays = (int)AccessTools.Method(comp.GetType(), "get_GatherResourcesIntervalDays").Invoke(resource, null);

                    String resourceStat = ResourceAmount + " / " + string.Format("{0:0.#}", GatherResourcesIntervalDays) + "LetterDay".Translate();
                    if (GatherResourcesIntervalDays != 1)
                    {
                        resourceStat += " (" + string.Format("{0:0.#}", ResourceAmount / GatherResourcesIntervalDays) + "/" + "LetterDay".Translate() + ")";
                    }
                    NewList.Add(new StatDrawEntry(StatCategory, "AL_ResourceAmount".Translate(), resourceStat, "AL_ResourceAmount_Desc".Translate(), startOrder--));
                }

                if (c is CompProperties_EggLayer layer)
                {
                    List <Dialog_InfoCard.Hyperlink> hyperlinks = new List <Dialog_InfoCard.Hyperlink>
                    {
                        new Dialog_InfoCard.Hyperlink(layer.eggFertilizedDef)
                    };
                    if (layer.eggUnfertilizedDef != null && layer.eggUnfertilizedDef != layer.eggFertilizedDef)
                    {
                        hyperlinks.Add(new Dialog_InfoCard.Hyperlink(layer.eggUnfertilizedDef));
                    }

                    NewList.Add(new StatDrawEntry(StatCategory, "EggType".Translate(), layer.eggFertilizedDef.LabelCap, "Stat_Race_EggType_Desc".Translate(), startOrder--, null, hyperlinks));
                    TaggedString eggsStat = (layer.eggCountRange.min == layer.eggCountRange.max ? layer.eggCountRange.max.ToString() : layer.eggCountRange.ToString())
                                            + " / " + string.Format("{0:0.#}", layer.eggLayIntervalDays) + "LetterDay".Translate();
                    if (layer.eggLayIntervalDays != 1 || layer.eggCountRange.min != layer.eggCountRange.max)
                    {
                        eggsStat += " (" + string.Format("{0:0.#}", layer.eggCountRange.Average / layer.eggLayIntervalDays) + "/" + "LetterDay".Translate() + ")";
                    }
                    NewList.Add(new StatDrawEntry(StatCategory, "EggAmount".Translate(), eggsStat, "Stat_Race_EggAmount_Desc".Translate(), startOrder--));
                    NewList.Add(new StatDrawEntry(StatCategory, "EggFemale".Translate(), layer.eggLayFemaleOnly ? "Yes".Translate() : "No".Translate(), "EggFemaleExplanation".Translate(), startOrder--));
                    NewList.Add(new StatDrawEntry(StatCategory, "EggNeedFertilization".Translate(), layer.eggProgressUnfertilizedMax < 1 ? "Yes".Translate() : "No".Translate(), "EggNeedFertilizationExplanation".Translate(), startOrder--));

                    CompProperties_Hatcher hatcher = layer.eggFertilizedDef.GetCompProperties <CompProperties_Hatcher>();
                    if (hatcher != null)
                    {
                        NewList.Add(new StatDrawEntry(StatCategory, "EggIncubation".Translate(), hatcher.hatcherDaystoHatch + "LetterDay".Translate(), "EggIncubationExplanation".Translate(), startOrder--));
                    }
                }
            }

            // TODO: break it down into explanation of each stage
            if (!__instance.lifeStageAges.NullOrEmpty())
            {
                LifeStageAge matureAge = __instance.lifeStageAges.FirstOrFallback(
                    p => p.def.reproductive || p.def.milkable || p.def.shearable,
                    __instance.lifeStageAges.Last()
                    );

                if (matureAge != null)
                {
                    float age   = matureAge.minAge; // contains number of years as float
                    int   years = (int)age;
                    age %= 1.0f;                    // now contains number of years that is less than 1
                    int days = (int)(age * 60);
                    age = (age * 60) % 1.0f;        // now contains number of days that is less than 1
                    int hours = (int)age * 24;

                    String matureAgeString      = ""; // unused now
                    String matureAgeStringShort = "";

                    if (years > 1)
                    {
                        matureAgeString      += "PeriodYears".Translate(years);
                        matureAgeStringShort += years + "LetterYear".Translate();
                    }
                    if (years == 1)
                    {
                        matureAgeString      += "Period1Year".Translate();
                        matureAgeStringShort += 1 + "LetterYear".Translate();
                    }

                    if (days > 1)
                    {
                        if (years > 0)
                        {
                            matureAgeString      += " ";
                            matureAgeStringShort += " ";
                        }
                        matureAgeString      += "PeriodDays".Translate(days);
                        matureAgeStringShort += days + "LetterDay".Translate();
                    }
                    if (days == 1)
                    {
                        if (years > 0)
                        {
                            matureAgeString      += " ";
                            matureAgeStringShort += " ";
                        }
                        matureAgeString      += "Period1Day".Translate();
                        matureAgeStringShort += 1 + "LetterDay".Translate();
                    }

                    if (hours > 1)
                    {
                        if (years + hours > 0)
                        {
                            matureAgeString      += " ";
                            matureAgeStringShort += " ";
                        }
                        matureAgeString      += "PeriodHours".Translate(hours);
                        matureAgeStringShort += hours + "LetterHour".Translate();
                    }
                    if (hours == 1)
                    {
                        if (years + hours > 0)
                        {
                            matureAgeString      += " ";
                            matureAgeStringShort += " ";
                        }
                        matureAgeString      += "Period1Hour".Translate();
                        matureAgeStringShort += 1 + "LetterHour".Translate();
                    }

                    NewList.Add(new StatDrawEntry(StatCategory, "TimeToMature".Translate(), matureAgeStringShort, "TimeToMatureExplanation".Translate(), startOrder--));
                }

                LifeStageAge reproductiveAge = __instance.lifeStageAges.Find(
                    p => p.def.reproductive
                    );

                if (__instance.hasGenders && reproductiveAge != null && !parentDef.HasComp(typeof(CompEggLayer)))
                {
                    NewList.Add(new StatDrawEntry(StatCategory, "GestationPeriod".Translate(), String.Format("{0:0.#}", __instance.gestationPeriodDays) + "LetterDay".Translate(), "GestationPeriodExplanation".Translate(), startOrder--));

                    float  litterAvg  = 1f;
                    String litterSize = "1";

                    if (__instance.litterSizeCurve != null && Math.Max(1, __instance.litterSizeCurve.First().x) != Math.Max(1, __instance.litterSizeCurve.Last().x))
                    {
                        litterAvg  = Rand.ByCurveAverage(__instance.litterSizeCurve);
                        litterAvg  = Math.Max(1, litterAvg);
                        litterSize = Math.Max(1, __instance.litterSizeCurve.First().x) + "~" + Math.Max(1, __instance.litterSizeCurve.Last().x) + " (" + String.Format("{0:0.#}", litterAvg) + ")";
                    }
                    NewList.Add(new StatDrawEntry(StatCategory, "LitterSize".Translate(), litterSize, "LitterSizeExplanation".Translate(), startOrder--));
                }
            }

            // convert list to IEnumerable to match the caller's expectations
            IEnumerable <StatDrawEntry> output = NewList;

            // make caller use the list
            __result = output;
        }
Пример #46
0
        public void                         ChangeColor(int index)
        {
            ColorInt colour = ColorProps.color[index].value;

            ColorIndex = index;
            GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc;

            var currentGlower = CompGlower;

            // Current lit state from existing glower
            bool wasLit = currentGlower.Lit;

            // Turn off glower
            currentGlower.Lit = false;

            // New glower
            var newGlower = new CompGlower();

            if (newGlower == null)
            {
                Log.Error("Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to create new CompGlower!");
                return;
            }
            newGlower.parent = parent;

            // Glower properties
            var newProps = new CompProperties();

            if (newProps == null)
            {
                Log.Error("Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to create new CompProperties!");
                return;
            }
            newProps.compClass  = typeof(CompGlower);
            newProps.glowColor  = colour;
            newProps.glowRadius = lightRadius;

            // Add properties to glower
            newGlower.Initialize(newProps);

            // Fetch the comps list
            var allComps = parent.GetComps();

            if (allComps == null)
            {
                Log.Error("Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to get list of comps!");
                return;
            }

            // Remove existing glower
            allComps.Remove(currentGlower);

            // Add new glower
            allComps.Add(newGlower);

            // Store comps list
            parent.SetComps(allComps);


            // Update glow grid
            newGlower.Lit = false;
            Find.GlowGrid.MarkGlowGridDirty(parent.Position);
            Find.MapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.GroundGlow);
            Find.MapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.Things);

            // Turn light on if appropriate
            newGlower.Lit |= (wasLit) && (PowerTrader.PowerOn);
        }
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     weather = base.Props.conditionDef.weatherDef;
 }