コード例 #1
0
ファイル: MoveSpline.cs プロジェクト: mygithome002/CypherCore
        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;

            time_passed           = 0;
            vertical_acceleration = 0.0f;
            effect_start_time     = 0;
            spell_effect_extra    = args.spellEffectExtra;
            splineIsFacingOnly    = args.path.Length == 2 && args.facing.type != MonsterMoveType.Normal && ((args.path[1] - args.path[0]).GetLength() < 0.1f);

            // Check if its a stop spline
            if (args.flags.hasFlag(SplineFlag.Done))
            {
                spline.clear();
                return;
            }

            init_spline(args);

            // init parabolic / animation
            // spline initialized, duration known and i able to compute parabolic acceleration
            if (args.flags.hasFlag(SplineFlag.Parabolic | SplineFlag.Animation | SplineFlag.FadeObject))
            {
                effect_start_time = (int)(Duration() * args.time_perc);
                if (args.flags.hasFlag(SplineFlag.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);
                }
            }
        }
コード例 #2
0
ファイル: MoveSpline.cs プロジェクト: mygithome002/CypherCore
        void init_spline(MoveSplineInitArgs args)
        {
            Spline.EvaluationMode[] modes = new Spline.EvaluationMode[2] {
                Spline.EvaluationMode.Linear, Spline.EvaluationMode.Catmullrom
            };
            if (args.flags.hasFlag(SplineFlag.Cyclic))
            {
                spline.init_cyclic_spline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.isSmooth())], 0);
            }
            else
            {
                spline.Init_Spline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.isSmooth())]);
            }

            // init spline timestamps
            if (splineflags.hasFlag(SplineFlag.Falling))
            {
                FallInitializer init = new FallInitializer(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(LogFilter.Unit, "MoveSpline.init_spline: zero length spline, wrong input data?");
                spline.set_length(spline.last(), spline.isCyclic() ? 1000 : 1);
            }
            point_Idx = spline.first();
        }
コード例 #3
0
        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;

            time_passed           = 0;
            vertical_acceleration = 0.0f;
            effect_start_time     = 0;
            spell_effect_extra    = args.spellEffectExtra;
            anim_tier             = args.animTier;
            splineIsFacingOnly    = args.path.Count == 2 && args.facing.type != MonsterMoveType.Normal && ((args.path[1] - args.path[0]).Length() < 0.1f);

            velocity = args.velocity;

            // Check if its a stop spline
            if (args.flags.HasFlag(SplineFlag.Done))
            {
                spline.Clear();
                return;
            }

            InitSpline(args);

            // init parabolic / animation
            // spline initialized, duration known and i able to compute parabolic acceleration
            if (args.flags.HasFlag(SplineFlag.Parabolic | SplineFlag.Animation | SplineFlag.FadeObject))
            {
                effect_start_time = (int)(Duration() * args.time_perc);
                if (args.flags.HasFlag(SplineFlag.Parabolic) && effect_start_time < Duration())
                {
                    if (args.parabolic_amplitude != 0.0f)
                    {
                        float f_duration = MSToSec((uint)(Duration() - effect_start_time));
                        vertical_acceleration = args.parabolic_amplitude * 8.0f / (f_duration * f_duration);
                    }
                    else if (args.vertical_acceleration != 0.0f)
                    {
                        vertical_acceleration = args.vertical_acceleration;
                    }
                }
            }
        }
コード例 #4
0
ファイル: MoveSpline.cs プロジェクト: lyosky/CypherCore
        void InitSpline(MoveSplineInitArgs args)
        {
            Spline.EvaluationMode[] modes = new Spline.EvaluationMode[2] {
                Spline.EvaluationMode.Linear, Spline.EvaluationMode.Catmullrom
            };
            if (args.flags.HasFlag(SplineFlag.Cyclic))
            {
                int cyclic_point = 0;
                if (splineflags.HasFlag(SplineFlag.EnterCycle))
                {
                    cyclic_point = 1;   // shouldn't be modified, came from client
                }
                spline.InitCyclicSpline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.IsSmooth())], cyclic_point, args.initialOrientation);
            }
            else
            {
                spline.InitSpline(args.path, args.path.Length, modes[Convert.ToInt32(args.flags.IsSmooth())], args.initialOrientation);
            }

            // init spline timestamps
            if (splineflags.HasFlag(SplineFlag.Falling))
            {
                FallInitializer init = new(spline.GetPoint(spline.First()).Z);
                spline.InitLengths(init);
            }
            else
            {
                CommonInitializer init = new(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(LogFilter.Unit, "MoveSpline.init_spline: zero length spline, wrong input data?");
                spline.Set_length(spline.Last(), spline.IsCyclic() ? 1000 : 1);
            }
            point_Idx = spline.First();
        }