Skip to content

Commit

Permalink
#529 fixed some load/save issues
Browse files Browse the repository at this point in the history
Sal now uses WorkTableWorkSpeedFactor
  • Loading branch information
Sn1p3rr3c0n committed Mar 19, 2022
1 parent bf7da4c commit 4d6e72b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public bool GetTarget(IntVec3 pos, Rot4 rot , Map map , bool spawned = false)
public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
base.SpawnSetup(map, respawningAfterLoad);
GetTarget();
if (salTarget == null) GetTarget();
extension_Skills = def.GetModExtension<ModExtension_Skills>();

}
Expand Down Expand Up @@ -140,12 +140,12 @@ protected override void Reset()
protected override void CleanupWorkingEffect()
{
base.CleanupWorkingEffect();
salTarget.CleanupWorkingEffect(this.MapManager);
salTarget?.CleanupWorkingEffect(this.MapManager);
}

protected override void CreateWorkingEffect()
{
salTarget.CreateWorkingEffect(this.MapManager);
salTarget?.CreateWorkingEffect(this.MapManager);
}


Expand All @@ -160,7 +160,7 @@ protected override TargetInfo ProgressBarTarget()
/// </summary>
private void WorkTableSetting()
{
GetTarget();
if (salTarget == null) GetTarget();
}

protected override void Ready()
Expand Down
9 changes: 4 additions & 5 deletions Source/ProjectRimFactory/AutoMachineTool/SAL_TargetBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public override void ExposeData()
Scribe_References.Look<Bill>(ref this.bill, "bill");
Scribe_References.Look<Thing>(ref this.dominant, "dominant");
Scribe_References.Look<Building_WorkTable>(ref this.my_workTable, "my_workTable");
Scribe_Collections.Look<Thing>(ref this.ingredients, "ingredients", LookMode.Deep);
Scribe_Collections.Look<Thing>(ref this.ingredients, "ingredients",LookMode.Reference /*, LookMode.Deep*/);
}

public interface IBill_PawnForbidded
Expand Down Expand Up @@ -278,7 +278,6 @@ public override void Reset(WorkingState workingState)

public override void CreateWorkingEffect(MapTickManager mapTickManager)
{

workingEffect = this.bill.recipe.effectWorking?.Spawn();

workingSound = this.bill.recipe.soundWorking?.TrySpawnSustainer(my_workTable);
Expand Down Expand Up @@ -448,7 +447,6 @@ private Thing DominantIngredient(List<Thing> ingredients)

public override void WorkDone(out List<Thing> products)
{

products = GenRecipe2.MakeRecipeProducts(this.bill.recipe, mySAL, this.ingredients, this.dominant, my_workTable, this.bill.precept).ToList();

this.ingredients.ForEach(i => bill.recipe.Worker.ConsumeIngredient(i, bill.recipe, map));
Expand All @@ -461,7 +459,6 @@ public override void WorkDone(out List<Thing> products)
this.ingredients = null;
// Because we use custom GenRecipe2, we have to handle bonus items and product modifications directly:
mySAL.ModifyProductExt?.ProcessProducts(products, this as IBillGiver, mySAL, this.bill.recipe); // this as IBillGiver is probably null

}

public override bool TryStartWork(out float workAmount)
Expand Down Expand Up @@ -502,8 +499,10 @@ public override bool TryStartWork(out float workAmount)
}
workAmount = this.bill.recipe.WorkAmountTotal(thingDef);

return true;
float speedfact = my_workTable.GetStatValue(StatDefOf.WorkTableWorkSpeedFactor);

workAmount /= speedfact;
return true;
}
else
{
Expand Down

0 comments on commit 4d6e72b

Please sign in to comment.