protected override void WatchTickAction() { ticksSpentAlready++; LearningUtility.WeaponTrainingAnimation(pawn, pawn.jobs.curJob.GetTarget(TargetIndex.A), verbToUse, ticksSpentAlready); base.WatchTickAction(); }
protected Toil Train(Thing currentWeapon) { Toil train = new Toil(); train.initAction = delegate() { Pawn actor = train.actor; Job curJob = actor.jobs.curJob; ThingDef weapon = practice ? currentWeapon.def : job.targetB.Thing.def; workLeft = curJob.bill.recipe.WorkAmountTotal(null); billStartTick = Find.TickManager.TicksGame; ticksSpentDoingRecipeWork = 0; curJob.bill.Notify_DoBillStarted(actor); Verb verbToUse = actor.TryGetAttackVerb(currentWeapon, true); LocalTargetInfo target = actor.jobs.curJob.GetTarget(TargetIndex.A); pawn.stances.SetStance(new Stance_Cooldown(2, target, verbToUse)); }; train.tickAction = delegate() { Pawn actor = train.actor; Job curJob = actor.jobs.curJob; ThingDef weapon = practice ? currentWeapon.def : job.targetB.Thing.def; ticksSpentDoingRecipeWork++; curJob.bill.Notify_PawnDidWork(actor); IBillGiverWithTickAction billGiverWithTickAction = train.actor.CurJob.GetTarget(TargetIndex.A).Thing as IBillGiverWithTickAction; if (billGiverWithTickAction != null) { billGiverWithTickAction.UsedThisTick(); } float num = (curJob.RecipeDef.workSpeedStat != null) ? actor.GetStatValue(curJob.RecipeDef.workSpeedStat, true) : 1f; if (curJob.RecipeDef.workTableSpeedStat != null) { Building_WorkTable building_WorkTable = BillGiver as Building_WorkTable; if (building_WorkTable != null) { num *= building_WorkTable.GetStatValue(curJob.RecipeDef.workTableSpeedStat, true); } } if (DebugSettings.fastCrafting) { num *= 30f; } workLeft -= num; actor.GainComfortFromCellIfPossible(); if (workLeft <= 0f) { ReadyForNextToil(); } LearningUtility.WeaponTrainingAnimation(pawn, pawn.jobs.curJob.GetTarget(TargetIndex.A), actor.TryGetAttackVerb(currentWeapon, true), ticksSpentDoingRecipeWork); if (job.RecipeDef.workSkill != null) { float xpDelta = practice ? 0.5f : 0.1f; float xp = xpDelta * job.RecipeDef.workSkillLearnFactor; actor.skills.GetSkill(job.RecipeDef.workSkill).Learn(xp, false); } }; train.defaultCompleteMode = ToilCompleteMode.Never; train.WithEffect(() => train.actor.CurJob.bill.recipe.effectWorking, TargetIndex.A); train.PlaySustainerOrSound(() => train.actor.CurJob.bill.recipe.soundWorking); train.WithProgressBar(TargetIndex.A, delegate { Pawn actor = train.actor; Job curJob = actor.CurJob; return(1f - (workLeft / curJob.bill.recipe.WorkAmountTotal(null))); }, false, -0.5f); train.FailOn(() => train.actor.CurJob.bill.suspended); train.activeSkill = () => train.actor.CurJob.bill.recipe.workSkill; return(train); }