Ludeon Forums

RimWorld => Mods => Help => Topic started by: skullywag on March 06, 2016, 03:55:58 AM

Title: Alpha 13 modders stuff
Post by: skullywag on March 06, 2016, 03:55:58 AM
Heres what ive found so far:

1. Only 1 BuildingBase and the like is to be defined for each mod.
2. Comp properties can now define the class via the <li> in xml, e.g:
<li Class="CompProperties_Explosive">
3. DamageData is added to graphicData, this controls the damage overlay, so far ive seen:
<damageData>
  <rect>(0.2,0.2,0.6,0.6)</rect>
</damageData>

on a turret.
<damageData>
  <cornerTL>Damage/Corner</cornerTL>
  <cornerTR>Damage/Corner</cornerTR>
  <cornerBL>Damage/Corner</cornerBL>
  <cornerBR>Damage/Corner</cornerBR>
</damageData>

on a battery
<damageData>
  <cornerTL>Damage/Corner</cornerTL>
  <cornerTR>Damage/Corner</cornerTR>
  <cornerBL>Damage/Corner</cornerBL>
  <cornerBR>Damage/Corner</cornerBR>
  <edgeTop>Damage/Edge</edgeTop>
  <edgeBot>Damage/Edge</edgeBot>
  <edgeLeft>Damage/Edge</edgeLeft>
  <edgeRight>Damage/Edge</edgeRight>
</damageData>

on walls.
4. New comp:
<li Class="CompProperties_Breakdownable"/>
This is used by a new incident that makes machinery breakdown and require repairs.
5. In c# props can now be referenced on a comp via Props (capitalised P), e.g:
comp.Props.storedEnergyMax
instead of
comp.props.storedEnergyMax
6. combatTargetBuilding is now defined as a building property, e.g:
<building>
  <ai_combatDangerous>true</ai_combatDangerous>
</building>

instead of
<combatTargetBuilding>true</combatTargetBuilding>
7. Hediff_Stages is no more, you'll now need:
<HediffDef Name="DiseaseBase" Abstract="True">
  <hediffClass>HediffWithComps</hediffClass>
  <defaultLabelColor>(0.8, 0.8, 0.35)</defaultLabelColor>
</HediffDef>

8. singleBillGiverDef in workGivers is no longer, you'll now need, for example:
<fixedBillGiverDefs>
  <li>NameOfWorkbench</li>
</fixedBillGiverDefs>

9. When referring to a drawer on a pawn, capital D now, so:
this.wearer.Drawer.DrawPos;
instead of:
this.wearer.drawer.DrawPos;
10. BrokenStateDef is now MentalStatDef, so for example:
this.wearer.MentalStateDef
instead of:
this.wearer.BrokenStateDef
11. PowerToggleable is gone from CompPowerTrader and is now it own comp:
<li Class="CompProperties_Flickable" />
12. listerPawns is now mapPawns so when doing things like:
Find.Map.listerPawns.AllPawns
you now need:
Find.Map.mapPawns.AllPawns
13. You may need to use the attribute when using static material and such:
[StaticConstructorOnStartup]
A quick snippet from Ison as to why this is the case:
QuoteThis happens because from now on mods are loaded in a different thread. This, combined with the fact that it's impossible to use Unity's functions like loading a texture in threads other than the main one, means that you get an error in such cases. Does your new class have any static resources like Texture, Material or Graphic? If so, it means that during loading the game, when an object of this class is loaded, its static constructor is called and the game tries to load a texture in a different thread. With StaticConstructorOnStartup attribute, class' static constructor is called in the main thread before loading everything else.
You should make all resources static and then use [StaticConstructorOnStartup] attribute on the class, like this:
[StaticConstructorOnStartup]
public class Building_WindTurbineStuffed : Building_WindTurbine

14. Pawn_HealthTracker.ShouldBeTreatedNow is now Pawn_HealthTracker.ShouldBeTendedNow.
Title: Re: Alpha 13 modders stuff
Post by: RickyMartini on March 06, 2016, 03:56:53 AM
Can I ask, what cool new ideas are you currently developing? Any new mods?
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 06, 2016, 03:58:57 AM
Well things to come out of A13 testing idea wise....

Vaccines...lol

Other stuff im working on for A13, the return of purple ivy, now we have more insects its the right time to bring it back fully.
Ive got a bit of a turret update incoming, improves turrets via research and addon buildings (like an autoloader to speed up firerate for example)
And one giant mod including 14 themed sets of armour and weapons based on greek mythology, its a random one but i had to get the idea out of my head lol (could be adjusted to void gods easily enough if i feel like it)

In other news, updating is almost a non issue, large code basis will have some monotonous refactoring to do but its simples. Ive updated 7 of my mods in less than an hour. Gonna stop now though as alpha13 code could change further and dont want have to refactor again, I just got the ones unlikely to change out the way, the rest are the more indepth mods that id rather wait for more solid codebase (even if its the next build).
Title: Re: Alpha 13 modders stuff
Post by: RickyMartini on March 06, 2016, 04:03:15 AM
Really, vaccines? interesting
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 06, 2016, 04:05:26 AM
updated the above.

Yeah vaccines, im thinking of editing the health tab to show what the pawn is immune to somehow and then have very rare and expensive vaccines sold by traders (think neural trainers but for setting immunity to disease) you can apply them instantly or risk holding onto them until that particular disease hits...
Title: Re: Alpha 13 modders stuff
Post by: Coenmcj on March 06, 2016, 04:24:00 AM
interesting, but iirc things like parasites don't care so much if you're vacinatted or not, they'll still wreak havoc.

Parasites such as the Muscle Parasites and gut worms.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 06, 2016, 04:33:23 AM
worming tablets then....or the real way to prevent them, good hygeine. Its only an idea currently.
Title: Re: Alpha 13 modders stuff
Post by: RawCode on March 06, 2016, 05:39:23 AM
we are sci-fi and it's possible to explain anything by nano machines.

Title: Re: Alpha 13 modders stuff
Post by: RemingtonRyder on March 06, 2016, 05:51:20 AM
I'm pleased by the full XML inheritance of basebuilding. I'll make for less problems updating things from one alpha to the next.
Title: Re: Alpha 13 modders stuff
Post by: isistoy on March 06, 2016, 07:12:33 AM
Oh! Wait! I think I like the changer with <li Class="CompPropertyClass"!
Is it possible to know a bit more about exactly why this has changed? Would access to defs comp properties be different in the game? ::)
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 06, 2016, 03:31:36 PM
updated with a couple more.
Title: Re: Alpha 13 modders stuff
Post by: Tynan on March 06, 2016, 03:37:40 PM
Thanks for assembling this, definitely move it to public on release.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 06, 2016, 03:38:02 PM
Hmm my first issue I think, this:

<ThingDef ParentName="BuildingBase" Class="ExtendedStorage.ESdef">

used to allow me to add a new xml node and have it read into a class, this doesnt seem to work anymore, has this method of custom xml additions changed?

For clarity i use this for my extended storage mod to allow me to define a maxstorage int, e.g
using Verse;

namespace ExtendedStorage
{
    public class ESdef : ThingDef
    {
        public int maxStorage;
    }
}


did i done derped? or is this now different?
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 07, 2016, 02:43:23 AM
Any word on the above. If thats no longer working a lot of mods are gonna have issues.
Title: Re: Alpha 13 modders stuff
Post by: Tynan on March 07, 2016, 07:50:36 AM
Please enter a Mantis issue, this may be related to the refactor of def loading code.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 07, 2016, 08:25:16 AM
Mantis 2229
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 10, 2016, 08:22:37 AM
Seen your notes on 2229, cant wait for the next build, nice work on fixing it Ison.
Title: Re: Alpha 13 modders stuff
Post by: ison on March 12, 2016, 05:55:10 AM
Thanks skullywag. Both syntaxes should now work.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 12, 2016, 07:55:11 AM
Seems the old way still works but:

<ExtendedStorage.ESdef ParentName="BuildingBase"> does not, would this be because its inside <Buildings> tags?

not major as the old way is working fine again just thought it was strange.
Title: Re: Alpha 13 modders stuff
Post by: ison on March 14, 2016, 11:23:13 AM
Quote from: skullywag on March 12, 2016, 07:55:11 AM
Seems the old way still works but:

<ExtendedStorage.ESdef ParentName="BuildingBase"> does not, would this be because its inside <Buildings> tags?

not major as the old way is working fine again just thought it was strange.

You want to define a new def of type ExtendedStorage.ESdef and "Buildings" is the root node of the xml file, correct? Can you post a logfile here? It's probably because ExtendedStorage.ESdef comes from a non-Core mod.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 14, 2016, 11:45:35 AM
Ill grab everything and post it up tonight, at work currently, but yes as per:

https://github.com/Skullywag/ExtendedStorage/blob/master/Defs/ThingDefs/Storage/Storage_Basket.xml

with the relevant "Class" lines changed (and other A13 things) to what youve stated above.
Title: Re: Alpha 13 modders stuff
Post by: keylocke on March 16, 2016, 01:10:07 AM
can someone help point me out?

i'm trying to make a pawn reskin mod but i don't know which defs do i need to change to point to the new graphics. i also don't know which xml tags i need in order to achieve this.

(http://i.imgur.com/QbkEoBp.jpg)

is there a documentation of what each def does and what each xml tag does for the defs?

further questions :
-what's the texture filepath for pawn body textures?
-how do i remove incompatible vanilla graphics for this mod? (since some vanilla apparel is gonna be incompatible, etc)

-----------

i've been reading the tutorials.
i can mod new animals, new weapons, new apparels, etc.. but i can't find tutorial for modding pawn textures for humanoids.

can anyone point me in the right direction?

------------------------

hmm, the images in the rimworld core textures are greyscale, so i started doing these in greyscale like this.

(http://i.imgur.com/I39qmd4.jpg)

(i'm gonna pixel art this when i go final, but for testing, i think these will do until i learn how to mod this into the game itself)

anyways, i just remembered shinzy's cool apparello mod having colored textures instead of just greyscale.

-is that applicable to pawn bodies?
-how do i do that? which tag should i change in which def?

--------------------

PS : pardon if it's wrong for me to post it here, since this board has higher traffic of modders right now.

hoping to get some answers so i can finish this asap before i got lazy again.. lel.  :-\
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 16, 2016, 04:18:38 AM
Theres an alternate pawn texture thread somewhere on the forums. Might be in mods. That might have what you need.
Title: Re: Alpha 13 modders stuff
Post by: keylocke on March 16, 2016, 09:17:33 AM
thanks do you have a link for that? i can't seem to find the right keywords to search it.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 16, 2016, 09:36:05 AM
I believe it was Jabbamonkey:
https://ludeon.com/forums/index.php?topic=10895.0
and:
https://ludeon.com/forums/index.php?topic=7180.msg73172#msg73172

that should lead you in the right direction, dont know how much of this is going to be correct but its what i was thinking of.
Title: Re: Alpha 13 modders stuff
Post by: keylocke on March 16, 2016, 10:08:08 AM
thanks a lot skully!  ;D
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 16, 2016, 10:08:51 AM
check your other thread, i just put all the info youd need, i went and dug out the paths from the code.
Title: Re: Alpha 13 modders stuff
Post by: keylocke on March 18, 2016, 09:49:12 PM
thanks skully for your help. i got another problem. :-\

(http://i.imgur.com/nJlA3KO.png)

i can't find texture path for pants. i'm not sure if there's a pants "layer" either. (unlike armor vests which occupies it's own layer).

is there a workaround for this?

or should i just include pants/skirts graphics with the clothes in the bottom layer?
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 19, 2016, 07:51:29 AM
I can see you request in the other thread, no need to do this in 2 places, i think shinzys got you sorted over there.
Title: Re: Alpha 13 modders stuff
Post by: keylocke on March 19, 2016, 12:19:35 PM
yep. sorry about that. sometimes i get stuck and i panic. my bad.
Title: Re: Alpha 13 modders stuff
Post by: Nasikabatrachus on March 19, 2016, 05:32:56 PM
Is it possible to add sounds to correlate with social interactions?
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 19, 2016, 05:50:51 PM
Maybe, havent looked into it.

Added and updated a few more points in the OP.
Title: Re: Alpha 13 modders stuff
Post by: Tynan on March 19, 2016, 05:53:53 PM
Quote from: Nasikabatrachus on March 19, 2016, 05:32:56 PM
Is it possible to add sounds to correlate with social interactions?
You could do it pretty easily with a custom InteractionWorker, I think.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 23, 2016, 04:28:28 PM
Have had a few hours testing, thought id flip over to mod stuff.

Just had a major explosion on loading a save on the latest build containing mods:

Load can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

(Filename: C:/buildslave/unity/build/artifacts/StandalonePlayerGenerated/BaseClass.cpp Line: 426)

Exception from asynchronous event: System.InvalidOperationException: SaveableFromNode exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for TurbinesStuffed.Building_WindTurbineStuffed ---> System.ArgumentException: Load can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

  at (wrapper managed-to-native) UnityEngine.Resources:Load (string,System.Type)

  at UnityEngine.Resources.Load[Texture2D] (System.String path) [0x00000] in C:\buildslave\unity\build\artifacts\StandalonePlayerGenerated\BaseClass.cs:708

  at Verse.ContentFinder`1[UnityEngine.Texture2D].Get (System.String itemPath, Boolean reportFailure) [0x00071] in C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\ContentFinder.cs:29

  at Verse.MaterialPool.MatFrom (System.String texPath) [0x00018] in C:\Dev\RimWorld\Assets\Scripts\Verse\Resources\MaterialPool.cs:31

  at TurbinesStuffed.Building_WindTurbineStuffed..cctor () [0x00000] in <filename unknown>:0

  --- End of inner exception stack trace ---

  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (object,object[],System.Exception&)

  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00119] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:513

  --- End of inner exception stack trace ---

  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0012c] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:519

  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:528

  at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x001b8] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Activator.cs:338

  at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Activator.cs:268

  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Activator.cs:263

  at Verse.ScribeExtractor.SaveableFromNode[Thing] (System.Xml.XmlNode subNode, System.Object[] ctorArgs) [0x000eb] in C:\Dev\RimWorld\Assets\Scripts\Verse\Map\SaveLoad\Scribe\ScribeExtractor.cs:94
Subnode:
<thing Class="TurbinesStuffed.Building_WindTurbineStuffed"><def>WindTurbine</def><id>WindTurbine55156</id><pos>(137, 0, 149)</pos><health>150</health><stuff>Steel</stuff><faction>Faction_9</faction><parentThing>null</parentThing><updateCounter>22</updateCounter><cachedPowerOutput>541.5908</cachedPowerOutput></thing>

  at Verse.ScribeExtractor.SaveableFromNode[Thing] (System.Xml.XmlNode subNode, System.Object[] ctorArgs) [0x0017c] in C:\Dev\RimWorld\Assets\Scripts\Verse\Map\SaveLoad\Scribe\ScribeExtractor.cs:120

  at Verse.Scribe_Collections.LookList[Thing] (System.Collections.Generic.List`1& list, Boolean saveDestroyedThings, System.String label, LookMode lookMode, System.Object[] ctorArgs) [0x0037d] in C:\Dev\RimWorld\Assets\Scripts\Verse\Map\SaveLoad\Scribe\Scribe_Collections.cs:132

  at Verse.Scribe_Collections.LookList[Thing] (System.Collections.Generic.List`1& list, System.String label, LookMode lookMode, System.Object[] ctorArgs) [0x00000] in C:\Dev\RimWorld\Assets\Scripts\Verse\Map\SaveLoad\Scribe\Scribe_Collections.cs:13

  at Verse.MapIniter_LoadFromFile.InitMapFromFile (System.String fileName) [0x00138] in C:\Dev\RimWorld\Assets\Scripts\Verse\Map\MapIniter\MapIniter_LoadFromFile.cs:67

  at Verse.RootMap.<Init>m__4FF () [0x00000] in C:\Dev\RimWorld\Assets\Scripts\Verse\Global\Root\RootMap.cs:27

  at Verse.LongEventHandler.RunEventFromAnotherThread (System.Action action) [0x00006] in C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:287


Not sure whats happening here, ill debug some more, but a pointer would be appreciated.

So the mod with the issue seems to be the windturbines mod, the core turbine class has "[StaticConstructorOnStartup]" at the start of its class. Do i need to do some trickery here if im extending this class?
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 28, 2016, 01:49:46 PM
Added another one i spotted when playing with map components.

Also added the [StaticConstructorOnStartup] stuff.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on March 29, 2016, 05:15:56 AM
Also can we move this to the public testers forum, so we can gain more feedback about the modding based changes.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on April 02, 2016, 04:44:45 PM
Added Pawn_HealthTracker changes.
Title: Re: Alpha 13 modders stuff
Post by: skullywag on April 06, 2016, 05:04:17 PM
Can we get this in the mods sub forum plz
Title: Re: Alpha 13 modders stuff
Post by: NoImageAvailable on April 06, 2016, 05:36:15 PM
Moved this to the Help forum and stickied.
Title: Re: Alpha 13 modders stuff
Post by: mrofa on April 11, 2016, 05:56:07 AM
C# code:
Comps props got choped to separate class, there is no longer "One to rule them all"
Old
var affectedComp = affectedDef.GetCompProperties(typeof(CompFacility));

New
var affectedComp = affectedDef.GetCompProperties<CompProperties_Facilities>();

Glower comp is broken cant get/set its status, if on/off unless its within vanilia preset rules, so check the comp checks before and/or wait for ccl
Good days of Snake like googels are gone, now you need switches for glowing...
(https://s21.postimg.org/no95bqumf/GlowingStuff.gif)
Title: Re: Alpha 13 modders stuff
Post by: Rikiki on April 13, 2016, 05:35:56 PM
I found how to refresh ComGlower! :)
Just add these two lines to force glower update:
Find.MapDrawer.MapMeshDirty(this.Position, MapMeshFlag.Things);
Find.GlowGrid.MarkGlowGridDirty(this.Position);


To switch it on or off, you might try to set its radius to 0 before a refresh?
this.GetComp<CompGlower>().Props.glowRadius = 0;
Title: Re: Alpha 13 modders stuff
Post by: skullywag on April 13, 2016, 06:09:17 PM
Glowers have an updateglow method that does the above, you dont need to call that stuff anymore it does it for you.

The issue of the on/off not sure.
Title: Re: Alpha 13 modders stuff
Post by: Rikiki on April 14, 2016, 03:31:14 AM
I know but this does not work for 'dynamic' glowers (like in my alert speaker mod).
Title: Re: Alpha 13 modders stuff
Post by: skullywag on April 14, 2016, 03:36:29 AM
Ah i see. I feel we are going to need a compGlowerX again lol
Just when we thought custom glow comps were no longer needed.
Title: Re: Alpha 13 modders stuff
Post by: RemingtonRyder on April 28, 2016, 11:23:00 AM
Something I noticed with abstracts is that even within the same file, the <selectable> tag does not propagate down properly.

In other words, if building foo has an abstract parent B and B has an abstract parent A, and A has the <selectable>true</selectable> tag but B does not, then building foo will not be selectable.

Not sure if that's a limitation or a bug, but I thought I should make you aware of it!
Title: Re: Alpha 13 modders stuff
Post by: Kilroy232 on May 03, 2016, 10:46:37 PM
Do we have any more info on the new <damageData> tag? I would like to know just what the points forming a rectangle are used for and in what position in the rectangle does each point belong?
Title: Re: Alpha 13 modders stuff
Post by: skullywag on May 04, 2016, 06:26:09 PM
Its for the little marks that denote damage on things, theres multiple ways of implementing them as ive documented. A bit of experimentation is the best way to figure them out.
Title: Re: Alpha 13 modders stuff
Post by: Em on May 24, 2016, 12:16:57 PM
I don't get it guys. How do I find out what certain defintions are used for? I mean, I can't open the existing dll files and edit them, right? How exactly would I know what is used for what?
For example if I wanted to change the chances of two pawns being certain family members, how would I know what variables I need to use?
Title: Re: Alpha 13 modders stuff
Post by: mrofa on May 25, 2016, 09:09:03 AM
Download ILSpy (http://ilspy.net/), then just throw assembly dll(drag&drop) into it, you will the stuff decompiled to most extent