public void StopWander() { if (moveTween != null) { moveTween.Stop(TweenStopBehavior.Complete); moveTween = null; } }
private void DrawTweenedHand(Vector3 position, Mesh handsMesh, Material material, Quaternion quat, TweenThing tweenThing, bool portrait, bool noTween) { if (position == Vector3.zero || handsMesh == null || material == null || quat == null || tweenThing == null) { return; } if (!this.Pawn.Downed || !this.Pawn.Dead) { if (!HarmonyPatchesFS.AnimatorIsOpen() && Find.TickManager.TicksGame == this.CompAnimator.LastPosUpdate[(int)tweenThing] || HarmonyPatchesFS.AnimatorIsOpen() && MainTabWindow_BaseAnimator.Pawn != this.Pawn) { position = this.CompAnimator.LastPosition[(int)tweenThing]; } else { if (this.Pawn.pather.MovedRecently(5)) { noTween = true; } this.CompAnimator.LastPosUpdate[(int)tweenThing] = Find.TickManager.TicksGame; Vector3Tween tween = this.CompAnimator.Vector3Tweens[(int)tweenThing]; switch (tween.State) { case TweenState.Running: if (noTween || this.CompAnimator.IsMoving) { tween.Stop(StopBehavior.ForceComplete); } position = tween.CurrentValue; break; case TweenState.Paused: break; case TweenState.Stopped: if (noTween || (this.CompAnimator.IsMoving)) { break; } ScaleFunc scaleFunc = ScaleFuncs.SineEaseOut; Vector3 start = this.CompAnimator.LastPosition[(int)tweenThing]; float distance = Vector3.Distance(start, position); float duration = Mathf.Abs(distance * 50f); if (start != Vector3.zero && duration > 12f) { start.y = position.y; tween.Start(start, position, duration, scaleFunc); position = start; } break; } this.CompAnimator.LastPosition[(int)tweenThing] = position; } } // tweener.PreThingPosCalculation(tweenThing, noTween); GenDraw.DrawMeshNowOrLater( handsMesh, position, quat, material, portrait); }
// private static float RecoilMax = -0.15f; // private static Vector3 curOffset = new Vector3(0f, 0f, 0f); // public static void AddOffset(float dist, float dir) // { // curOffset += Quaternion.AngleAxis(dir, Vector3.up) * Vector3.forward * dist; // if (curOffset.sqrMagnitude > RecoilMax * RecoilMax) // { // curOffset *= RecoilMax / curOffset.magnitude; // } // } public static void DoWeaponOffsets(Pawn pawn, Thing eq, ref Vector3 drawLoc, ref float weaponAngle, ref Mesh weaponMesh) { CompProperties_WeaponExtensions extensions = eq.def.GetCompProperties <CompProperties_WeaponExtensions>(); bool flipped = weaponMesh == MeshPool.plane10Flip; if ((pawn == null) || (!pawn.GetCompAnim(out CompBodyAnimator animator)) || (extensions == null)) { return; } float sizeMod = 1f; // if (Controller.settings.IReallyLikeBigGuns) { sizeMod = 2.0f; } // else if (Controller.settings.ILikeBigGuns) // { // sizeMod = 1.4f; // } // else // { // sizeMod = 1f; // } if (Find.TickManager.TicksGame == animator.LastPosUpdate[(int)equipment] || MainTabWindow_WalkAnimator.IsOpen && MainTabWindow_WalkAnimator.Pawn != pawn) { drawLoc = animator.LastPosition[(int)equipment]; weaponAngle = animator.LastWeaponAngle; } else { animator.LastPosUpdate[(int)equipment] = Find.TickManager.TicksGame; CalculatePositionsWeapon(pawn, ref weaponAngle, extensions, out Vector3 weaponPosOffset, out bool aiming, flipped); // weapon angle and position offsets based on current attack keyframes sequence DoAttackAnimationOffsetsWeapons(pawn, ref weaponAngle, ref weaponPosOffset, flipped, animator, out bool noTween); drawLoc += weaponPosOffset * sizeMod; Vector3Tween eqTween = animator.Vector3Tweens[(int)equipment]; if (pawn.pather.MovedRecently(5)) { noTween = true; } switch (eqTween.State) { case TweenState.Running: if (noTween || animator.IsMoving) { eqTween.Stop(StopBehavior.ForceComplete); } drawLoc = eqTween.CurrentValue; break; case TweenState.Paused: break; case TweenState.Stopped: if (noTween || (animator.IsMoving)) { break; } ScaleFunc scaleFunc = ScaleFuncs.SineEaseOut; Vector3 start = animator.LastPosition[(int)equipment]; float distance = Vector3.Distance(start, drawLoc); float duration = Mathf.Abs(distance * 50f); if (start != Vector3.zero && duration > 12f) { start.y = drawLoc.y; eqTween.Start(start, drawLoc, duration, scaleFunc); drawLoc = start; } break; } // // fix the reset to default pos is target is changing // bool isAimAngle = (Math.Abs(aimAngle - angleStanding) <= 0.1f); // bool isAimAngleFlipped = (Math.Abs(aimAngle - angleStandingFlipped) <= 0.1f); // // if (aiming && (isAimAngle || isAimAngleFlipped)) // { // // use the last known position to avoid 1 frame flipping when target changes // drawLoc = animator.lastPosition[(int)equipment]; // weaponAngle = animator.lastWeaponAngle; // } // else { animator.LastPosition[(int)equipment] = drawLoc; animator.LastWeaponAngle = weaponAngle; animator.MeshFlipped = flipped; } } // Now the remaining hands if possible if (animator.Props.bipedWithHands && Controller.settings.UseHands) { SetPositionsForHandsOnWeapons( drawLoc, flipped, weaponAngle, extensions, animator, sizeMod); } }