[1.5] HugsLib (11.0.3) Lightweight modding library

Started by UnlimitedHugs, December 15, 2016, 02:20:14 PM

Previous topic - Next topic

UnlimitedHugs

Updated to 6.1.0

Hey folks. Been a while since I added any new features- let's remedy that!

  • [EarlyInit] attribute
    When you put this puppy on a ModBase class, it will be instantiated at the earliest moment possible- when Verse.Mod instances are being created. Harmony patches will also be applied, and you will receive the new EarlyInitalize callback.
    This is handy when you need to patch some loading or initialization code, and you need to apply your patches as soon as possible.
  • Support for AssemblyFileVersion
    If you ever tried to directly reference another mod assembly in your own, you might know that it is vital that the other mods AssemblyVersion remain the same. Otherwise the dependency breaks, and you will have to rebuild your assembly to fix the problem.
    Turns out, that changing the AssemblyFileVersion of your dll instead will allow you to both advertise your version and not break any of the mods that depend on yours. So, AssemblyFileVersion will now be reported in the published logs, and will correctly trigger your update news items.

    HugsLib[ov:6.1.0]: 0Harmony(1.2.0.1), HugsLib(av:1.0.0.0,fv:6.1.0)
    An entry from the log publisher. ov is the overrideVersion from Version.xml (always takes priority), av and fv are AssemblyVersion and AssemblyFileVersion respectively. The highest one is used for update news.
    I also updated my mod publisher script to treat the two versions separately.


  • Per-mod update news toggles
    This gives the player the option to ignore future update news from a specific mod. If you've been making sure your news are short and relevant, you have nothing to worry about ;)
  • Update news for mods without assemblies
    Mods that only contain XML files can now also display news- more details on the wiki.
  • Optional saving for SettingHandleConvertible
    Custom setting handle data structures can now prevent themselves from being saved. Useful when they are in their default state.

That about covers it. Do try it out (before your players get to it) and let me know if you have any suggestions.
Steam update tomorrow, assuming all is well.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

Updated to 6.1.1

Got a couple of fixes for the last update.
Also, I disabled the new "update news for mods without assemblies" feature for now. It's not going to work properly for workshop mods, so I'll see if I can redesign it using a different approach.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

carlzxc

Hello, is this incompatible with AlienRaces? I can't play when AlienRaces is allowed

hauvega

I use Huglibs with Alien Race Framework and have no problems.  I have a race mod so do know hugs at the top under core with the HAF later in the mod order.  Sounds like a conflict or improper mod load order.

Work on mod
Break mod
Fix Mod
Break mod again

UncleIROH

I'm having issues attempting to do mod processing after other mods load their defs.

This code appears to handle a large number of cases
LongEventHandler.QueueLongEvent(() => {
     // Code to run after mods
}, ....);


But it doesn't fire after the HugsLib late method fire. Maybe OnDefsLoaded?

Is there a way to modify my existing code so that it fires after HugsLib. Or a way for me to bind to the HubsLib event sequence but only if HugsLib is present. ( i.e. My mod does not require HugsLib as a dependency )

UnlimitedHugs

Quote from: UncleIROH on March 28, 2019, 02:34:29 PM
I'm having issues attempting to do mod processing after other mods load their defs.

This code appears to handle a large number of cases
LongEventHandler.QueueLongEvent(() => {
     // Code to run after mods
}, ....);


But it doesn't fire after the HugsLib late method fire. Maybe OnDefsLoaded?

Is there a way to modify my existing code so that it fires after HugsLib. Or a way for me to bind to the HubsLib event sequence but only if HugsLib is present. ( i.e. My mod does not require HugsLib as a dependency )

HugsLib initializes in two stages- when Verse.Mod instances are created and again at StaticConstructorOnStartup. So, if you put a [StaticConstructorOnStartup] attribute on your controller and use LongEventHandler.QueueLongEvent you should get a callback once all HugsLib mods are initialized.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

Updated to 6.1.2

Minor update to disable log publisher url shortening by default. This should get around Steam automatically removing short urls. You can still have your url shortened if you hold Ctrl while publishing.
Also fixed the deprecated version format warning on startup.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

Updated to 6.1.3

Some additional tweaks to the log uploader. The confirmation window now has toggles to configure the publishing process. Also, logs are now limited to 10K lines by default to help upload long longs on slower connections.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

#368
Updated to 6.2.0

Hey folks, the 1.1 update is live.
Important! This is only a preliminary update to get the ball rolling and let people update and use the log publisher.
A compatibility-breaking update is coming a bit later- hopefully before 1.1 goes live on the stable branch. I have some outstanding API changes I want to make.
If you have any suggestions on HugsLib features that need changing, this is a good time to speak up.

Extra kudos go to diddily and Tobe-Continued on GitHub for their pull requests and doing most of my work for me ;)
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

Knight

Not sure if I'm being stupid or not but I think HugsLibChecker might be broken for 1.1. I haven't actually played or programmed for Rimworld for a while now so, again, could just be me being stupid. Still, getting the following on startup (when purposely excluding HugsLib - required for my mod):

RimWorld 1.1.2551 rev1075
Verse.Log:Message(String, Boolean)
RimWorld.VersionControl:LogVersionNumber()
Verse.Root:CheckGlobalInit()
Verse.Root:Start()
Verse.Root_Entry:Start()

ReflectionTypeLoadException getting types in assembly UseYourGun: System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0
  at Verse.ModAssemblyHandler.AssemblyIsUsable (System.Reflection.Assembly asm) [0x00000] in <b8131242147c4f5bbc580697f7726377>:0

Loader exceptions:
   => System.TypeLoadException: Could not resolve type with token 01000018 (from typeref, class/assembly HugsLib.Settings.SettingHandleConvertible, HugsLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
   => System.TypeLoadException: Could not resolve type with token 0100001f (from typeref, class/assembly HugsLib.ModBase, HugsLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)

Verse.Log:Error(String, Boolean)
Verse.ModAssemblyHandler:AssemblyIsUsable(Assembly)
Verse.ModAssemblyHandler:ReloadAll()
Verse.ModContentPack:ReloadContent()
Verse.LoadedModManager:LoadModContent()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.<>c:<Start>b__6_1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.<>c:<UpdateCurrentAsynchronousEvent>b__27_0()
System.Threading.ThreadHelper:ThreadStart_Context(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
System.Threading.ThreadHelper:ThreadStart()

An exception was caused by the HugsLibChecker assembly. Exception was: System.MissingMethodException: void Verse.LongEventHandler.QueueLongEvent(System.Action,string,bool,System.Action`1<System.Exception>)
  at HugsLibChecker.HugsLibChecker.RunAllChecks () [0x00056] in <17e0364003f64863ad8732cb22ef5516>:0
Verse.Log:Error(String, Boolean)
HugsLibChecker.HugsLibChecker:RunAllChecks()
HugsLibChecker.HugsLibChecker:.ctor(ModContentPack)
System.Reflection.MonoCMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoCMethod:InternalInvoke(Object, Object[])
System.Reflection.MonoCMethod:DoInvoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MonoCMethod:Invoke(BindingFlags, Binder, Object[], CultureInfo)
System.RuntimeType:CreateInstanceImpl(BindingFlags, Binder, Object[], CultureInfo, Object[], StackCrawlMark&)
System.Activator:CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[])
System.Activator:CreateInstance(Type, Object[])
Verse.LoadedModManager:CreateModClasses()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.<>c:<Start>b__6_1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.<>c:<UpdateCurrentAsynchronousEvent>b__27_0()
System.Threading.ThreadHelper:ThreadStart_Context(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
System.Threading.ThreadHelper:ThreadStart()

UnlimitedHugs

Quote from: Knight on February 21, 2020, 10:51:16 AM
I think HugsLibChecker might be broken for 1.1.

Right! Forgot to mention the checker.
Since 1.1 it is deprecated, on account of being no longer needed- the base game will check for (and possibly automatically download) any dependencies you specify for your mod, including HugsLib.
See ModUpdating.txt in you game folder and the update guide by Pardeike to figure out the syntax to make that happen.
Here's what I believe your About.xml file should include if the mod requires HugsLib:


<modDependencies>
<li>
<packageId>UnlimitedHugs.HugsLib</packageId>
<displayName>HugsLib</displayName>
<downloadUrl>https://github.com/UnlimitedHugs/RimworldHugsLib/releases/latest</downloadUrl>
<steamWorkshopUrl>steam://url/CommunityFilePage/818773962</steamWorkshopUrl>
</li>
</modDependencies>
<loadAfter>
<li>UnlimitedHugs.HugsLib</li>
</loadAfter>


Not tested, but looks about right (famous last words!).
I'll put a deprecation warning on the checker wiki page later.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

Updated to 6.2.1

Minor update to fix load order When the Royalty DLC is present.
Also, updated Harmony library to 2.0.0.6.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

#372
Update 7.0.0 pre-release

Hey fellas.
After much pressing of the keys, the 7.0 update for Rimworld 1.1 is available.
Unlike previously announced, this update does not break compatibility with existing mods for 1.1.
However, some minor fixes may be necessary, and some improvements can be made.
I have prepared an update guide to highlight the key points and save you some time: HugsLib 7.0 for Rimworld 1.1 update guide

The update is planned to go live on Steam tomorrow.
Do let me know if everything is working for your particular mods as it should.

Extra props to Fluffy for taking care of part of this update- the non-library news loading.
Hugs out.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

UnlimitedHugs

Updated to 7.0.1

A minor update to bring Harmony up to the latest version.
This update is now live on Steam.
HugsLib - AllowTool - Remote Tech - Map Reroll - Defensive Positions: Github, Steam

falconne

#374
After I updated my BetterWorkbenchManagement mod to 1.1 and HugsLib 6.2.1, a number of players are getting this error. Only some people get it, others are reporting it's working fine. My first instinct was conflicting versions of Harmony. Do you think this is related to issues you've had with the recent update?

I'm fetching HugsLib v6.2.1 via NuGet, which brings in Lib.Harmony 2.0.0.6. Can you advise what versions of the two I should build against? Should I update to the latest of each or are those still problematic?

For reference this is the patch class here the issue arises.