This repository has been archived by the owner on Nov 25, 2018. It is now read-only.
forked from alattalatta/RimWorld-Infusion
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
107 additions
and
278 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
|
||
using Harmony; | ||
|
||
using Verse; | ||
using RimWorld; | ||
|
||
namespace Infused | ||
{ | ||
[HarmonyPatch (typeof (CompQuality))] | ||
[HarmonyPatch ("SetQuality")] | ||
[HarmonyPatch (new Type [] { typeof (QualityCategory), typeof (ArtGenerationContext) })] | ||
class CompQualityPatch | ||
{ | ||
static void Postfix (CompQuality __instance, QualityCategory q, ArtGenerationContext source) | ||
{ | ||
// Can we be infused? | ||
CompInfusion compInfusion = __instance.parent.TryGetComp<CompInfusion> (); | ||
if (compInfusion != null) { | ||
var thing = __instance.parent; | ||
var def = __instance.parent.def; | ||
// Get those Infusions rolling | ||
var prefix = roll (thing, q); | ||
var suffix = roll (thing, q); | ||
|
||
var tierMult = def.techLevel < TechLevel.Industrial ? 3 : 1; | ||
|
||
if (prefix) | ||
compInfusion.InitializeInfusionPrefix (GenInfusion.GetTier (q, tierMult)); | ||
if (suffix) | ||
compInfusion.InitializeInfusionSuffix (GenInfusion.GetTier (q, tierMult)); | ||
if (prefix || suffix) | ||
__instance.parent.HitPoints = __instance.parent.MaxHitPoints; | ||
} | ||
} | ||
|
||
private static bool roll (Thing thing, QualityCategory qc) | ||
{ | ||
var chance = GenInfusion.GetInfusionChance (thing, qc); | ||
var rand = Rand.Value; | ||
#if DEBUG | ||
Log.Message ("Infused :: Rolled " + ((rand < chance) ? "success" : "failure") + " " + rand + " < " + chance + " for " + thing + " and " + qc); | ||
#endif | ||
return rand < chance; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
using Verse; | ||
using RimWorld; | ||
|
||
namespace Infused | ||
{ | ||
class InfusedMod : Mod | ||
{ | ||
public InfusedMod(ModContentPack mcp) : base (mcp) | ||
{ | ||
Harmony.HarmonyInstance.Create ("rimworld.infused").PatchAll (Assembly.GetExecutingAssembly ()); | ||
|
||
LongEventHandler.ExecuteWhenFinished (Inject); | ||
} | ||
|
||
private static void Inject () | ||
{ | ||
var defs = ( | ||
from def in DefDatabase<ThingDef>.AllDefs | ||
where (def.IsMeleeWeapon || def.IsRangedWeapon || def.IsApparel) | ||
&& def.HasComp (typeof (CompQuality)) && !def.HasComp (typeof (CompInfusion)) | ||
select def | ||
); | ||
|
||
var tabType = typeof (ITab_Infusion); | ||
var tab = InspectTabManager.GetSharedInstance (tabType); | ||
var compProperties = new CompProperties { compClass = typeof (CompInfusion) }; | ||
|
||
foreach (var def in defs) { | ||
def.comps.Add (compProperties); | ||
#if DEBUG | ||
Log.Message ("Infused :: Component added to " + def.label); | ||
#endif | ||
|
||
if (def.inspectorTabs == null || def.inspectorTabs.Count == 0) { | ||
def.inspectorTabs = new List<Type> (); | ||
def.inspectorTabsResolved = new List<InspectTabBase> (); | ||
} | ||
|
||
def.inspectorTabs.Add (tabType); | ||
def.inspectorTabsResolved.Add (tab); | ||
} | ||
#if DEBUG | ||
Log.Message ("Infused :: Injected " + defs.Count() + " " + DefDatabase<ThingDef>.AllDefs.Count()); | ||
#endif | ||
} | ||
|
||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.