Пример #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);
                }
            }
        }