Skip to content
Snippets Groups Projects
Commit d125d309 authored by Ed86's avatar Ed86
Browse files

remove milking wip code

parent 29ee9adc
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<!--
<JobDef>
<defName>MilkHuman</defName>
<driverClass>rjw.JobDriver_MilkHuman</driverClass>
<reportString>milking TargetA.</reportString>
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
</JobDef>
-->
</Defs>
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<!--
<Operation Class="PatchOperationSequence">
<success>Always</success>
<operations>
<li Class="PatchOperationTest">
<xpath>/Defs/ThingDef[defName="Human"]/comps</xpath>
<success>Invert</success>
</li>
<li Class="PatchOperationAdd">
<xpath>/Defs/ThingDef[defName="Human"]</xpath>
<value>
<comps />
</value>
</li>
</operations>
</Operation>
<Operation Class="PatchOperationAdd">
<xpath>Defs/ThingDef[defName="Human"]/comps</xpath>
<value>
<li Class="rjw.CompProperties_MilkableHuman">
<milkDef>Milk</milkDef>
<milkIntervalDays>1</milkIntervalDays>
<milkAmount>8</milkAmount>
<milkFemaleOnly>false</milkFemaleOnly>
</li>
</value>
</Operation>
<Operation Class="PatchOperationSequence">
<success>Always</success>
<operations>
<li Class="PatchOperationTest">
<xpath>Defs/AlienRace.ThingDef_AlienRace/comps</xpath>
</li>
<li Class="PatchOperationAdd">
<xpath>Defs/AlienRace.ThingDef_AlienRace[
defName="Alien_Callistan" or
defName="Alien_Astoriel" or
defName="Fantasy_Goblin" or
defName="LotRE_ElfStandardRace" or
defName="LotRH_HobbitStandardRace" or
defName="Alien_Orassan" or
defName="RGK_Race_Ratty" or
defName="Alien_Twilek" or
defName="Alien_Zabrak" or
defName="Avali" or
defName="Alien_Argonian" or
defName="Alien_Asari_Base" or
defName="Alien_Eldar" or
defName="Alien_Kroot" or
defName="Alien_Ork" or
defName="Alien_Tau" or
defName="Alien_Vespid" or
defName="Alien_Terran" or
defName="Alien_Sororitas" or
defName="Alien_Salamander" or
defName="Alien_Astartes" or
defName="Alien_Guevesa" or
defName="Alien_Krieg" or
defName="Alien_Valhallan" or
defName="Alien_Ferrex" or
defName="Alien_Xenn" or
defName="Alien_Leeani" or
defName="Alien_Fennex" or
defName="Alien_Frijjid"]/comps</xpath>
<value>
<li Class="rjw.CompProperties_MilkableHuman">
<milkDef>Milk</milkDef>
<milkIntervalDays>3</milkIntervalDays>
<milkAmount>12</milkAmount>
<milkFemaleOnly>false</milkFemaleOnly>
</li>
</value>
</li>
</operations>
</Operation>
<Operation Class="PatchOperationSequence">
<success>Always</success>
<operations>
<li Class="PatchOperationTest">
<xpath>Defs/AlienRace.ThingDef_AlienRace[defName="Naga"]/comps</xpath>
</li>
<li Class="PatchOperationAdd">
<xpath>Defs/AlienRace.ThingDef_AlienRace[defName="Naga"]/comps</xpath>
<value>
<li Class="rjw.CompProperties_MilkableHuman">
<milkDef>EggChickenUnfertilized</milkDef>
<milkIntervalDays>3</milkIntervalDays>
<milkAmount>6</milkAmount>
<milkFemaleOnly>true</milkFemaleOnly>
</li>
</value>
</li>
</operations>
</Operation>
-->
</Patch>
\ No newline at end of file
using RimWorld;
using Verse;
namespace rjw
{
public class CompMilkableHuman : CompHasGatherableBodyResource
{
protected override int GatherResourcesIntervalDays => Props.milkIntervalDays;
protected override int ResourceAmount => Props.milkAmount;
protected override ThingDef ResourceDef => Props.milkDef;
protected override string SaveKey => "milkFullness";
public CompProperties_MilkableHuman Props => (CompProperties_MilkableHuman)props;
protected override bool Active
{
get
{
if (!Active)
{
return false;
}
Pawn pawn = parent as Pawn;
if (pawn != null)
{
//idk should probably remove non rjw stuff
//should merge Lactating into .cs hediff?
//vanilla
//C&P?
//rjw human
//rjw animal
if ((!pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_lactating"), false))
&& ((pawn.health.hediffSet.HasHediff(HediffDef.Named("Pregnant"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("Pregnant"), false).Visible)
//|| (pawn.health.hediffSet.HasHediff(HediffDef.Named("HumanPregnancy"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy"), false).Visible)
|| (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy"), false).Visible)
|| (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_pregnancy_beast"), false) && pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("RJW_pregnancy_beast"), false).Visible)))
{
pawn.health.AddHediff(HediffDef.Named("RJW_lactating"), null, null, null);
}
if ((!Props.milkFemaleOnly || pawn.gender == Gender.Female)
&& (pawn.ageTracker.CurLifeStage.reproductive)
&& (pawn.RaceProps.Humanlike)
&& (pawn.health.hediffSet.HasHediff(HediffDef.Named("RJW_lactating"), false)
//|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Permanent"), false)
//|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Natural"), false)
//|| pawn.health.hediffSet.HasHediff(HediffDef.Named("Lactating_Drug"), false)
))
{
return true;
}
}
return false;
}
}
public override string CompInspectStringExtra()
{
if (!Active)
{
return null;
}
return Translator.Translate("MilkFullness") + ": " + GenText.ToStringPercent(this.Fullness);
}
}
}
using Verse;
namespace rjw
{
public class CompProperties_MilkableHuman : CompProperties
{
public int milkIntervalDays;
public int milkAmount = 8;
public ThingDef milkDef;
public bool milkFemaleOnly = true;
public CompProperties_MilkableHuman()
{
compClass = typeof(CompMilkableHuman);
}
}
}
using RimWorld;
using Verse;
namespace rjw
{
[DefOf]
public static class JobDefOfZ
{
public static JobDef MilkHuman;
static JobDefOfZ()
{
DefOfHelper.EnsureInitializedInCtor(typeof(JobDefOf));
}
}
}
using RimWorld;
using System;
using System.Collections.Generic;
using Verse;
using Verse.AI;
namespace rjw
{
public abstract class JobDriver_GatherHumanBodyResources : JobDriver_GatherAnimalBodyResources
{
private float gatherProgress;
/*
//maybe change?
protected abstract int GatherResourcesIntervalDays
{
get;
}
//add breastsize modifier?
protected abstract int ResourceAmount
{
get;
}
//add more milks?
protected abstract ThingDef ResourceDef
{
get;
}
*/
protected override IEnumerable<Toil> MakeNewToils()
{
ToilFailConditions.FailOnDespawnedNullOrForbidden<JobDriver_GatherHumanBodyResources>(this, TargetIndex.A);
ToilFailConditions.FailOnNotCasualInterruptible<JobDriver_GatherHumanBodyResources>(this, TargetIndex.A);
yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
Toil wait = new Toil();
wait.initAction = delegate
{
Pawn milker = base.pawn;
LocalTargetInfo target = base.job.GetTarget(TargetIndex.A);
Pawn target2 = (Pawn)target.Thing;
milker.pather.StopDead();
PawnUtility.ForceWait(target2, 15000, null, true);
};
wait.tickAction = delegate
{
Pawn milker = base.pawn;
milker.skills.Learn(SkillDefOf.Animals, 0.13f, false);
gatherProgress += StatExtension.GetStatValue(milker, StatDefOf.AnimalGatherSpeed, true);
if (gatherProgress >= WorkTotal)
{
GetComp((Pawn)base.job.GetTarget(TargetIndex.A)).Gathered(base.pawn);
milker.jobs.EndCurrentJob(JobCondition.Succeeded, true);
}
};
wait.AddFinishAction((Action)delegate
{
Pawn milker = base.pawn;
LocalTargetInfo target = base.job.GetTarget(TargetIndex.A);
Pawn target2 = (Pawn)target.Thing;
if (target2 != null && target2.CurJobDef == JobDefOf.Wait_MaintainPosture)
{
milker.jobs.EndCurrentJob(JobCondition.InterruptForced, true);
}
});
ToilFailConditions.FailOnDespawnedOrNull<Toil>(wait, TargetIndex.A);
ToilFailConditions.FailOnCannotTouch<Toil>(wait, TargetIndex.A, PathEndMode.Touch);
wait.AddEndCondition((Func<JobCondition>)delegate
{
if (GetComp((Pawn)base.job.GetTarget(TargetIndex.A)).ActiveAndFull)
{
return JobCondition.Ongoing;
}
return JobCondition.Incompletable;
});
wait.defaultCompleteMode = ToilCompleteMode.Never;
ToilEffects.WithProgressBar(wait, TargetIndex.A, (Func<float>)(() => gatherProgress / WorkTotal), false, -0.5f);
wait.activeSkill = (() => SkillDefOf.Animals);
yield return wait;
}
}
}
using RimWorld;
using Verse;
namespace rjw
{
public class JobDriver_MilkHuman : JobDriver_GatherHumanBodyResources
{
protected override float WorkTotal => 400f;
protected override CompHasGatherableBodyResource GetComp(Pawn animal)
{
return ThingCompUtility.TryGetComp<CompMilkableHuman>(animal);
}
}
}
using RimWorld;
using System.Collections.Generic;
using Verse;
using Verse.AI;
namespace rjw
{
public abstract class WorkGiver_GatherHumanBodyResources : WorkGiver_GatherAnimalBodyResources
{
public override IEnumerable<Thing> PotentialWorkThingsGlobal(Pawn pawn)
{
//List<Pawn> pawns = pawn.Map.mapPawns.SpawnedPawnsInFaction(pawn.Faction);
//int i = 0;
//if (i < pawns.Count)
//{
// yield return (Thing)pawns[i];
/*Error: Unable to find new state assignment for yield return*/
// ;
//}
foreach (Pawn targetpawn in pawn.Map.mapPawns.FreeColonistsAndPrisonersSpawned)
{
yield return targetpawn;
}
}
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
{
Pawn pawn2 = t as Pawn;
if (pawn2 == null || !pawn2.RaceProps.Humanlike)
{
return false;
}
CompHasGatherableBodyResource comp = GetComp(pawn2);
if (comp != null && comp.ActiveAndFull && PawnUtility.CanCasuallyInteractNow(pawn2, false) && pawn2 != pawn)
{
LocalTargetInfo target = pawn2;
bool ignoreOtherReservations = forced;
if (ReservationUtility.CanReserve(pawn, target, 1, -1, null, ignoreOtherReservations))
{
return true;
}
}
return false;
}
}
}
using RimWorld;
using Verse;
namespace rjw
{
public class WorkGiver_MilkHuman : WorkGiver_GatherHumanBodyResources
{
protected override JobDef JobDef => JobDefOfZ.MilkHuman;
protected override CompHasGatherableBodyResource GetComp(Pawn animal)
{
return ThingCompUtility.TryGetComp<CompMilkableHuman>(animal);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment