public void RenderEveryTick(float dt) { Vector3 zero = Vector3.zero; KBatchedAnimController component = GetComponent <KBatchedAnimController>(); zero = (component.GetTransformMatrix() * component.GetSymbolLocalTransform(targetSymbol, out bool _)).MultiplyPoint(Vector3.zero) - base.transform.GetPosition(); GetComponent <Light2D>().Offset = zero; }
private void UpdateFrame() { forceUpdate = false; bool symbolVisible = false; KAnim.Anim currentAnim = controller.CurrentAnim; if (currentAnim != null) { Matrix2x3 symbolLocalTransform = controller.GetSymbolLocalTransform(symbol, out symbolVisible); Vector3 position = controller.transform.GetPosition(); if (symbolVisible && (previousMatrix != symbolLocalTransform || position != previousPosition || useTargetPoint)) { previousMatrix = symbolLocalTransform; previousPosition = position; Matrix2x3 overrideTransformMatrix = controller.GetTransformMatrix() * symbolLocalTransform; Vector3 position2 = base.transform.GetPosition(); float z = position2.z; base.transform.SetPosition(overrideTransformMatrix.MultiplyPoint(offset)); if (useTargetPoint) { Vector3 position3 = base.transform.GetPosition(); position3.z = 0f; Vector3 from = targetPoint - position3; float num = Vector3.Angle(from, Vector3.right); if (from.y < 0f) { num = 360f - num; } base.transform.localRotation = Quaternion.identity; base.transform.RotateAround(position3, new Vector3(0f, 0f, 1f), num); float sqrMagnitude = from.sqrMagnitude; KBatchedAnimInstanceData batchInstanceData = myAnim.GetBatchInstanceData(); Vector3 position4 = base.transform.GetPosition(); float x = position4.x; Vector3 position5 = base.transform.GetPosition(); batchInstanceData.SetClipRadius(x, position5.y, sqrMagnitude, true); } else { Vector3 v = (!controller.FlipX) ? Vector3.right : Vector3.left; Vector3 v2 = (!controller.FlipY) ? Vector3.up : Vector3.down; base.transform.up = overrideTransformMatrix.MultiplyVector(v2); base.transform.right = overrideTransformMatrix.MultiplyVector(v); if ((Object)myAnim != (Object)null) { myAnim.GetBatchInstanceData()?.SetOverrideTransformMatrix(overrideTransformMatrix); } } Transform transform = base.transform; Vector3 position6 = base.transform.GetPosition(); float x2 = position6.x; Vector3 position7 = base.transform.GetPosition(); transform.SetPosition(new Vector3(x2, position7.y, z)); myAnim.SetDirty(); } } if ((Object)myAnim != (Object)null && symbolVisible != myAnim.enabled) { myAnim.enabled = symbolVisible; } }
// This method syncs the object to the transform of the neck snap point in the dupe void LateUpdate() { bool symbolVisible = false; if (dupeAnim.CurrentAnim != null) { var batch = dupeAnim.GetBatch(); var frame = batch.group.data.GetFrame(dupeAnim.GetCurrentFrameIndex()); if (frame != KAnim.Anim.Frame.InvalidFrame) { for (int i = 0; i < frame.numElements; i++) { int num = frame.firstElementIdx + i; if (num < batch.group.data.frameElements.Count) { KAnim.Anim.FrameElement frameElement = batch.group.data.frameElements[num]; if (frameElement.symbol == symbol) { if (frameElement.frame == 0) { if (facing <= 0) { myAnim.Play(front_anim); facing = 1; } } else { if (facing >= 0) { myAnim.Play(back_anim); facing = -1; } } } } } } symbolVisible = dupeAnim.GetSymbolVisiblity(symbol); bool unusedBool; Matrix2x3 symbolLocalTransform = dupeAnim.GetSymbolLocalTransform(symbol, out unusedBool); Vector3 position = dupeAnim.transform.GetPosition(); if (symbolVisible && (previousMatrix != symbolLocalTransform || position != previousPosition)) { previousMatrix = symbolLocalTransform; previousPosition = position; Matrix2x3 overrideTransformMatrix = dupeAnim.GetTransformMatrix() * symbolLocalTransform; float z = base.transform.GetPosition().z; base.transform.SetPosition(overrideTransformMatrix.MultiplyPoint(offset)); Vector3 v = dupeAnim.FlipX ? Vector3.left : Vector3.right; Vector3 v2 = dupeAnim.FlipY ? Vector3.down : Vector3.up; base.transform.up = overrideTransformMatrix.MultiplyVector(v2); base.transform.right = overrideTransformMatrix.MultiplyVector(v); if (myAnim != null) { myAnim.GetBatchInstanceData()?.SetOverrideTransformMatrix(overrideTransformMatrix); } base.transform.SetPosition(new Vector3(base.transform.GetPosition().x, base.transform.GetPosition().y, z)); myAnim.Offset = dupeAnim.Offset; myAnim.SetDirty(); } } if (myAnim != null && symbolVisible != myAnim.enabled) { myAnim.enabled = symbolVisible; } }