Exemple #1
0
        public void DropOff(Player plr)
        {
#if (DEBUG)
            Log.Info("Part.DropOff()", "Part Dropped off.");
#endif
            plr.CanMount = true;
            if (_targetCart != null)
            {
                plr.KneelDown(_targetCart.Oid, false);
            }
            plr.KneelDown(Oid, false);

            _carrier = null;
            plr.EvtInterface.RemoveEventNotify(EventName.OnDie, OnPlayerDied);
            plr.EvtInterface.RemoveEventNotify(EventName.OnMove, OnPlayerMove);
            plr.EvtInterface.RemoveEventNotify(EventName.OnReceiveDamage, OnPlayerDamage);
            if (_dropDel != null)
            {
                plr.EvtInterface.RemoveEvent(_dropDel);
                _dropDel = null;
            }
            if (_dropDel != null)
            {
                if (_flagEffect.HasValue)
                {
                    plr.OSInterface.RemoveEffect(0xB);
                }
            }


            if (DroppedOff != null)
            {
                DroppedOff(plr, this);
            }
        }
Exemple #2
0
 public Interact(Part part, Player player, EventDelegateEx del)
 {
     Player = player;
     Del    = del;
     Part   = part;
     player.EvtInterface.AddEventNotify(EventName.OnReceiveDamage, OnPlayerDamage);
 }
Exemple #3
0
        public void BeginDropOff(Player plr, GameObject targetCart)
        {
#if (DEBUG)
            Log.Info("Part.BeginDropOff()", plr.Name + " is dropping off the part at Oid " + targetCart.Oid);
#endif

            if (_carrier == plr)
            {
                if (_dropTime != 0)
                {
                    _targetCart = targetCart;
                    plr.KneelDown(_targetCart.Oid, true, (ushort)_dropTime);

                    plr.EvtInterface.AddEventNotify(EventName.OnMove, OnPlayerMove);
                    plr.EvtInterface.AddEventNotify(EventName.OnDie, OnPlayerDied);
                    plr.EvtInterface.AddEventNotify(EventName.OnReceiveDamage, OnPlayerDamage);
                    _dropDel = new EventDelegateEx(OnDroppedOff);
                    plr.EvtInterface.AddEvent(_dropDel, _dropTime, 1, plr);

#if (DEBUG)
                    Log.Info("Part.BeginDropOff()", "Event Added: OnDroppedOff should be called in 2s");
#endif
                }
                else
                {
                    DropOff(plr);
                }
            }
        }
 public void RemoveEvent(EventDelegateEx del)
 {
     lock (_eventList)
         for (int i = _eventList.Count - 1; i >= 0; --i)
         {
             if (_eventList[i].DelEx == del)
             {
                 _eventList[i].ToDelete = true;
             }
         }
 }
Exemple #5
0
        private void StopInteract(Player plr)
        {
#if (DEBUG)
            Log.Info("Part.StopInteract()", "Stopping interaction for " + plr.Name);
#endif
            plr.EvtInterface.RemoveEventNotify(EventName.OnMove, OnPlayerMove);
            plr.EvtInterface.RemoveEventNotify(EventName.OnDie, OnPlayerDied);
            plr.EvtInterface.RemoveEventNotify(EventName.OnReceiveDamage, OnPlayerDamage);

            if (_dropDel != null && plr == _carrier)
            {
                if (_targetCart == null)
                {
                    plr.KneelDown(Oid, false);
                }
                plr.KneelDown(Oid, false);

                plr.EvtInterface.RemoveEvent(_dropDel);
                _dropDel = null;
            }

            Interact interact = null;
            lock (_interacting)
            {
                foreach (var i in _interacting.Where(e => e.Player == plr).ToList())
                {
#if (DEBUG)
                    Log.Info("Part.StopInteract()", "Removing Interaction for " + i.Player.Name);
#endif
                    interact = i;
                    i.Stop();
                    _interacting.Remove(i);
                }
            }

            if (interact != null)
            {
                EvtInterface.RemoveEvent(interact.Del);
            }
            if (_targetCart == null)
            {
                plr.KneelDown(Oid, false);
            }
            else
            {
#if (DEBUG)
                Log.Info("Part.StopInteract()", "Ending kneeling animation for " + plr.Name);
#endif
                plr.KneelDown(_targetCart.Oid, false);
                _targetCart = null;
            }
        }
        public EventInfo(EventDelegateEx del, int interval, int count, object userData)
        {
            DelEx     = del;
            Interval  = interval;
            Count     = count;
            BaseCount = count;
            UserData  = userData;
            if (interval == 0)
            {
                ToDelete = true;
            }

            //Log.Success("AddEvent", "Del =" + Del.Method.Name + ",Name" + Del.Target.ToString());
        }
 public bool HasEvent(EventDelegateEx del)
 {
     lock (_eventList)
     {
         for (int i = 0; i < _eventList.Count; ++i)
         {
             if (_eventList[i].DelEx == del)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 /// <summary>
 /// Registers a new delayed event expecting user data.
 /// </summary>
 /// <param name="del">Delegate to invoke when event is fired</param>
 /// <param name="interval">LastUpdatedTime before first execution and between each execution</param>
 /// <param name="count">Number of expected executions, if 0 executions has no limit</param>
 /// <param name="userData">Custom user data</param>
 public void AddEvent(EventDelegateEx del, int interval, int count, object userData)
 {
     lock (_eventList)
         _eventList.Add(new EventInfo(del, interval, count, userData));
 }