public Vector3 SimulateMotion(float time, CreatureDirection dir, Vector3_ origin) { if (!m_motion || m_motionFrame.x < 1) { return(stateMachine.creature.position_); } if (time < 0) { time = 0; } var itime = (int)(time * 1000); var frame = itime / 33; var prog = (itime % 33) / 33.0; var idx = (int)m_motionFrame.x + frame; idx = Mathd.Clamp(idx, (int)m_motionFrame.x, (int)m_motionFrame.y); var next = m_motion.points[idx]; var prev = m_motion.points[idx - 1]; var tar = (Vector3_.Lerp(prev, next, prog) - m_motion.points[0]) * 0.01; tar = new Vector3_(dir == CreatureDirection.BACK ? -tar.z : tar.z, tar.y, -tar.x) + origin; if (tar.y < 0) { tar.y = 0; } return(tar); }
private void UpdateAnimMotion() { var idx = (int)m_motionFrame.x + m_currentFrame; var max = (int)m_motionFrame.y; if (!m_motion || m_falling || idx < 1 || idx > max && m_motionIndex >= max) { m_inMotion = false; return; } m_inMotion = true; if (idx > max) { idx = max; } m_motionIndex = idx; var next = m_motion.points[m_motionIndex]; var prev = m_motion.points[m_motionIndex - 1]; var prog = idx == max ? 1.0 : (m_time % 33) / 33.0; var tar = (Vector3_.Lerp(prev, next, prog) - m_motion.points[0]) * 0.01; var c = stateMachine.creature; currentMotionPos = new Vector3_(!c.isForward ? -tar.z : tar.z, tar.y, -tar.x) + c.motionOrigin; if (currentMotionPos.y < 0) { FightRecordManager.RecordLog <LogVector3>(l => { l.tag = (byte)TagType.motionOrigin; l.pos = new double[] { tar.x, tar.y, tar.z }; }); FightRecordManager.RecordLog <LogVector3>(l => { l.tag = (byte)TagType.motionOrigin; l.pos = new double[] { c.motionOrigin.x, c.motionOrigin.y, c.motionOrigin.z }; }); FightRecordManager.RecordLog <LogVector3>(l => { l.tag = (byte)TagType.currentMotionPos; l.pos = new double[3]; l.pos[0] = currentMotionPos.x; l.pos[1] = currentMotionPos.y; l.pos[2] = currentMotionPos.z; }); currentMotionPos.y = 0; } }