Exemple #1
0
        void AddThreat(Unit victim, float threat)
        {
            var reff = threatContainer.AddThreat(victim, threat);

            // Ref is not in the online refs, search the offline refs next
            if (reff == null)
            {
                reff = threatOfflineContainer.AddThreat(victim, threat);
            }

            if (reff == null) // there was no ref => create a new one
            {
                bool isFirst = threatContainer.Empty();

                // threat has to be 0 here
                var hostileRef = new HostileReference(victim, this, 0);
                threatContainer.AddReference(hostileRef);
                hostileRef.AddThreat(threat); // now we add the real threat
                if (victim.IsTypeId(TypeId.Player) && victim.ToPlayer().IsGameMaster())
                {
                    hostileRef.SetOnlineOfflineState(false); // GM is always offline
                }
                else if (isFirst)
                {
                    SetCurrentVictim(hostileRef);
                }
            }
        }
        public void SetOnlineOfflineState(bool isOnline)
        {
            HostileReference refe = GetFirst();

            while (refe != null)
            {
                refe.SetOnlineOfflineState(isOnline);
                refe = refe.Next();
            }
        }
        // set state for one reference, defined by Unit
        public void SetOnlineOfflineState(Unit creature, bool isOnline)
        {
            HostileReference refe = GetFirst();

            while (refe != null)
            {
                HostileReference nextRef = refe.Next();
                if (refe.GetSource().GetOwner() == creature)
                {
                    refe.SetOnlineOfflineState(isOnline);
                    break;
                }
                refe = nextRef;
            }
        }