Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Fixes to ItemProcessor, DualCropExtension and SwallowWhole
Browse files Browse the repository at this point in the history
  • Loading branch information
juanosarg committed Apr 4, 2022
1 parent 603b01d commit 1bcbacc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
Binary file modified 1.3/Assemblies/VFECore.dll
Binary file not shown.
43 changes: 30 additions & 13 deletions Source/VFECore/AnimalBehaviours/Pawn classes/Pawn_SwallowWhole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,28 @@ public class Pawn_SwallowWhole : Pawn, IThingHolder

CompSwallowWhole comp = null;


public CompSwallowWhole Comp
{
get
{
if (this.comp != null)
{
return this.comp;
}
this.comp = this.TryGetComp<CompSwallowWhole>();
return this.comp;


}
}


public Pawn_SwallowWhole()
{
//Constructor initializes the pawn container and the comp
this.innerContainer = new ThingOwner<Thing>(this, false, LookMode.Deep);
comp = this.TryGetComp<CompSwallowWhole>();
comp = Comp;

}
public override void ExposeData()
Expand Down Expand Up @@ -62,18 +79,18 @@ public void DestroyContents()
public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
{

if (this.Map != null && comp.Props.createFilthWhenKilled)
if (this.Map != null && Comp.Props.createFilthWhenKilled)
{
EjectContents();
for (int i = 0; i < 20; i++)
{
IntVec3 c;
CellFinder.TryFindRandomReachableCellNear(this.Position, this.Map, 2, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c);
FilthMaker.TryMakeFilth(c, this.Map, comp.Props.filthToMake);
FilthMaker.TryMakeFilth(c, this.Map, Comp.Props.filthToMake);

}
if (comp.Props.playSoundWhenKilled) {
SoundDef.Named(comp.Props.soundToPlay).PlayOneShot(new TargetInfo(this.Position, this.Map, false));
if (Comp.Props.playSoundWhenKilled) {
SoundDef.Named(Comp.Props.soundToPlay).PlayOneShot(new TargetInfo(this.Position, this.Map, false));

}
}
Expand All @@ -83,19 +100,19 @@ public override void Destroy(DestroyMode mode = DestroyMode.Vanish)

public override void Kill(DamageInfo? dinfo, Hediff exactCulprit = null)
{
if (this.Map != null && comp.Props.createFilthWhenKilled)
if (this.Map != null && Comp.Props.createFilthWhenKilled)
{
EjectContents();
for (int i = 0; i < 20; i++)
{
IntVec3 c;
CellFinder.TryFindRandomReachableCellNear(this.Position, this.Map, 2, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c);
FilthMaker.TryMakeFilth(c, this.Map, comp.Props.filthToMake);
FilthMaker.TryMakeFilth(c, this.Map, Comp.Props.filthToMake);

}
if (comp.Props.playSoundWhenKilled)
if (Comp.Props.playSoundWhenKilled)
{
SoundDef.Named(comp.Props.soundToPlay).PlayOneShot(new TargetInfo(this.Position, this.Map, false));
SoundDef.Named(Comp.Props.soundToPlay).PlayOneShot(new TargetInfo(this.Position, this.Map, false));

}
}
Expand Down Expand Up @@ -139,10 +156,10 @@ public virtual bool TryAcceptThing(Thing thing, bool allowSpecialEffects = true)
public override void TickRare()
{
base.TickRare();
if (innerContainer.Count >= comp.Props.stomachCapacity)
if (innerContainer.Count >= Comp.Props.stomachCapacity)
{
tickCounter++;
if (tickCounter > comp.Props.digestionPeriod)
if (tickCounter > Comp.Props.digestionPeriod)
{
foreach (Thing thing in innerContainer)
{
Expand Down Expand Up @@ -174,9 +191,9 @@ public override string GetInspectString()
{
string stomachContents = "";

if (innerContainer.Count >= comp.Props.stomachCapacity)
if (innerContainer.Count >= Comp.Props.stomachCapacity)
{
stomachContents += "\n" + "VEF_StomachContents".Translate(innerContainer.Count) + "VEF_DigestionTime".Translate(((comp.Props.digestionPeriod - tickCounter) * 250).ToStringTicksToPeriod(true, false, true, true));
stomachContents += "\n" + "VEF_StomachContents".Translate(innerContainer.Count) + "VEF_DigestionTime".Translate(((Comp.Props.digestionPeriod - tickCounter) * 250).ToStringTicksToPeriod(true, false, true, true));
}
else stomachContents += "\n" + "VEF_StomachContents".Translate(innerContainer.Count);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ public override void TickRare()
{
float currentTempInMap = this.Position.GetTemperature(this.Map);
CombinationDef thisCombinationRecipe = DefDatabase<CombinationDef>.GetNamed(thisRecipe);
if ((currentTempInMap > compItemProcessor.Props.maxAccelerationTemp) || (currentTempInMap < compItemProcessor.Props.minAccelerationTemp))
if ((currentTempInMap > compItemProcessor.Props.minAccelerationTemp) && (currentTempInMap < compItemProcessor.Props.maxAccelerationTemp))
{

this.days = thisCombinationRecipe.singleTimeIfNotQualityIncreasing * compItemProcessor.Props.accelerationFactor;
Expand Down
4 changes: 2 additions & 2 deletions Source/VFECore/Plants/Harmony/Plant_PlantCollected.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public static void AddSecondaryOutput(Plant __instance, Pawn by)
{

float statValue = by.GetStatValue(StatDefOf.PlantHarvestYield);
if (!(by.RaceProps.Humanlike && !__instance.Blighted && Rand.Value > statValue))
if (!(by.RaceProps.Humanlike && !__instance.Blighted && __instance.CanYieldNow() && Rand.Value > statValue))
{

int num = extension.outPutAmount;
if (statValue > 1f)
{
num = GenMath.RoundRandom((float)num * statValue);
num = GenMath.RoundRandom((float)num * statValue * __instance.Growth);
}
if (num > 0)
{
Expand Down

0 comments on commit 1bcbacc

Please sign in to comment.