Exemplo n.º 1
0
        private async Task RefreshCreatureData([NotNull] ICreatureDataServiceClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            try
            {
                DisplayProgressBar("Refreshing Creature", "Creature Instance (1/2).", 0.0f);

                CreatureInstanceModel instanceData = await RefreshCreatureInstanceData(client);

                //If the creature instance exists and we have a valid template assigned.
                if (instanceData != null && instanceData.TemplateId > 0)
                {
                    DisplayProgressBar("Refreshing Creature", "Creature Template (2/2).", 0.0f);
                    await RefreshCreatureTemplateData(client);
                }
            }
            catch (Exception e)
            {
                Debug.LogError($"Failed to refresh Creature. Reason: {e.Message}");
                throw;
            }
            finally
            {
                ClearProgressBar();
            }
        }
Exemplo n.º 2
0
        private async Task RefreshCreatureTemplateData(ICreatureDataServiceClient client)
        {
            //TODO: This is just for testing, we should properly handle this
            ResponseModel <CreatureTemplateModel, SceneContentQueryResponseCode> templateModelResponse = await client.GetCreatureTemplate(GetTarget().CreatureTemplateId);

            var result = templateModelResponse.Result;

            CachedCreatureTemplateInfoText = $"Creature Template: {GetTarget().CreatureTemplateId}\nName: {result.CreatureName}\nModel Id: {result.ModelId}\nLevel Range: {result.MinimumLevel}-{result.MaximumLevel}";
        }
Exemplo n.º 3
0
 public RequestStaticCreatureSpawnsEventListener(IServerStartingEventSubscribable subscriptionService,
                                                 [NotNull] ICreatureDataServiceClient creatureContentDataClient,
                                                 [NotNull] IEventPublisher <IEntityCreationRequestedEventSubscribable, EntityCreationRequestedEventArgs> entityCreationRequester,
                                                 [NotNull] IFactoryCreatable <NetworkEntityGuid, CreatureInstanceModel> creatureGuidFactory,
                                                 [NotNull] ILog logger, [NotNull] IEntityGuidMappable <CreatureTemplateModel> creatureTemplateMappable,
                                                 [NotNull] IEntityGuidMappable <CreatureInstanceModel> creatureInstanceMappable, WorldConfiguration worldConfiguration)
     : base(subscriptionService)
 {
     CreatureContentDataClient = creatureContentDataClient ?? throw new ArgumentNullException(nameof(creatureContentDataClient));
     EntityCreationRequester   = entityCreationRequester ?? throw new ArgumentNullException(nameof(entityCreationRequester));
     CreatureGuidFactory       = creatureGuidFactory ?? throw new ArgumentNullException(nameof(creatureGuidFactory));
     Logger = logger ?? throw new ArgumentNullException(nameof(logger));
     CreatureTemplateMappable = creatureTemplateMappable ?? throw new ArgumentNullException(nameof(creatureTemplateMappable));
     CreatureInstanceMappable = creatureInstanceMappable ?? throw new ArgumentNullException(nameof(creatureInstanceMappable));
     WorldConfiguration       = worldConfiguration;
 }
Exemplo n.º 4
0
        private async Task <CreatureInstanceModel> RefreshCreatureInstanceData([NotNull] ICreatureDataServiceClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            ResponseModel <CreatureInstanceModel, SceneContentQueryResponseCode> queryResponseModel = await client.GetCreatureInstance(GetTarget().CreatureInstanceId);

            //TODO: No idea what should be done here.
            if (!queryResponseModel.isSuccessful)
            {
                return(null);
            }

            CachedCreatureInfoText         = $"Creature Instance: {GetTarget().CreatureInstanceId}\nGuid: {queryResponseModel.Result.Guid}\nSpawnPosition: {queryResponseModel.Result.InitialPosition}\nYRotation: {queryResponseModel.Result.YAxisRotation}";
            GetTarget().CreatureTemplateId = queryResponseModel.Result.TemplateId;

            return(queryResponseModel.Result);
        }
Exemplo n.º 5
0
        private void CreateCreatureInstance(ICreatureDataServiceClient client, WorldDefinitionData worldData)
        {
            DisplayProgressBar("Creating Creature", "Requesting instance (1/2)", 0.0f);

            UnityAsyncHelper.UnityMainThreadContext.Post(async o =>
            {
                try
                {
                    //If they press this, we need to actually create a creature instance for this world id.
                    var result = await client.CreateCreatureInstance(worldData.ContentId);

                    if (result.isSuccessful)
                    {
                        DisplayProgressBar("Creating Creature", "Saving Instance (2/2)", 0.5f);

                        GetTarget().CreatureInstanceId = result.Result.Guid.EntryId;
                        EditorUtility.SetDirty(GetTarget());
                        EditorSceneManager.MarkSceneDirty(GetTarget().gameObject.scene);

                        await RefreshCreatureData(client);
                    }
                    else
                    {
                        Debug.LogError($"Failed to create Creature Instance. Reason: {result.ResultCode}");
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError($"Failed to create Creature Instance. Reason: {e.Message}");
                    throw;
                }
                finally
                {
                    ClearProgressBar();
                }
            }, null);
        }