/// <inheritdoc /> public GroupUnitFrameIssueResult TryClaimUnitFrame(NetworkEntityGuid guid) { if (guid.EntityType != EntityType.Player) { return(GroupUnitFrameIssueResult.FailedNotAPlayer); } lock (SyncObj) { if (OwnedGroupUnitFrames.ContainsKey(guid)) { return(GroupUnitFrameIssueResult.FailedAlreadyClaimedUnitframe); } if (!AvailableUnitFrames.Any()) { return(GroupUnitFrameIssueResult.FailedUnitframeUnavailable); } //Otherwise, at this point we're in a proper state to associate a unitframe OwnedGroupUnitFrames.Add(guid, new ClaimedGroupUnitFrame(AvailableUnitFrames.Pop())); } return(GroupUnitFrameIssueResult.Success); }
/// <inheritdoc /> public GroupUnitFrameReleaseResult TryReleaseUnitFrame(NetworkEntityGuid guid) { if (guid.EntityType != EntityType.Player) { return(GroupUnitFrameReleaseResult.FailedNotAPlayer); } lock (SyncObj) { if (!OwnedGroupUnitFrames.ContainsKey(guid)) { return(GroupUnitFrameReleaseResult.FailedNoUnitFrameClaimed); } var current = OwnedGroupUnitFrames[guid]; OwnedGroupUnitFrames.Remove(guid); current.ClearRegisteredCallbacks(); //this clears up all callbacks associated with the registeration. AvailableUnitFrames.Push(current.UnitFrame); } return(GroupUnitFrameReleaseResult.Sucess); }