private async Task RefreshGameObjectData([NotNull] IGameObjectDataServiceClient client) { if (client == null) { throw new ArgumentNullException(nameof(client)); } try { DisplayProgressBar("Refreshing GameObject", "GameObject Instance (1/2).", 0.0f); GameObjectInstanceModel instanceData = await RefreshGameObjectInstanceData(client); //If the creature instance exists and we have a valid template assigned. if (instanceData != null && instanceData.TemplateId > 0) { DisplayProgressBar("Refreshing GameObject", "GameObject Template (2/2).", 0.0f); await RefreshGameObjectTemplateData(client); } } catch (Exception e) { Debug.LogError($"Failed to refresh GameObject. Reason: {e.Message}"); throw; } finally { ClearProgressBar(); } }
private async Task RefreshGameObjectTemplateData(IGameObjectDataServiceClient client) { //TODO: This is just for testing, we should properly handle this ResponseModel <GameObjectTemplateModel, SceneContentQueryResponseCode> templateModelResponse = await client.GetGameObjectTemplate(GetTarget().GameObjectTemplateId); var result = templateModelResponse.Result; CachedGameObjectType = templateModelResponse.Result.ObjectType; CachedGameObjectTemplateInfoText = $"GameObject Template: {GetTarget().GameObjectTemplateId}\nName: {result.GameObjectName}\nModel Id: {result.ModelId}\nType: {result.ObjectType.ToString()}"; }
private async Task <GameObjectInstanceModel> RefreshGameObjectInstanceData([NotNull] IGameObjectDataServiceClient client) { if (client == null) { throw new ArgumentNullException(nameof(client)); } ResponseModel <GameObjectInstanceModel, SceneContentQueryResponseCode> queryResponseModel = await client.GetGameObjectInstance(GetTarget().GameObjectInstanceId); //TODO: No idea what should be done here. if (!queryResponseModel.isSuccessful) { return(null); } CachedGameObjectInfoText = $"GameObject Instance: {GetTarget().GameObjectInstanceId}\nGuid: {queryResponseModel.Result.Guid}\nSpawnPosition: {queryResponseModel.Result.InitialPosition}\nYRotation: {queryResponseModel.Result.YAxisRotation}"; GetTarget().GameObjectTemplateId = queryResponseModel.Result.TemplateId; return(queryResponseModel.Result); }
public RemoteGameObjectDataService( [NotNull] IEntityGuidMappable <GameObjectTemplateModel> gameObjectTemplateMappable, [NotNull] IEntityGuidMappable <GameObjectInstanceModel> gameObjectInstanceMappable, [NotNull] IGameObjectDataServiceClient dataServiceClient, [NotNull] WorldConfiguration worldConfiguration, [NotNull] ILog logger, [NotNull] IGameObjectBehaviourDataServiceClient <WorldTeleporterInstanceModel> teleporterDataServiceClient, [NotNull] IGameObjectBehaviourDataServiceClient <AvatarPedestalInstanceModel> avatarPedestalDataServiceClient) { _GameObjectTemplateMappable = gameObjectTemplateMappable ?? throw new ArgumentNullException(nameof(gameObjectTemplateMappable)); _GameObjectInstanceMappable = gameObjectInstanceMappable ?? throw new ArgumentNullException(nameof(gameObjectInstanceMappable)); DataServiceClient = dataServiceClient ?? throw new ArgumentNullException(nameof(dataServiceClient)); WorldConfiguration = worldConfiguration ?? throw new ArgumentNullException(nameof(worldConfiguration)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); TeleporterDataServiceClient = teleporterDataServiceClient ?? throw new ArgumentNullException(nameof(teleporterDataServiceClient)); AvatarPedestalDataServiceClient = avatarPedestalDataServiceClient; BehaviourInstanceDataMappable = new Dictionary <Type, IEntityGuidMappable <object> >(5); }
private void CreateGameObjectInstance(IGameObjectDataServiceClient client, WorldDefinitionData worldData) { DisplayProgressBar("Creating GameObject", "Requesting instance (1/2)", 0.0f); UnityAsyncHelper.UnityMainThreadContext.Post(async o => { try { //If they press this, we need to actually create a gameobject instance for this world id. var result = await client.CreateGameObjectInstance(worldData.ContentId); if (result.isSuccessful) { DisplayProgressBar("Creating GameObject", "Saving Instance (2/2)", 0.5f); GetTarget().GameObjectInstanceId = result.Result.Guid.EntryId; EditorUtility.SetDirty(GetTarget()); EditorSceneManager.MarkSceneDirty(GetTarget().gameObject.scene); await RefreshGameObjectData(client); } else { Debug.LogError($"Failed to create GameObject Instance. Reason: {result.ResultCode}"); } } catch (Exception e) { Debug.LogError($"Failed to create GameObject Instance. Reason: {e.Message}"); throw; } finally { ClearProgressBar(); } }, null); }