[A14] Community Core Library v0.14.3.1

Started by RWCCLTeam, October 20, 2015, 12:08:13 PM

Previous topic - Next topic

1000101

#330
Detouring only applies to methods (code) and classes are just conceptual containers for data (fields).  Since data isn't "run" then detouring doesn't even make sense in their context.

For the private pawn field, you just need a little reflection.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

zlj

Hi,

unfortunately that didn't make any sense to me, or maybe i didn't clearly state what i wanted to say in the first place =p

RimWorld instantiates SkillRecord classes

I'd like it to instantiate MyMuchBetterSkillRecordThatDoesn'tUseStupidPrivateVariables classes instead, which basically is a clone of SkillRecord but with several modifications. But from your response i'm getting that this is not possible.

As for the reflection, i tried that, but it kind of fails pretty badly (with all Pawns not being able to do anything). I'd appreciate it if you can provide a hint at what i'm doing wrong?

Thank you!


namespace static_quality
{
    class static_quality_no_skill_degrading : SkillRecord
    {

        public static FieldInfo fi = typeof(SkillRecord).GetField("pawn", BindingFlags.Instance | BindingFlags.NonPublic);
Pawn pawn = (Pawn)fi.GetValue(null);

        public float _LearningFactor
        {
            get
            {
                if (DebugSettings.fastLearning)
                {
                    return 200f;
                }
                float num = pawn.GetStatValue(StatDefOf.GlobalLearningFactor, true) - 1f;  // << crashes here

// more stuff

}
}

1000101

Your reflection is wrong.  Or, rather, your call to the GetValue().  You aren't passing the object which contains the field, you are passing null (which is only valid for static member).

Take a look at CCLs source and it's detours, there is a fair bit of reflection in those for non-public members.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

SpaceDorf

Can I make a wish here for the CCL ?
As far as I remember the Minimap is from the CCL,
could you add an overlay for things drawn with the games Plan Tool ?
Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

gendalf

suggestion for minimap:
- add ores colors
- make it save the selected buttons and layers of zones, etc, of the map itself

zlj

Quote from: 1000101 on August 18, 2016, 05:19:26 PM
Your reflection is wrong.  Or, rather, your call to the GetValue().  You aren't passing the object which contains the field, you are passing null (which is only valid for static member).

Take a look at CCLs source and it's detours, there is a fair bit of reflection in those for non-public members.

Thanks for the tip. Of course it doesn't work out of the box with that particular class/method construct, but i managed to work around it ;)


1000101

#336
Quote from: gendalf on August 20, 2016, 07:01:44 AMsuggestion for minimap:
- add ores colors
- make it save the selected buttons and layers of zones, etc, of the map itself

We originally looked at adding a colour map for terrain and ores but the problem was not all the defs contained colour information.

Saving the state of areas and zones is a bit tricky because they don't have a fixed def, they are auto-generated at runtime so the "key" used to save them may not exist between one play session and another.

Quote from: SpaceDorf on August 19, 2016, 10:53:05 AMCan I make a wish here for the CCL ?
As far as I remember the Minimap is from the CCL,
could you add an overlay for things drawn with the games Plan Tool ?

The planning tool should be an easy enough overlay to add, thanks for the suggestion.  :)

Quote from: zlj on August 20, 2016, 02:45:50 PM
Quote from: 1000101 on August 18, 2016, 05:19:26 PMYour reflection is wrong.  Or, rather, your call to the GetValue().  You aren't passing the object which contains the field, you are passing null (which is only valid for static member).

Take a look at CCLs source and it's detours, there is a fair bit of reflection in those for non-public members.

Thanks for the tip. Of course it doesn't work out of the box with that particular class/method construct, but i managed to work around it ;)

Just make sure you are passing the correctly typed object to the GetValue() method of the FieldInfo for any given reflection.  You only pass a null object for static members.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

SpaceDorf

Quote from: 1000101 on August 20, 2016, 02:53:14 PM

Quote from: SpaceDorf on August 19, 2016, 10:53:05 AMCan I make a wish here for the CCL ?
As far as I remember the Minimap is from the CCL,
could you add an overlay for things drawn with the games Plan Tool ?


Thanks, I found out, that the planning tool is awesome to mark minerals and geysiers after visually prospecting the maps.
Now if I could see those on the minimap it would be optimal.

Anf thanks for all your work, the minimap made my game so much easier.
Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

Hatti

any ETA for a A15 version to get CCL dependant mods going?

1000101

Quote from: Hatti on August 21, 2016, 04:34:52 PMany ETA for a A15 version to get CCL dependant mods going?

Nope, and we'll never give ETA's so don't bother asking.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

Telkir

I've read through the docs / examples and searched forum posts, but couldn't tell whether this was possible - does CCL allow for replacing the texture of a Core terrain without redefining any XML?

I guessed it might be done with post-injection, something like this:

    public class GravelTweaker : SpecialInjector
    {
        public override bool Inject()
        {
            TerrainDef.Named("Gravel").fertility = 0.25f;
            TerrainDef.Named("Gravel").texturePath = "Terrains/NewGravel";
            return true;
        }
    }


But this has no effect - not even an error - perhaps because by the point this code runs, the texture at the original path was already loaded.

Any help appreciated.

1000101

#341
Yes, CCL does it's injections after all assets are loaded, etc.

You'd need to set up a long event handler (as texture loading has to be done in the main thread) to load the new texture directly.

Alternately, you could simply recreate the textures directory structure and place your texture in that with the proper filename and the game will automatically load it.  No need for XML or C# or CCL.

Modifying the values of the def however, will still require an XML override (which will cause the "sand" issue for existing saves) or C# after the game has generated the hash value for the terrain (such as when CCL executes special injectors).
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

Adventurer

Noticed this just updated. Should I start using this right now, or should I want for my CCL-dependent mods to update?

BlackSmokeDMax

#343
Quote from: Adventurer on August 23, 2016, 12:58:05 PM
Noticed this just updated. Should I start using this right now, or should I want for my CCL-dependent mods to update?

Think they have stated CCL should never break compatibility with older mods. Could be wrong about that, might want to read back a couple pages, think this was somewhat recently answered.

DariusWolfe

Nine times in ten, a mod like CCL is compatible with mods built for older versions. If it's ever not, the devs will usually say so, similarly to how Tynan points out when a new Alpha will not be compatible with older saves.