public void Initialize(MoveSplineInitArgs args) { splineflags = args.flags; facing = args.facing; m_Id = args.splineId; point_Idx_offset = args.path_Idx_offset; initialOrientation = args.initialOrientation; onTransport = false; time_passed = 0; vertical_acceleration = 0.0f; effect_start_time = 0; // Check if its a stop spline if (args.flags.done) { spline.clear(); return; } init_spline(args); // init parabolic / animation // spline initialized, duration known and i able to compute parabolic acceleration if (Convert.ToBoolean(args.flags.Raw() & (MoveSplineFlag.eFlags.Parabolic | MoveSplineFlag.eFlags.Animation))) { effect_start_time = (int)(Duration() * args.time_perc); if (args.flags.parabolic && effect_start_time < Duration()) { float f_duration = (float)TimeSpan.FromMilliseconds(Duration() - effect_start_time).TotalSeconds; vertical_acceleration = args.parabolic_amplitude * 8.0f / (f_duration * f_duration); } } }
void init_spline(MoveSplineInitArgs args) { Spline.EvaluationMode[] modes = new Spline.EvaluationMode[2] { Spline.EvaluationMode.Linear, Spline.EvaluationMode.Catmullrom }; if (args.flags.cyclic) { int cyclic_point = 0; // MoveSplineFlag::Enter_Cycle support dropped //if (splineflags & SPLINEFLAG_ENTER_CYCLE) //cyclic_point = 1; // shouldn't be modified, came from client spline.Init_Spline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.isSmooth())], cyclic_point); } else { spline.Init_Spline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.isSmooth())]); } // init spline timestamps if (splineflags.falling) { //FallInitializer init(spline.getPoint(spline.first()).z); //spline.initLengths(init); } else { CommonInitializer init = new CommonInitializer(args.velocity); spline.initLengths(init); } // TODO: what to do in such cases? problem is in input data (all points are at same coords) if (spline.length() < 1) { Log.outError("MoveSpline->init_spline: zero length spline, wrong input data?"); spline.set_length(spline.last(), spline.isCyclic() ? 1000 : 1); } point_Idx = spline.first(); }