{"id":22900345,"url":"https://github.com/vectorial1024/elitebionicsframework","last_synced_at":"2025-09-07T05:34:43.813Z","repository":{"id":40681375,"uuid":"172317407","full_name":"Vectorial1024/EliteBionicsFramework","owner":"Vectorial1024","description":"A common framework to change body part max HP.","archived":false,"fork":false,"pushed_at":"2025-03-31T11:06:06.000Z","size":7656,"stargazers_count":5,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T01:11:42.109Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://steamcommunity.com/sharedfiles/filedetails/?id=1665403571","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vectorial1024.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-02-24T09:11:28.000Z","updated_at":"2025-03-31T11:17:41.000Z","dependencies_parsed_at":"2024-04-15T18:04:30.668Z","dependency_job_id":null,"html_url":"https://github.com/Vectorial1024/EliteBionicsFramework","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vectorial1024%2FEliteBionicsFramework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vectorial1024%2FEliteBionicsFramework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vectorial1024%2FEliteBionicsFramework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vectorial1024%2FEliteBionicsFramework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vectorial1024","download_url":"https://codeload.github.com/Vectorial1024/EliteBionicsFramework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978779,"owners_count":21834917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T01:19:09.349Z","updated_at":"2025-09-07T05:34:43.801Z","avatar_url":"https://github.com/Vectorial1024.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elite Bionics Framework (EBF)\nA common framework to change body part max HP.\n\n## Installing this mod\nThe recommended way to install this mod is through the Steam Workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=1665403571\n\nPre-packed archives are sometimes available at GitHub releases: https://github.com/Vectorial1024/EliteBionicsFramework/releases\n\nStill, advanced users and other modders may want to clone this repo with Git, to access latest/development builds.\n\n## Third-party mod integrations/interactions\nThere are several ways the Elite Bionics Framework (\"EBF\") interacts with mods made by others:\n- Some mods depend on the EBF to enhance their bionics\n  - See this Steam Workshop Collection for known items: https://steamcommunity.com/workshop/filedetails/?id=2016834921\n- Some mods are patched to read updated statistics from EBF\n  - See this Steam Workshop Collection for known items: https://steamcommunity.com/workshop/filedetails/?id=2693300854\n- Some mods are patched to make their max-HP boosts work correctly\n  - See this Steam Workshop Collection for known items: https://steamcommunity.com/workshop/filedetails/?id=2828792658\n  - The main criteria of selecting mods to manually patch is their stability\n  - EBF does not claim ownership to those mods; the patching is done only to fix bugs\n\n------\n\n# Appendix: Adding compatibility with this mod\nThere are several ways to add compatibility with this mod, which corresponds to the 3 interaction categories listed above:\n- For XML modders to enhance/buff their bionics/hediffs\n- For C# modders to read the correct `BodyPartRecord` max HP\n- For C# modders to programmatically enhance/buff their bionics/hediffs (advanced usage!)\n\n\u003e [!TIP]\n\u003e The Elite Bionics Framework is most commonly used to buff bionics, but the framework works on basically any Hediff.\n\u003e\n\u003e One possible creative use is to make a Potion of Toughness that temporarily buffs the max HP of a given body part.\n\n## Appendix 1: XML modders and buffing bionics/hediffs\nThe EBF is available as additional `HediffComp`s to your bionics/hediffs. This section will only show the end result after adding EBF; this section will not teach you how to do XML patching.\n\n\u003e [!IMPORTANT]\n\u003e For XML patching, be aware that the game rejects the following:\n\u003e - multiple `\u003ccomps\u003e` nodes under the same `\u003cHediffDef\u003e` node\n\u003e - multiple `\u003cli\u003e` nodes under the same `\u003ccomps\u003e` node with the same `Class=\"...\"` value\n\u003e\n\u003e These are the game's limitation/requirements, and have nothing to do with Elite Bionics Framework. Be defensive when writing XML patches!\n\n\u003e [!TIP]\n\u003e As of RimWorld 1.1, you may use the atttribute `MayRequire=\"...\"` to make EBF support available but optional.\n\nA `HediffDef` XML code excerpt that uses `MayRequire=\"...\"` is as follows:\n\n```xml\n\u003cHediffDef\u003e\n    \u003c!-- hediff name, hediff worker class, etc. --\u003e\n    \u003ccomps\u003e\n        \u003cli class=\"EBF.Hediffs.HediffCompProperties_MaxHPAdjust\" MayRequire=\"V1024.EBFramework\"\u003e\n            \u003clinearAdjustment\u003e20\u003c/linearAdjustment\u003e\n            \u003cscaleAdjustment\u003e0.15\u003c/scaleAdjustment\u003e\n        \u003c/li\u003e\n    \u003ccomps\u003e\n    \u003c!-- other hediff-related code, etc. --\u003e\n\u003c/HediffDef\u003e\n```\n\nMore information about available XML components are found inside the `/Docs` folder.\n\n## Appendix 2: C# modders and reading statistics from EBF\nThe updated statistics values can be read from the class `EBF.EBFEndpoints`. Please refer to the source code in this repo for the latest method details (they rarely change and can be safely accessed with reflection). \n\n\u003e [!TIP]\n\u003e As of Harmony 2 (i.e. RimWorld 1.2), You can make integration easier by utilizing reverse-patching.\n\nA sample C# code excerpt making use of reverse-patching from the trusty Harmony 2 for RimWorld 1.6 is as follows:\n\n```c#\n[HarmonyPatch]\npublic class MaxHealthGetter\n{\n    public static bool Prepare()\n    {\n        // detect whether the EBF is loaded\n        return LoadedModManager.RunningMods.Where((ModContentPack pack) =\u003e pack.PackageId == \"V1024.EBFramework\");\n    }\n\n    public static MethodBase TargetMethod()\n    {\n        // the correct EBF endpoint method to get the updated statistics\n        return AccessTools.Method(\"EBF.EBFEndpoints:GetMaxHealthWithEBF\");\n    }\n\n    [HarmonyReversePatch]\n    public static float GetMaxHealth(BodyPartRecord record, Pawn pawn)\n    {\n        // if EBF is loaded, then Harmony replaces the body with the EBF endpoint method\n        // else, the reverse-patch fails and the body remains the vanilla GetMaxHealth().\n        return record.def.GetMaxHealth(pawn);\n    }\n}\n```\n\nThen, usages of the vanilla `BodyPartDef.GetMaxHealth(Pawn)` in your code base should be replaced with the reverse-patched method:\n\n```c#\n// setup\nBodyPartRecord record = /* ... */;\nPawn pawn = /* ... */;\nfloat maxHealth = 0;\n\n// replace this...\nmaxHealth = record.def.GetMaxHealth(pawn);\n\n// with this:\nmaxHealth = MaxHealthGetter.GetMaxHealth(record, pawn);\n```\n\nWith this change, EBF will no longer warn about \"adopting the EBF protocol\" (explained below).\n\n\u003e [!TIP]\n\u003e You may use decompilers (e.g. ILSpy) to see usages of `BodyPartDef.GetMaxHealth(Pawn)` inside your compiled assembly, so that you know where your code needs to be replaced inside your code base.\n\n### About \"adopting the EBF protocol\"\nCalling the vanilla `Verse.BodyPartDef:GetMaxHealth(Pawn)` method while this mod is active will emit a warning that looks like this:\n\n```\n[V1024-EBF] Elite Bionics Framework has detected some mods using the unmodified GetMaxHealth() method, which violates the EBF protocol. \nThe author(s) of the involved mod(s) should adopt the EBF to clarify their intentions.\nFor now, the unmodified max HP is returned.\nThe detected mod comes from: [name]\n```\n\nThe reason for this warning is that, under EBF, only having a `BodyPartDef` is not enough to determine the correct body part max HP when bionics are installed or `Hediff`s are added. As an example, a colonist have two `BodyPartRecord`s (left shoulder and right shoulder) but these share the same `BodyPartDef` (the shoulder).\n\nIf you see this warning, do report this to both the EBF and to the mod authors involved, so that compatibility may be ensured.\n\nIf you are a C# modder seeing this warning, then you should clarify your intentions by replacing the vanilla method call with one of the following:\n- `EBF.EBFEndpoints:GetMaxHealthUnmodified(BodyPartDef, Pawn)`: returns the def-backed max HP value, suppressing this warning\n- `EBF.EBFEndpoints:GetMaxHealthWithEBF(BodyPartRecord, Pawn)`: returns the EBF-calculated max HP value of a body part record\n\n## Appendix 3: C# modders and writing effects to EBF\nThis is advanced usage; it entails programmatically providing the max HP adjustment to EBF. Do review whether the same effect may be achieved by modifying XML files since that method is usually simpler.\n\nStill, as of EBF 6.0, it is possible to programmatically provide max HP adjustment to EBF. EBF will then pick up the value, and include it in the max HP calculations.\n\nA NuGet package is required: `Vectorial1024.EliteBionicsFrameworkAPI`.\n\nAt your `HediffComp`, implement `EBF.API.IHediffCompAdjustsMaxHp`. In particular, provide your intended max HP adjustment through the abstract property `public BodyPartMaxHpAdjustment MaxHpAdjustment`, so EBF may read it and know how you intend to adjust the max HP values.\n\n\u003e [!IMPORTANT]\n\u003e Currently, EBF caches body part max HP values, so at the moment, it is not possible to dynamically change max HP adjustment based on custom events (hypothetical e.g. bionics from CyberNet losing the max HP bonus when the GlitterNet goes out).\n\u003e\n\u003e However, support for dynamic HP max adjustment is being considered.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectorial1024%2Felitebionicsframework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvectorial1024%2Felitebionicsframework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectorial1024%2Felitebionicsframework/lists"}