/// <summary> /// Returns the authority state of the GameObject over the specified component. /// </summary> /// <exception cref="InvalidOperationException"> /// If the GameObject is not a SpatialOS entity, or the authority for this entity could not be accessed. /// </exception> public static Authority GetAuthority(this GameObject obj, uint componentId) { var entityObject = obj.GetSpatialOsEntity(); if (entityObject == null) { throw new InvalidOperationException(string.Format("{0} is not a SpatialOS-related entity.", obj)); } Improbable.Collections.Map <uint, Authority> authorityForComponentsOfEntity; if (!SpatialOS.Dispatcher.Authority.TryGetValue(entityObject.EntityId, out authorityForComponentsOfEntity)) { throw new InvalidOperationException( string.Format("Authority information for entity {0} could not be accessed.", obj)); } Authority authorityForComponent; if (!authorityForComponentsOfEntity.TryGetValue(componentId, out authorityForComponent)) { // It is possible that this worker cannot even see the component. // That means it certainly is not authoritative over it. authorityForComponent = Authority.NotAuthoritative; } return(authorityForComponent); }