Initializing comps and inspect string

Started by skullywag, January 31, 2015, 03:10:07 PM

Previous topic - Next topic

skullywag

Hi all,

Small issue im having with the inspect string on my auto heal casket, its extending the core sleep casket whos get inspect string simply returns some text and doesnt call base.getinspectstring so never hits thingwithcomponents so never gets the inspect string if you add comps to anything that extends the sleep casket, ive created a comp list in my heal casket class and filled on spawn setup:

The part of my spawnSetup()
ThingComp thingComp = (ThingComp)Activator.CreateInstance(this.def.comps[i].compClass);
                thingComp.parent = this;
                thingComp.Initialize(this.def.comps[i]);
                this.comps.Add(thingComp);


However the strings always show "not connected to power" and "0 power needed".

The part of my getInspectString()
for (int i = 0; i < this.comps.Count; i++)
            {
                string text = this.comps[i].CompInspectStringExtra();
                if (!text.NullOrEmpty())
                {
                    stringBuilder.Append(text);
                    if (i < this.comps.Count - 1)
                    {
                        stringBuilder.AppendLine();
                    }
                }
            }


Any ideas what im missing or is this not possible due to the way the sleep casket im extending doesnt use base.getinspectstring().
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Gaesatae

#1
I had the same problem when I created a custom comp that had to work with electricity.
Try changing on the getinspectstring:
this.comps[i].CompInspectStringExtra(); for
base.GetComp<[compclass]>().CompInspectStringExtra();
I write [compclass] because I don't have any idea of how to use a variable in there. I'm a C noob. But something like Type compclass = this.comps.compClass.GetType(); may work, I don't know.

I don't know if it will work, I didn't use the Activator.CreateInstance, but you get the idea...

Wastelander

Is your getInspectString() method marked override? If not, give that a shot.

Otherwise you might not be able to extend Casket and will have to define your own class. Looks like (at least the cryptosleep casket) decompiles nicely, so it shouldn't be much more than a copy-paste job.

skullywag

this was a bug/something Tynan missed, hes addressing it for a future release. My issue was to try and find a way around it until he fixes it in core. My decompile wont show the commands method or something cant remember now but one of them is boned. I could probably write one myself but eh...effort, ill just wait for it to be fixed.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?