Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.5 update (art skill only, biotech kids)
Browse files Browse the repository at this point in the history
  - Plushies now only use Art skill and have no minimum skill requirement (less confusing for players).
  - Biotech: Added specific thoughts for children cuddling plushies (extra +1, stacks with Kind)
  - Biotech: Babies now get a small +1 thought for having a plushie near their crib
evrys committed Oct 29, 2022
1 parent 553191a commit 1a56d66
Showing 10 changed files with 158 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"omnisharp.useModernNet": false
}
Binary file modified 1.4/Assemblies/Plushies.dll
Binary file not shown.
50 changes: 46 additions & 4 deletions Defs/ThingDef/plushies.xml
Original file line number Diff line number Diff line change
@@ -116,10 +116,6 @@
<li>HandTailoringBench</li>
</recipeUsers>
<workSpeedStat>GeneralLaborSpeed</workSpeedStat>
<skillRequirements>
<Crafting>4</Crafting>
<Artistic>1</Artistic>
</skillRequirements>
<workSkill>Artistic</workSkill>
<unfinishedThingDef>UnfinishedApparel</unfinishedThingDef>
<effectWorking>Tailor</effectWorking>
@@ -170,4 +166,50 @@
</li>
</stages>
</ThoughtDef>

<ThoughtDef>
<defName>PlushieCuddleChild</defName>
<durationDays>1</durationDays>
<stackLimit>1</stackLimit>
<nullifyingTraits>
<li>Psychopath</li>
</nullifyingTraits>
<stages>
<li>
<label>cuddled soft toy</label>
<description>I feel extra snug and safe.</description>
<baseMoodEffect>2</baseMoodEffect>
</li>
</stages>
</ThoughtDef>

<ThoughtDef>
<defName>PlushieCuddleChildKind</defName>
<durationDays>1</durationDays>
<stackLimit>1</stackLimit>
<requiredTraits>
<li>Kind</li>
</requiredTraits>
<stages>
<li>
<label>cuddled favorite toy</label>
<description>I can take on the world with my fluffy best friend!</description>
<baseMoodEffect>4</baseMoodEffect>
</li>
</stages>
</ThoughtDef>

<ThoughtDef>
<defName>PlushieCuddleBaby</defName>
<workerClass>Plushies.ThoughtWorker_PlushieBaby</workerClass>
<validWhileDespawned>true</validWhileDespawned>
<developmentalStageFilter>Baby</developmentalStageFilter>
<stages>
<li>
<label>Nearby plushie</label>
<description>What is this fluffy creature?</description>
<baseMoodEffect>1</baseMoodEffect>
</li>
</stages>
</ThoughtDef>
</Defs>
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<p align="center">
<img src="https://steamuserimages-a.akamaihd.net/ugc/1648839814002163309/364DFD2C42A908873D1D10D52EADF3EBCC82E83E/" alt="Plushies" />
</p>

f
<p align="center">
<a href="https://github.com/Two-Kay/plushiesMod/releases/">
<img src="https://img.shields.io/badge/release-1.0.4-4BC51D.svg?style=flat" alt="v1.0.4" />
<img src="https://img.shields.io/badge/release-1.0.5-4BC51D.svg?style=flat" alt="v1.0.5" />
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2259582816">
<img src="https://img.shields.io/badge/RimWorld-1.2/1.3/1.4-purple.svg?longCache=true&style=plastic)" alt="Compatible Rimworld 1.2-1.4" />
@@ -25,6 +25,7 @@ A mod that adds plushies to Rimworld!
- "Psychopath" colonists are not too excited about plushies...
- but "Kind" colonists really like plushie cuddles and get +3!
- Colonists can also spend their free time cuddling plushies to gain joy!
- Biotech: Children particularly like plushies! Babies enjoy having some near their crib.

## Compatibility

@@ -34,4 +35,11 @@ Plushies are patched in as linkables for anything with "Bed" in the defName, so

Put the repository in your `RimWorld/Mods` folder. The assembly references in `Plushies.csproj` are relative paths that expect the mod to be located here. On Windows+Steam the mods folder will be at `C:\Program Files (x86)\Steam\steamapps\common\RimWorld\Mods`. The mod will be listed in the Rimworld UI with a folder icon next to it (unlike the steam workshop versions which have a steam icon).

For developing in Visual Studio Code: If you open the `Source/Plushies` folder, it should autodetect that it's a C# project and download the necessary plugins. You can then run `dotnet build` in a terminal to build the Rimworld 1.4 assembly for the mod.
For developing in Visual Studio Code: If you open the `Source/Plushies` folder, it should autodetect that it's a C# project and download the necessary plugins. You can then run `dotnet build` in a terminal to build the Rimworld 1.4 assembly for the mod.

## Changelog

- 1.0.5
- Plushies now only use Art skill and have no minimum skill requirement (less confusing for players).
- Biotech: Added specific thoughts for children cuddling plushies (extra +1, stacks with Kind)
- Biotech: Babies now get a small +1 thought for having a plushie near their crib
13 changes: 13 additions & 0 deletions Source/Plushies/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"ms-dotnettools.csharp"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [

]
}
3 changes: 3 additions & 0 deletions Source/Plushies/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"omnisharp.useModernNet": false
}
54 changes: 50 additions & 4 deletions Source/Plushies/HarmonyPatches.cs
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ public static class PlushiesThoughtDefOf
{
public static ThoughtDef PlushieCuddle;
public static ThoughtDef PlushieCuddleKind;
public static ThoughtDef PlushieCuddleChild;
public static ThoughtDef PlushieCuddleChildKind;

static PlushiesThoughtDefOf()
{
@@ -49,34 +51,70 @@ static HarmonyPatches()
}
}

// [HarmonyPatch(typeof(Toils_LayDown))]
// [HarmonyPatch("ApplyBedRelatedEffects")]
// class BabyBedThoughtsPatch {
// static void Postfix(
// Pawn p,
// Building_Bed bed,
// bool asleep,
// bool gainRest,
// bool deathrest) {

// Log.Message($"{p.ageTracker.CurLifeStage.developmentalStage} {p.mindState.applyBedThoughtsTick}")
// if (p.ageTracker.CurLifeStage.developmentalStage <= DevelopmentalStage.Baby && p.mindState.applyBedThoughtsTick == 0)
// {
// p.mindState.applyBedThoughtsTick = Find.TickManager.TicksGame + Rand.Range(2500, 10000);
// p.mindState.applyBedThoughtsOnLeave = false;
// }
// }
// }


[HarmonyPatch(typeof(Toils_LayDown))]
[HarmonyPatch("ApplyBedThoughts")]
class BedThoughtsPatch
{
static void Postfix(Pawn actor)
{
Log.Message("BedThoughtsPatch");
// These are here since it seems hard to figure out what properties in Rimworld
// are actually nullable
if (actor.needs == null || actor.needs.mood == null || actor.needs.mood.thoughts == null ||
actor.needs.mood.thoughts.memories == null)
return;

Log.Message("Has memories");

var bed = actor.CurrentBed();
if (bed == null)
return;

Log.Message("Has bed");

// This can be null in the case of a sleeping spot
var comp = bed.GetComp<CompAffectedByFacilities>();
if (comp == null)
return;

Log.Message("Has comp");

//var hasPlushie = comp.LinkedFacilitiesListForReading.Any(thing => thing.def.defName == "Plushie");
var hasPlushie = comp.LinkedFacilitiesListForReading.Any(thing => thing.def.defName.StartsWith("Plushie"));
if (hasPlushie) {
Log.Message("Has plushie");
if (actor.story != null && actor.story.traits != null && actor.story.traits.HasTrait(TraitDefOf.Kind)) {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddleKind);
if (!actor.ageTracker.Adult) {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddleChildKind);
} else {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddleKind);
}
} else {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddle);
if (!actor.ageTracker.Adult) {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddleChild);
} else {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddle);
}
}
}
}
@@ -105,9 +143,17 @@ static void Prefix(JobCondition condition, Pawn_JobTracker __instance, Pawn ___p
if (condition == JobCondition.Succeeded) {
var actor = ___pawn;
if (actor.story.traits.HasTrait(TraitDefOf.Kind)) {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddleKind);
if (!actor.ageTracker.Adult) {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddleChildKind);
} else {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddleKind);
}
} else {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddle);
if (!actor.ageTracker.Adult) {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddleChild);
} else {
actor.needs.mood.thoughts.memories.TryGainMemory(PlushiesThoughtDefOf.PlushieCuddle);
}
}
}
}
2 changes: 1 addition & 1 deletion Source/Plushies/JoyGiver_CuddlePlushie.cs
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public override Job TryGiveJob(Pawn pawn)
CompArt compArt = thing.TryGetComp<CompArt>();
if (compArt == null)
{
Log.Error("No CompArt on thing being considered for viewing: " + thing, false);
Log.Error("No CompArt on thing being considered for viewing: " + thing);
return false;
}
//if (thing.def.defName != "Plushie")
1 change: 1 addition & 0 deletions Source/Plushies/Plushies.csproj
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@
<Compile Include="JoyGiver_CuddlePlushie.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ThingDef_Plushie.cs" />
<Compile Include="ThoughtWorker_PlushieBaby.cs" />
<Compile Include="HarmonyPatches.cs" />
</ItemGroup>
<ItemGroup>
30 changes: 30 additions & 0 deletions Source/Plushies/ThoughtWorker_PlushieBaby.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Verse;
using RimWorld;

namespace Plushies
{
public class ThoughtWorker_PlushieBaby : ThoughtWorker
{
protected override ThoughtState CurrentStateInternal(Pawn p)
{
if (!ModsConfig.BiotechActive)
return (ThoughtState) false;


Building_Bed bed = p.CurrentBed();
if (bed == null || !bed.def.building.bed_crib)
return (ThoughtState) false;

var comp = bed.GetComp<CompAffectedByFacilities>();
if (comp == null)
return (ThoughtState) false;

var hasPlushie = comp.LinkedFacilitiesListForReading.Any(thing => thing.def.defName.StartsWith("Plushie"));
if (hasPlushie) {
return ThoughtState.ActiveDefault;
} else {
return (ThoughtState) false;
}
}
}
}

0 comments on commit 1a56d66

Please sign in to comment.