Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - aRandomKiwi

#16
Help / Re: How do I access disease defs in C# code?
November 20, 2018, 09:50:16 PM
Hi,

Try with that :


HediffDef disease = DefDatabase<HediffDef>.GetNamed("SensoryMechanites");   // in parameter here the defName of your desease
//and then :
HediffGiverUtility.TryApply(pawn, disease, ...);


Generally all def class can be accessed with DefDatabase<DefClass>.GetNamed("defNameHere");
#17
Help / Bug in GameComponents ?
November 19, 2018, 01:52:27 PM
Hi,

Can someone explain me why the constructor of implemented GameComponents class are called 4 times (instanciate 4 times ?) ? Is it a normal behavior ?

Because i noticed that when i try to access the GameComponent instance with " Instance = (GameComponent_Test) Current.Game.components.Find(x => x is GameComponent_Test); i get sometimes different instance (not the same properties i changed earlier), so to solve this i get only once time the reference instance and store it in a public static class.


Reproduce :
Simply implement a dumb GameComponent with alert in constructor :


public class GameComponent_X: GameComponent
    {
        public GameComponent_X(Game game)
        {
            Log.Message("Test");
        }

        public GameComponent_X()
        {
            Log.Message("Test");
        }
}


Thanks
#18
It seem this occure because the Building_Cooler class dont call the base.TickRare() method of mother class "ThingWithComps", so the loop calling "CompTickRare()" method of all components stored in comps property is never called, it's not a consistent behavior, sometimes the "tickerType" def tag is applied for the Thing AND ThingComp, and sometimes nope only for the Thing class.

So unless messing with Harmony's C# expert transpiler stuff to patch the overrided TickRare or making an ugly workaround (eg : GameComp, ...) it's not possible.

#19
Hi,

Is it normal that "CompTickRare()" of a custom CompThing appended with a Patch to Vanilla Coolers (Building_Cooler) is never called ?
I watched  the def file of the cooler, and there is a "<tickerType>Rare</tickerType>" so i dont undestand why this dont work, is there any way to get this method called ?

The patch work because i overrided the "CompInspectStringExtra()" of the custom ComThing and i can see the text returned on the Cooler.


Thanks
#20
Solved by avoiding using the "soundAmbient" building subtag of the building ThinDef and by handling manualy with custom CompThing and "ReceiveCompSignal" method ( play sound with  SoundDef.Named( <soundNameHere> ).startSustainer() ....).
#21
Help / Re: Disable/Enable Gizmo in a building ?
November 16, 2018, 01:01:25 PM
Resolved with a harmony prefix patch to "CompTempControl.CompGetGizmosExtra" method.
#22
I have my response, by implementing a GameComponent and the "ExposeData" method.
#23
Hi,

Does it exist any Getter/Setter of global variable in a Rimworld save ?
Because i manage a global counter variable (integer) in a static method (so no ExposeData stuff ) but i want this variable to be persistent across reloading.

Thanks
#24
Hi,

For a mod i do, i use a copy (properly renamed) of the SoundDefs of the geothermal generator (GeothermalPlant_Ambience_Start, GeothermalPlant_Ambience_Stop, GeothermalPlant_Ambience), it's fine but the building which i assign this soundDef is not a generator, so when there is a power loss it should not continue play the ambiance but instead play GeothermalPlant_Ambience_Stop, and then when power come back GeothermalPlant_Ambience_Start again.

Is it possible with XML only or it need some C# stuff (just give me functions needed) ? i dont see any way of doing this.

Thanks !
#25
Help / Disable/Enable Gizmo in a building ?
November 08, 2018, 07:42:26 PM
Hi guys,

Is it possible to disable/enable an Gizmo  (button) ? because i try to disable the gizmos of a specific cooler (i need to re-enable them later) to prevent the player to change the targetTemperature :


foreach (var item in cooler.TryGetComp<CompTempControl>().CompGetGizmosExtra())
                {
                    item.disabled = true;
                    item.Disable();
                }


But this dont work, and even if the Disable method work i dont see any Enable method to re-enable the gizmo... is it the correct way to do this ?

Thanks !