Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/MegaMorphChan.cs
2026-02-21 16:45:37 +08:00

191 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class MegaMorphChan
{
public string mName = "Empty";
public float Percent;
public bool mActiveOverride = true;
public bool mUseLimit;
public float mSpinmax = 100f;
public float mSpinmin;
public Vector3[] mDeltas;
public float mCurvature = 0.5f;
public bool showparams = true;
public bool showtargets = true;
public List<MegaMorphTarget> mTargetCache;
public MegaBezFloatKeyControl control;
public int[] mapping;
public bool cubic;
public int[] morphedVerts;
public Vector3[] oPoints;
private float speed;
private float targetPercent;
public float weight = 1f;
public float fChannelPercent;
public int targ;
public float fProgression;
public int segment;
public Vector3[] p1;
public Vector3[] p2;
public Vector3[] p3;
public Vector3[] p4;
public Vector3[] diff;
public static void Copy(MegaMorphChan from, MegaMorphChan to)
{
to.mName = from.mName;
to.Percent = from.Percent;
to.mActiveOverride = from.mActiveOverride;
to.mUseLimit = from.mUseLimit;
to.mSpinmax = from.mSpinmax;
to.mSpinmin = from.mSpinmin;
to.mDeltas = from.mDeltas;
to.mCurvature = from.mCurvature;
to.showparams = from.showparams;
to.showtargets = from.showtargets;
to.mTargetCache = from.mTargetCache;
to.control = from.control;
to.mapping = from.mapping;
to.cubic = from.cubic;
to.morphedVerts = from.morphedVerts;
to.oPoints = from.oPoints;
to.speed = from.speed;
to.targetPercent = from.targetPercent;
to.fChannelPercent = from.fChannelPercent;
to.targ = from.targ;
to.fProgression = from.fProgression;
to.segment = from.segment;
to.p1 = from.p1;
to.p2 = from.p2;
to.p3 = from.p3;
to.p4 = from.p4;
to.diff = from.diff;
to.weight = from.weight;
}
public void SetTarget(float target, float spd)
{
speed = spd;
targetPercent = target;
}
public void UpdatePercent()
{
if (speed == 0f)
{
return;
}
if (Percent < targetPercent)
{
Percent += speed * Time.deltaTime;
if (Percent >= targetPercent)
{
Percent = targetPercent;
speed = 0f;
}
}
else
{
Percent -= speed * Time.deltaTime;
if (Percent <= targetPercent)
{
Percent = targetPercent;
speed = 0f;
}
}
}
public float GetTargetPercent(int which)
{
if (which < -1 || which >= mTargetCache.Count)
{
return 0f;
}
if (which == -1)
{
return mTargetCache[0].percent;
}
return mTargetCache[which + 1].percent;
}
public void CompressChannel()
{
}
public void ResetPercent()
{
int count = mTargetCache.Count;
for (int i = 0; i < mTargetCache.Count; i++)
{
mTargetCache[i].percent = (float)(i + 1) / (float)count * 100f;
}
}
public void Rebuild(MegaMorph mp)
{
if (mTargetCache != null && mTargetCache.Count > 0 && mp.oPoints != null && mTargetCache[0].points != null && mp.oPoints.Length == mTargetCache[0].points.Length)
{
mDeltas = new Vector3[mp.oPoints.Length];
for (int i = 0; i < mTargetCache[0].points.Length; i++)
{
mDeltas[i] = (mTargetCache[0].points[i] - mp.oPoints[i]) / 100f;
}
}
}
public MegaMorphTarget GetTarget(string name)
{
if (mTargetCache == null)
{
return null;
}
for (int i = 0; i < mTargetCache.Count; i++)
{
if (mTargetCache[i].name == name)
{
return mTargetCache[i];
}
}
return null;
}
public void ChannelMapping(MegaMorph mr)
{
mapping = new int[mr.oPoints.Length];
for (int i = 0; i < mr.oPoints.Length; i++)
{
mapping[i] = i;
}
}
}