public LocalIDManager_MS(GlobalAccountIDManager globalAccountIDManager, IDTypes IDType) { _IDSupplier = globalAccountIDManager; if (_IDSupplier != null) { _IDSupplier.GetFreeIDs(_minIDCount * 2); } else { ConsoleManager.WriteLine("Warning: networkIDSupplier is null in LocalIDManager constructor. This should only be the case when running DBFiller.", ConsoleMessageType.Warning); } _IDType = IDType; }
/// <summary> /// Gives the object a unique free ID, registers the object with various managers and collections /// </summary> /// <param name="obj"></param> /// <returns></returns> public int PopFreeID() { int ID; if (_minIDCount == 0) { //Just in case _minIDCount = 1000; } if (_freeIDs.Count < _minIDCount) { int[] newIDs = _IDSupplier.GetFreeIDs(_minIDCount); foreach (int i in newIDs) { _freeIDs.Push(i); } } _freeIDs.TryPop(out ID); return(ID); }
/// <summary> /// Simulates IDs which would be generated by the master server, to allow for ship creation /// </summary> /// <param name="numIDs"></param> void GenerateIDsForLocalIDManager(GlobalIDManager globalIDManager, LocalIDManager galaxyIDManager, int numIDs) { var IDs = globalIDManager.GetFreeIDs(numIDs); galaxyIDManager.ReceiveServerIDs(IDs); }