123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- public class KupaCtrl
- {
- public KupaCtrl(TBody body0, TMorph morph)
- {
- this.m_morph = morph;
- for (int i = 0; i < this.m_morphId.Length; i++)
- {
- this.m_morphId[i] = -1;
- }
- if (this.m_morph.hash.ContainsKey("openkupa"))
- {
- this.m_morphId[0] = (int)this.m_morph.hash["openkupa"];
- }
- if (this.m_morph.hash.ContainsKey("openvagina"))
- {
- this.m_morphId[1] = (int)this.m_morph.hash["openvagina"];
- }
- if (this.m_morph.hash.ContainsKey("openanal"))
- {
- this.m_morphId[2] = (int)this.m_morph.hash["openanal"];
- }
- if (this.m_morph.hash.ContainsKey("chinkos"))
- {
- this.m_morphId[3] = (int)this.m_morph.hash["chinkos"];
- }
- Transform transform = CMT.SearchObjName(body0.m_trBones, "_IK_vagina", true);
- if (transform != null)
- {
- this.m_trans[0] = transform;
- }
- Transform transform2 = CMT.SearchObjName(body0.m_trBones, "_IK_vagina", true);
- if (transform2 != null)
- {
- this.m_trans[1] = transform2;
- }
- Transform transform3 = CMT.SearchObjName(body0.m_trBones, "_IK_anal", true);
- if (transform3 != null)
- {
- this.m_trans[2] = transform3;
- }
- }
- public void FinishAll()
- {
- for (int i = 0; i < this.m_taskList.Count; i++)
- {
- this.m_taskList[i].ForceFinish();
- }
- this.m_taskList.Clear();
- this.m_morph.FixBlendValues();
- }
- public void ResetAll()
- {
- for (int i = 0; i < this.m_morphId.Length; i++)
- {
- if (this.m_morphId[i] != -1)
- {
- this.m_morph.SetBlendValues(this.m_morphId[i], 0f);
- }
- }
- this.m_taskList.Clear();
- this.m_morph.FixBlendValues();
- }
- public void KupaStart(KupaCtrl.OPEN reg, float trans, float delay, float val, bool add = false)
- {
- if (!add)
- {
- this.Finish(reg);
- }
- if (this.m_morphId[(int)reg] != -1)
- {
- this.m_taskList.Add(new KupaCtrl.Task(this.m_morph, this.m_morphId[(int)reg], reg, trans, delay, val));
- }
- }
- public void AutoKupaStart(KupaCtrl.OPEN reg, Maid targetMan, float val, float speedIn, float sppedOut, float outVal)
- {
- this.m_taskList.RemoveAll((KupaCtrl.ATask i) => i.m_reg == reg);
- Transform trBones = targetMan.body0.m_trBones;
- NDebug.Assert(trBones != null, "男の体が未だロードされていません。");
- Transform transform = CMT.SearchObjName(trBones, "chinkoCenter", true);
- if (transform != null)
- {
- Transform[] array = new Transform[3];
- array[0] = transform.Find("chinko1");
- array[1] = array[0].Find("chinko2");
- array[2] = array[1].Find("chinko_nub");
- if (this.m_morphId[(int)reg] != -1)
- {
- this.m_taskList.Add(new KupaCtrl.Target(this.m_morph, this.m_morphId[(int)reg], reg, this.m_trans[(int)reg], array, val, speedIn, sppedOut, outVal));
- }
- }
- }
- public void Finish(KupaCtrl.OPEN reg)
- {
- for (int j = 0; j < this.m_taskList.Count; j++)
- {
- KupaCtrl.ATask atask = this.m_taskList[j];
- if (atask.m_reg == reg)
- {
- atask.ForceFinish();
- }
- }
- this.m_taskList.RemoveAll((KupaCtrl.ATask i) => i.m_reg == reg);
- }
- public void Reset(KupaCtrl.OPEN reg)
- {
- if (this.m_morphId[(int)reg] != -1)
- {
- this.m_morph.SetBlendValues(this.m_morphId[(int)reg], 0f);
- }
- this.m_taskList.RemoveAll((KupaCtrl.ATask i) => i.m_reg == reg);
- }
- public void SelfUpdate()
- {
- bool flag = false;
- for (int j = 0; j < this.m_taskList.Count; j++)
- {
- flag |= (this.m_taskList[j].IsVisible() && this.m_taskList[j].SelfUpdate());
- }
- if (flag)
- {
- this.m_morph.FixBlendValues();
- }
- this.m_taskList.RemoveAll((KupaCtrl.ATask i) => !i.IsVisible());
- }
- public TMorph m_morph;
- private int[] m_morphId = new int[4];
- private List<KupaCtrl.ATask> m_taskList = new List<KupaCtrl.ATask>();
- private Transform[] m_trans = new Transform[4];
- public enum OPEN
- {
- KUPA,
- VAGINA,
- ANAL,
- CHINKOS,
- MAX
- }
- private abstract class ATask
- {
- public ATask(TMorph morph, int id, KupaCtrl.OPEN reg)
- {
- this.m_morph = morph;
- this.m_id = id;
- this.m_reg = reg;
- }
- public virtual bool IsVisible()
- {
- return this.m_visible;
- }
- public abstract void ForceFinish();
- public virtual void ForceReset()
- {
- this.m_morph.SetBlendValues(this.m_id, 0f);
- this.m_visible = false;
- }
- public abstract bool SelfUpdate();
- protected TMorph m_morph;
- protected int m_id;
- public KupaCtrl.OPEN m_reg;
- protected bool m_visible;
- }
- private class Task : KupaCtrl.ATask
- {
- public Task(TMorph morph, int id, KupaCtrl.OPEN reg, float trans, float delay, float val) : base(morph, id, reg)
- {
- this.m_transTime = trans;
- this.m_delayTime = delay;
- this.m_distVal = Mathf.Clamp01(val);
- this.m_startTime = Time.realtimeSinceStartup;
- this.m_visible = true;
- this.m_start = false;
- if (trans <= 0f && delay <= 0f)
- {
- this.ForceFinish();
- return;
- }
- }
- public override void ForceFinish()
- {
- this.m_morph.SetBlendValues(this.m_id, this.m_distVal);
- this.m_visible = false;
- }
- public override bool SelfUpdate()
- {
- if (!this.m_visible)
- {
- return false;
- }
- float num = Time.realtimeSinceStartup - this.m_startTime;
- if (!this.m_start)
- {
- if (this.m_delayTime > num)
- {
- return false;
- }
- if (this.m_transTime <= 0f)
- {
- this.ForceFinish();
- return true;
- }
- this.m_start = true;
- this.m_startVal = this.m_morph.GetBlendValues(this.m_id);
- this.m_subVal = this.m_distVal - this.m_startVal;
- }
- float num2 = num - this.m_delayTime;
- float num3 = 1f;
- if (0f < this.m_transTime)
- {
- num3 = this.m_startVal + this.m_subVal * (num2 / this.m_transTime);
- }
- if (this.m_transTime <= num2 || this.m_distVal == num3)
- {
- num3 = this.m_distVal;
- this.m_visible = false;
- }
- float num4 = Mathf.Clamp01(num3);
- if (num4 != this.m_morph.GetBlendValues(this.m_id))
- {
- this.m_morph.SetBlendValues(this.m_id, num4);
- return true;
- }
- return false;
- }
- private float m_transTime;
- private float m_delayTime;
- private float m_distVal;
- private float m_startTime;
- private float m_startTime2;
- private float m_startVal;
- private float m_subVal;
- private bool m_start;
- }
- private class Target : KupaCtrl.ATask
- {
- public Target(TMorph morph, int id, KupaCtrl.OPEN reg, Transform src, Transform[] target, float val, float speedIn, float sppedOut, float outVal) : base(morph, id, reg)
- {
- this.m_src = src;
- this.m_target = target;
- this.m_distVal = val;
- this.m_sppedIn = speedIn;
- this.m_sppedNow = speedIn;
- this.m_sppedOut = sppedOut;
- this.m_outVal = outVal;
- this.m_visible = true;
- }
- public override void ForceFinish()
- {
- this.m_visible = false;
- }
- public override void ForceReset()
- {
- this.m_morph.SetBlendValues(this.m_id, 0f);
- this.m_visible = false;
- }
- public override bool SelfUpdate()
- {
- if (!this.m_visible)
- {
- return false;
- }
- Vector3 lhs = this.m_src.TransformVector(-Vector3.forward);
- float num = Vector3.Distance(this.m_src.position, this.m_target[this.m_target.Length - 1].position);
- float num2 = float.PositiveInfinity;
- int num3 = 0;
- Vector3 zero = Vector3.zero;
- float num4 = 0f;
- for (int i = 1; i < this.m_target.Length; i++)
- {
- Vector3 position = this.m_target[i - 1].position;
- Vector3 position2 = this.m_src.position;
- MathCM.Segment segment = new MathCM.Segment(position, this.m_target[i].position);
- Vector3 vector;
- float num6;
- float num5 = MathCM.calcPointSegmentDist(ref position2, ref segment, out vector, out num6);
- if (num5 < num2)
- {
- num2 = num5;
- num3 = i;
- num4 = num6;
- }
- }
- float num7 = this.m_outNowVal;
- if (num2 <= this.m_hitDistance)
- {
- num7 = this.m_distVal;
- if (0f < num4 && num4 < 1f)
- {
- this.m_outNowVal = this.m_outVal;
- }
- }
- else if (num2 <= this.m_apprDistance)
- {
- num7 = this.m_outNowVal + (this.m_distVal - this.m_outNowVal) * (1f - (num2 - this.m_hitDistance) / (this.m_apprDistance - this.m_hitDistance));
- Vector3 normalized = (this.m_target[num3 - 1].position - this.m_target[num3].position).normalized;
- float num8 = Vector3.Dot(lhs, normalized);
- if ((double)num8 <= 0.0)
- {
- num7 = 0f;
- }
- else if (num8 <= 0.7f)
- {
- num7 *= num8 / 0.7f;
- }
- }
- if (num7 - this.m_befRatio > 0f)
- {
- this.m_sppedNow = this.m_sppedIn;
- }
- else if (num7 - this.m_befRatio < 0f)
- {
- this.m_sppedNow = this.m_sppedOut;
- }
- this.m_nowRatio += (num7 - this.m_nowRatio) * (Time.deltaTime * this.m_sppedNow);
- this.m_befRatio = num7;
- float num9 = Mathf.Clamp01(this.m_nowRatio);
- if (num9 != this.m_morph.GetBlendValues(this.m_id))
- {
- this.m_morph.SetBlendValues(this.m_id, num9);
- return true;
- }
- return false;
- }
- public Transform m_src;
- public Transform[] m_target;
- private float m_distVal = 1f;
- private float m_outVal;
- private float m_apprDistance = 0.025f;
- private float m_hitDistance = 0.02f;
- private float m_sppedIn = 5f;
- private float m_sppedOut = 5f;
- private float m_sppedNow = 5f;
- private float m_outNowVal;
- private float m_nowRatio;
- private float m_befRatio;
- }
- }
|