コード例 #1
0
 private void ScriptedMovement_OnDestroy()
 {
     _wait?.Destroy();
     _wait    = null;
     _entry   = null;
     _current = null;
 }
コード例 #2
0
 public void Update(TimeSpan time)
 {
     if (_locked <= 0 && _current != null)
     {
         if (_position != _current.Position)
         {
             var offset = (_direction * ((time.Milliseconds / 1000f) * _speed / 45f));
             if (Vector3.DistanceSquared(_position, _current.Position) > (offset.LengthSquared() + Constants.EpsilonX1))
             {
                 _position += offset;
             }
             else
             {
                 if (!_waiting)
                 {
                     Execute();
                     offset     = (_direction * ((time.Milliseconds / 1000f) * _speed / 45f));
                     _position += offset;
                 }
                 else
                 {
                     _position = _current.Position;
                 }
             }
         }
         else if (_waiting)
         {
             _rotation = _current.Rotation.ToRadians();
             if (_wait == null && _current.Data01 > 0)
             {
                 _wait = new MovementWait(this, (_current.Data01 < _current.Data02 ?
                                                 TimeSpan.FromSeconds(Constants.RND.Next(_current.Data01, _current.Data02)) :
                                                 TimeSpan.FromSeconds(_current.Data01)));
             }
         }
         else
         {
             Execute();
         }
     }
     if ((_update -= time.Milliseconds) <= 0)
     {
         _update         = _interval;
         _entry.Position = _position;
         _entry.Rotation = _rotation;
         _entry.Time     = PNet.Utilities.Now;
         var msg = _creature.View.CreateStream(_entry.AllocSize);
         _entry.OnSerialize(msg); _creature.View.SendStream(msg);
     }
 }
コード例 #3
0
 public void ResetWait()
 {
     _waiting = false;
     _wait    = null;
 }