Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<ModMetaData>
<name>Community Framework</name>
<author>ISOREX, Turnovus, and community contributors.</author>
<modVersion IgnoreIfNoMatchingField="True">1.4.0</modVersion>
<supportedVersions>
<li>1.2</li>
<li>1.3</li>
Expand Down
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>CommunityFramework</identifier>
<version>1.3.0</version>
<version>1.4.0</version>
<dependencies>
<li>Harmony</li>
</dependencies>
Expand Down
Binary file modified Common/Assemblies/communityframework.dll
Binary file not shown.
2,703 changes: 2,703 additions & 0 deletions Common/Assemblies/communityframework.xml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Common/Languages/English/Keyed/Settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,16 @@

<CFSettings_ApplyOutputWorkerPatch_Name>Recipe Output Patches</CFSettings_ApplyOutputWorkerPatch_Name>
<CFSettings_ApplyOutputWorkerPatch_Desc>allows modders to run additional scripts whenever certain recipes are complete.</CFSettings_ApplyOutputWorkerPatch_Desc>

<CFSettings_ApplyCanPlaceBlueprintOverPatch_Name>Blueprint Overlap Patches</CFSettings_ApplyCanPlaceBlueprintOverPatch_Name>
<CFSettings_ApplyCanPlaceBlueprintOverPatch_Desc>allows modders to alter behaviors pertaining to placing blueprints onto existing buildings.</CFSettings_ApplyCanPlaceBlueprintOverPatch_Desc>

<CFSettings_ShortCircuitPatches_Name>Short circuit patches</CFSettings_ShortCircuitPatches_Name>
<CFSettings_ShortCircuitPatches_Desc>allows modders to create buildings that react differently to short circuits.</CFSettings_ShortCircuitPatches_Desc>

<CFSettings_PostMakePatch_Name>Thing post-make patches</CFSettings_PostMakePatch_Name>
<CFSettings_PostMakePatch_Desc>runs additional behaviors whenever a thing is created.</CFSettings_PostMakePatch_Desc>

<CFSettings_ApplyBatteryPatches_Name>Battery charge patches</CFSettings_ApplyBatteryPatches_Name>
<CFSettings_ApplyBatteryPatches_Desc>allows modders to further customize their modded batteries.</CFSettings_ApplyBatteryPatches_Desc>
</LanguageData>
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using Verse;
using RimWorld;

namespace CF
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using Verse;
using RimWorld;

namespace CF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using RimWorld;
using Verse;

namespace CF
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using Verse;
using RimWorld;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using Verse;

namespace CF
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using Verse;
using RimWorld;

namespace CF
{
Expand All @@ -30,5 +25,17 @@ class HediffCompProperties_MultiplyOtherHediff :
/// multiplied by.
/// </summary>
public float multiplier = 1.0f;
/// <summary>
/// If <c>true</c>, then the comp will affect newly-added
/// <c>Hediff</c>s. Does not affect conditions that are already
/// present.
/// </summary>
public bool affectsNewHediffs = true;
/// <summary>
/// If <c>true</c>, then the comp will affect <c>Hediff</c>s that were
/// already present when the parent condition was applied. Does not
/// affect other conditions that were added after the parent.
/// </summary>
public bool affectsExistingHediffs = false;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;

namespace CF
{
Expand All @@ -28,23 +23,73 @@ class HediffComp_MultiplyOtherHediffDuration :
/// Run when another <c>Hediff</c> is added to the parent's
/// <c>Pawn</c>. Multiplies the other <c>Hediff</c>'s duration by a set
/// amount, if the other <c>Hediff</c>'s <c>Def</c> is in
/// <c>Props.affectedHediffs</c>.
/// <c>Props.affectedHediffs</c>, and if <c>Props.affectsNewHediffs</c>
/// is <c>true</c>.
/// </summary>
/// <param name="hediff">The <c>Hediff</c> being added.</param>
public void OnHediffAdded(ref Hediff hediff)
{
if (hediff == parent)
if (!Props.affectsNewHediffs)
return;
if (Props.affectedHediffs.Contains(hediff.def))
if (hediff is HediffWithComps withComps)

TryAdjustOtherHediff(hediff);
}

/// <summary>
/// Run when the parent <see cref="Hediff"/> is applied to a
/// <see cref="Pawn"/>. If <c>Props.affectsExistingHediff</c> is
/// <c>true</c>, then this override will go through each health
/// condition already present on the target <c>Pawn</c>, and, if the
/// condition's <see cref="HediffDef"/> is in
/// <c>Props.affectedHediffs</c>, its duration will be multiplied by
/// <c>Props.multiplier</c>.
/// </summary>
/// <param name="dinfo">
/// The <see cref="DamageInfo"/> that caused the parent condition to be
/// applied. Unused here.
/// </param>
public override void CompPostPostAdd(DamageInfo? dinfo)
{
base.CompPostPostAdd(dinfo);

if (!Props.affectsExistingHediffs)
return;

foreach (Hediff otherHediff in Pawn.health.hediffSet.hediffs)
TryAdjustOtherHediff(otherHediff);
}

/// <summary>
/// Internal helper method used to adjust the duration of other
/// <see cref="Hediff"/>s where applicable. This method ensures that
/// the targeted health condition is not the comp's parent condition,
/// and that the condition's <see cref="HediffDef"/> is contained in
/// <c>Props.affectedHediff</c> before taking effect, as well as
/// ensring that it has the required
/// <see cref="HediffComp_Disappears"/>, so doing those comparisons
/// externally is unnecessary.
/// </summary>
/// <param name="other">
/// The <see cref="Hediff"/> to possibly adjust.
/// </param>
private void TryAdjustOtherHediff(Hediff other)
{
if (other == parent)
return;
if (Props.affectedHediffs.Contains(other.def))
{
if (other is HediffWithComps withComps)
{
HediffComp_Disappears comp =
withComps.TryGetComp<HediffComp_Disappears>();

if (comp != null)
{
comp.ticksToDisappear =
(int)Math.Ceiling(
comp.ticksToDisappear * Props.multiplier);
(int)Math.Ceiling(comp.ticksToDisappear * Props.multiplier);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;

namespace CF
{
Expand All @@ -28,16 +23,58 @@ class HediffComp_MultiplyOtherHediffSeverity :
/// Run when another <c>Hediff</c> is added to the parent's
/// <c>Pawn</c>. Multiplies the other <c>Hediff</c>'s severity by a set
/// amount, if the other <c>Hediff</c>'s <c>Def</c> is in
/// <c>Props.affectedHediffs</c>.
/// <c>Props.affectedHediffs</c>, and if <c>Props.affectsNewHediffs</c>
/// is <c>true</c>.
/// </summary>
/// <param name="hediff">The <c>Hediff</c> being added.</param>
public void OnHediffAdded(ref Hediff hediff)
{
if (hediff == parent)
if (Props.affectsNewHediffs)
TryAdjustOtherHediff(hediff);
}

/// <summary>
/// Run when the parent <see cref="Hediff"/> is applied to a
/// <see cref="Pawn"/>. If <c>Props.affectsExistingHediff</c> is
/// <c>true</c>, then this override will go through each health
/// condition already present on the target <c>Pawn</c>, and, if the
/// condition's <see cref="HediffDef"/> is in
/// <c>Props.affectedHediffs</c>, its severity will be multiplied by
/// <c>Props.multiplier</c>.
/// </summary>
/// <param name="dinfo">
/// The <see cref="DamageInfo"/> that caused the parent condition to be
/// applied. Unused here.
/// </param>
public override void CompPostPostAdd(DamageInfo? dinfo)
{
base.CompPostPostAdd(dinfo);

if (!Props.affectsExistingHediffs)
return;

foreach (Hediff otherHediff in Pawn.health.hediffSet.hediffs)
TryAdjustOtherHediff(otherHediff);
}

/// <summary>
/// Internal helper method used to adjust the severity of other
/// <see cref="Hediff"/>s where applicable. This method ensures that
/// the targeted health condition is not the comp's parent condition,
/// and that the condition's <see cref="HediffDef"/> is contained in
/// <c>Props.affectedHediff</c> before taking effect, so doing those
/// comparisons externally is unnecessary.
/// </summary>
/// <param name="other">
/// The <see cref="Hediff"/> to possibly adjust.
/// </param>
private void TryAdjustOtherHediff(Hediff other)
{
if (other == parent)
return;
if (Props.affectedHediffs.Contains(hediff.def))
hediff.Severity =
(int)Math.Ceiling(hediff.Severity * Props.multiplier);
if (Props.affectedHediffs.Contains(other.def))
other.Severity =
Math.Min(other.Severity * Props.multiplier, other.def.maxSeverity);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using RimWorld;
using Verse;

namespace CF
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using Verse;
using RimWorld;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
using Verse;
using RimWorld;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using Verse.Sound;
using RimWorld;

namespace CF
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using Verse;
using RimWorld;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;
using RimWorld;

namespace CF {
/// <summary>
Expand Down Expand Up @@ -82,6 +80,14 @@ public override string CompInspectStringExtra()
/// </summary>
public class CompProperties_Validator : CompProperties
{
/// <summary>
/// The number of in-game ticks that pass before each time the
/// <c>PlaceWorker</c> validation check is run. A lower number will run
/// the check more frequently, but can cause slowdown if the parent
/// <c>ThingWithComps</c> has computationally-expensive
/// <c>PlaceWorkers</c>. For reference, at 1x speed, there are 60 ticks
/// in a single second.
/// </summary>
public int tickInterval = 250;

/// <value>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Verse;
using Verse;

namespace CF
{
Expand Down
Loading