示例#1
0
        public static bool Add(AdvancedEntity en, EventType type)
        {
            switch (type)
            {
            case EventType.AggressiveDriver: return(SafelyAddTo(aggressiveList, en, "EventManager", type));

            case EventType.Carjacker: return(SafelyAddTo(carjackerList, en, "EventManager", type));

            case EventType.Driveby: return(SafelyAddTo(drivebyList, en, "EventManager", type));

            case EventType.Fire: return(SafelyAddTo(onFireList, en, "EventManager", type));

            case EventType.GangTeam: return(SafelyAddTo(gangList, en, "EventManager", type));

            case EventType.Massacre: return(SafelyAddTo(massacreList, en, "EventManager", type));

            case EventType.Racer: return(SafelyAddTo(racerList, en, "EventManager", type));

            case EventType.ReplacedVehicle: return(SafelyAddTo(replacedList, en, "EventManager", type));

            case EventType.Terrorist: return(SafelyAddTo(terroristList, en, "EventManager", type));

            default: return(false);
            }
        }
示例#2
0
        public static bool Add(AdvancedEntity en, DispatchType type)
        {
            switch (type)
            {
            case DispatchType.ArmyGround: return(SafelyAddTo(armyGroundList, en, "DispatchManager", type));

            case DispatchType.ArmyHeli: return(SafelyAddTo(armyHeliList, en, "DispatchManager", type));

            case DispatchType.ArmyRoadBlock: return(SafelyAddTo(armyRoadblockList, en, "DispatchManager", type));

            case DispatchType.CopGround: return(SafelyAddTo(copGroundList, en, "DispatchManager", type));

            case DispatchType.CopHeli: return(SafelyAddTo(copHeliList, en, "DispatchManager", type));

            case DispatchType.CopRoadBlock: return(SafelyAddTo(copRoadblockList, en, "DispatchManager", type));

            case DispatchType.Emergency: return(SafelyAddTo(emList, en, "DispatchManager", type));

            case DispatchType.Shield: return(SafelyAddTo(shieldList, en, "DispatchManager", type));

            case DispatchType.Stinger: return(SafelyAddTo(stingerList, en, "DispatchManager", type));

            default: return(false);
            }
        }
示例#3
0
        protected static bool SafelyAddTo(List <AdvancedEntity> list, AdvancedEntity item, string name, Enum type)
        {
            if (list == null || item == null || name == null)
            {
                return(false);
            }

            bool lockTaken = false;

            try
            {
                Monitor.Enter(list, ref lockTaken);
                list.Add(item);
            }
            catch (Exception e)
            {
                Logger.Error(e.Message + "\n" + e.StackTrace, type.ToString());
            }
            finally
            {
                if (lockTaken)
                {
                    Logger.Write(false, name + ": Successfully added new entity.", type.ToString());
                    Monitor.Exit(list);
                }
            }

            return(lockTaken);
        }