Пример #1
0
        public void addThreat(float modThreat)
        {
            if (modThreat == 0.0f)
            {
                return;
            }

            iThreat += modThreat;

            // the threat is changed. Source and target unit have to be available
            // if the link was cut before relink it again
            if (!isOnline())
            {
                updateOnlineStatus();
            }

            ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefThreatChange, this, modThreat);

            fireStatusChanged(Event);

            if (isValid() && modThreat > 0.0f)
            {
                Unit victimOwner = getTarget().GetCharmerOrOwner();
                if (victimOwner != null && victimOwner.IsAlive())
                {
                    GetSource().addThreat(victimOwner, 0.0f);     // create a threat to the owner of a pet, if the pet attacks
                }
            }
        }
Пример #2
0
 void fireStatusChanged(ThreatRefStatusChangeEvent threatRefStatusChangeEvent)
 {
     if (GetSource() != null)
     {
         GetSource().processThreatEvent(threatRefStatusChangeEvent);
     }
 }
Пример #3
0
        // reference is not needed anymore. realy delete it !
        public void removeReference()
        {
            invalidate();

            ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefRemoveFromList, this);

            fireStatusChanged(Event);
        }
Пример #4
0
        public void ProcessThreatEvent(ThreatRefStatusChangeEvent threatRefStatusChangeEvent)
        {
            threatRefStatusChangeEvent.SetThreatManager(this);     // now we can set the threat manager

            HostileReference hostilRef = threatRefStatusChangeEvent.GetReference();

            switch (threatRefStatusChangeEvent.GetEventType())
            {
            case UnitEventTypes.ThreatRefThreatChange:
                if ((getCurrentVictim() == hostilRef && threatRefStatusChangeEvent.GetFValue() < 0.0f) ||
                    (getCurrentVictim() != hostilRef && threatRefStatusChangeEvent.GetFValue() > 0.0f))
                {
                    SetDirty(true);                                 // the order in the threat list might have changed
                }
                break;

            case UnitEventTypes.ThreatRefOnlineStatus:
                if (!hostilRef.IsOnline())
                {
                    if (hostilRef == getCurrentVictim())
                    {
                        SetCurrentVictim(null);
                        SetDirty(true);
                    }
                    Owner.SendRemoveFromThreatList(hostilRef);
                    threatContainer.Remove(hostilRef);
                    threatOfflineContainer.AddReference(hostilRef);
                }
                else
                {
                    if (GetCurrentVictim() != null && hostilRef.GetThreat() > (1.1f * getCurrentVictim().GetThreat()))
                    {
                        SetDirty(true);
                    }
                    threatContainer.AddReference(hostilRef);
                    threatOfflineContainer.Remove(hostilRef);
                }
                break;

            case UnitEventTypes.ThreatRefRemoveFromList:
                if (hostilRef == getCurrentVictim())
                {
                    SetCurrentVictim(null);
                    SetDirty(true);
                }
                Owner.SendRemoveFromThreatList(hostilRef);
                if (hostilRef.IsOnline())
                {
                    threatContainer.Remove(hostilRef);
                }
                else
                {
                    threatOfflineContainer.Remove(hostilRef);
                }
                break;
            }
        }
Пример #5
0
        void setAccessibleState(bool isAccessible)
        {
            if (iAccessible != isAccessible)
            {
                iAccessible = isAccessible;

                ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefAccessibleStatus, this);
                fireStatusChanged(Event);
            }
        }
Пример #6
0
        public void addTempThreat(float threat)
        {
            if (threat == 0.0f)
            {
                return;
            }

            iTempThreatModifier += threat;

            ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefThreatChange, this, threat);

            fireStatusChanged(Event);
        }
Пример #7
0
 public void setOnlineOfflineState(bool isOnline)
 {
     if (iOnline != isOnline)
     {
         iOnline = isOnline;
         if (!iOnline)
         {
             setAccessibleState(false);                      // if not online that not accessable as well
         }
         ThreatRefStatusChangeEvent Event = new ThreatRefStatusChangeEvent(UnitEventTypes.ThreatRefOnlineStatus, this);
         fireStatusChanged(Event);
     }
 }