예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
 /// <inheritdoc />
 public bool Contains(NetworkEntityGuid entity)
 {
     lock (SyncObj)
         return(OwnedGroupUnitFrames.ContainsKey(entity));
 }