[mod idea] Worldmap road building

Started by Loconeko73, December 05, 2018, 12:13:16 AM

Previous topic - Next topic

Loconeko73

Greetings fellow Rimworlders,

As part of my attempt at a first mod, I have stumbled into a problem that boils down to lack of code toblatantly copy  get inspiration from.

It has to do with WorldObjectComp. ThingComp are well covered in Roxx Ploxx document here in the wiki and this knowledge can quickly be tested by checking the many existing mods that use comps.

However, I've been unable to find any mod that uses a WorldObjectComp, and find it difficult to navigate through that class without a working example.

By any chance, does any of you know of such a mod ?

Thanks in advance

Mehni

https://github.com/Mehni/MoreFactionInteraction/tree/master/MoreFactionInteraction/World%20Incidents

At its core, there's not much difference between a WorldObjectComp and a ThingComp. There are about 15 methods you can override that provide a hook/functionality.

Vanilla also has a few WorldObjectComps. Use your decompiler to see what classes inherit from or use the WorldObjectComp class.

Albion

#17
Yes like I already told you in an earlier post you can also look at my Sparkling Worlds code.
Specifically the events.cs which you can find here: https://gitlab.com/Albion/SparklingWorlds/tree/master/Source/SparklingWorlds%20Events/SparklingWorlds
It contains a WorldObjectComp for my psychic emitter event.

The best way is to look at the base classes from the core and see which methods you want to override. The most imporant ones are the ones like Pre- or PostSpawn, PostDestroy and CompTick.

Loconeko73

Thanks to you both. You're awesome  :)

I will check the mods you mentioned and hopefully that will put me on the right track.

Loconeko73

Hi again.

This is it. I have a working proof of concept : buildable roads that survive saving & loading ! There are still many more hours ahead to iron out the details, but I'm now confident I will release this mod.

Thanks everyone for the amazing support & patience !

Loconeko73

Roads of the Rim has been released on Steam. Feedback welcome !

Canute

Feedback: What is Steam, don't know such thing ! :-)

Loconeko73

Quote from: Canute on January 04, 2019, 03:08:27 AM
Feedback: What is Steam, don't know such thing ! :-)

Steam ? Best thing that ever happened to PC gaming ;-)

You can also get the mod on GitHub : https://github.com/LocoNeko/RoadsOfTheRim

Mehni

                else if (pawn.RaceProps.packAnimal)
                {
                    animalConstruction += (float)pawn.GetStatValue(StatDefOf.ConstructionSpeed) * (float)pawn.GetStatValue(StatDefOf.ConstructSuccessChance);
                }


https://github.com/LocoNeko/RoadsOfTheRim/blob/master/Source/RoadsOfTheRim/RoadsOfTheRim/WorldObjectComp_Caravan.cs#L99

I've never seen a muffalo with a trowel :P

Good job on the release tho.

Loconeko73

Thanks for the feedback, Mehni!

About the pack animals, if you look a bit further, you'll see they only help, but don't work on their own.

Canute

Tamed bulldozer and earthmover ! :-)
Here my stegosaurus, you favoured snack
*Dino is happy and dance*
*stamp stamp stamp stamp*
dirt road finished.

Mehni

I'm just wondering why you'd use those stats. As far as I can see, both the ConstructionSpeed and ConstructionSuccessChance return 1 for pawns without a SkillTracker. Such as animals. Maybe I'm wrong though.

It's a nice touch -- but maybe you're better off using manipulation/sight instead :)

Comrade Corwin

I'm getting this error on upload:

XML error: <li><compClass>RoadsOfTheRim.WorldObjectComp_Caravan</compClass></li> doesn't correspond to any field in type WorldObjectDef. Context: <WorldObjectDef><defName>Caravan</defName><label>caravan</label><description>A group of traveling people.</description><worldObjectClass>Caravan</worldObjectClass><texture>World/WorldObjects/Caravan</texture><useDynamicDrawer>true</useDynamicDrawer><expandingIcon>true</expandingIcon><expandingIconTexture>World/WorldObjects/Expanding/Caravan</expandingIconTexture><expandingIconPriority>100</expandingIconPriority><expandMore>true</expandMore><allowCaravanIncidentsWhichGenerateMap>true</allowCaravanIncidentsWhichGenerateMap><IncidentTargetTags><li>Caravan</li></IncidentTargetTags><inspectorTabs><li>WITab_Caravan_Health</li><li>WITab_Caravan_Needs</li><li>WITab_Caravan_Gear</li><li>WITab_Caravan_Social</li><li>WITab_Caravan_Items</li></inspectorTabs><comps><li><compClass>MoreFactionInteraction.World_Incidents.WorldObjectComp_CaravanComp</compClass></li></comps><li><compClass>RoadsOfTheRim.WorldObjectComp_Caravan</compClass></li></WorldObjectDef>
Verse.Log:Error(String, Boolean)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.DirectXmlLoader:DefFromNode(XmlNode, LoadableXmlAsset)
Verse.LoadedModManager:ParseAndProcessXML(XmlDocument, Dictionary`2)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__1()

I don't understand enough about coding in RimWorld to have any idea of the problem. Just thought I'd let you know what's up!

Canute

Comrade Corwin,
that's the right way, don't try to fix it by yourself, just report it to the mod author so he can fix it for all.

NazarDoe

Could you add a mapping of the required amount of resources without a caravan?