private void OnHarvestResponse(ICommandCallbackResponse <HarvestResponse> response) { if (response.StatusCode == StatusCode.Failure) { Debug.LogError("NPC failed to receive Harvest response"); return; } inventoryInterface.AddToInventory(response.Response.Value.resourcesTaken); StartCoroutine(ChangeStateAfter(SimulationSettings.NPCChoppingAnimationFinishTime, LumberjackFSMState.StateEnum.IDLE)); }
public void Trigger(ICommandCallbackResponse <TResponse> response) { if (response.StatusCode == StatusCode.Success) { TriggerSuccess(response); } else { TriggerFailure(response); } }
private void OnStockpileResponse(ICommandCallbackResponse <Nothing> response, int resourcesToAdd) { if (response.StatusCode == StatusCode.Failure) { Debug.LogError("NPC failed to receive Stockpile response"); } else { inventory.RemoveFromInventory(resourcesToAdd); } TransitionToIdle(); }
private void OnHarvestResponse(ICommandCallbackResponse <HarvestResponse> response) { if (response.StatusCode == StatusCode.Failure) { Debug.LogError("NPC failed to receive Harvest response"); } else { inventory.AddToInventory(response.Response.Value.resourcesTaken); } TransitionToIdle(); }
private void TriggerFailure(ICommandCallbackResponse <TResponse> response) { while (failureCallbacks.Count > 0) { try { failureCallbacks.Dequeue()(response); } catch (Exception e) { Debug.LogException(e); } } }
private void TriggerSuccess(ICommandCallbackResponse <TResponse> response) { while (successCallbacks.Count > 0) { try { successCallbacks.Dequeue()(response.Response.Value); } catch (Exception e) { Debug.LogException(e); } } }
private static void OnSearchResult(Action <EntityId> callback, ICommandCallbackResponse <EntityQueryResult> response) { if (!response.Response.HasValue || response.StatusCode != Improbable.Worker.StatusCode.Success) { Debug.LogError("Find player spawner query failed with error: " + response.ErrorMessage); return; } var result = response.Response.Value; if (result.EntityCount <= 0) { Debug.LogError("Failed to find player spawner: no entities found with the PlayerSpawner component."); return; } _simulationManagerEntityId = result.Entities.First.Value.Key; callback(_simulationManagerEntityId); }
private static void OnSpawnPlayerResponse(EntityId simulationManagerEntityId, ICommandCallbackResponse <SpawnPlayerResponse> response) { if (!response.Response.HasValue || response.StatusCode != Improbable.Worker.StatusCode.Success) { Debug.LogError("SpawnPlayer command failed: " + response.ErrorMessage); RequestPlayerSpawn(simulationManagerEntityId); return; } }
private void OnPlayerCreation(ResponseHandle <PlayerLifeCycle.Commands.SpawnPlayer, SpawnPlayerRequest, SpawnPlayerResponse> responseHandle, ICommandCallbackResponse <EntityId> response) { if (response.StatusCode != StatusCode.Success) { Debug.LogError("player spawner failed to create entity: " + response.ErrorMessage); return; } playerEntityIds.Add(responseHandle.CallerInfo.CallerWorkerId, response.Response.Value); responseHandle.Respond(new SpawnPlayerResponse(response.Response.Value)); }
private static void OnQueryResult(Action <EntityId> requestPlayerSpawnCallback, ICommandCallbackResponse <EntityQueryResult> queryResult) { if (!queryResult.Response.HasValue || queryResult.StatusCode != StatusCode.Success) { Debug.LogError("PlayerSpawner query failed. SpatialOS workers probably haven't started yet. Try again in a few seconds."); return; } var queriedEntities = queryResult.Response.Value; if (queriedEntities.EntityCount < 1) { Debug.LogError("Failed to find PlayerSpawner. SpatialOS probably hadn't finished spawning the initial snapshot. Try again in a few seconds."); return; } var playerSpawnerEntityId = queriedEntities.Entities.First.Value.Key; requestPlayerSpawnCallback(playerSpawnerEntityId); }