public bool Commit(MapStoreId mapStoreId)
        {
            // Note: We could create an EditorDataStore implementation instead, but for this little code, we can
            // just do it inline.
#if !UNITY_EDITOR
            _logger.LogError(LoggedFeature.Assets, "Commit(MapStoreId) called when not on editor.");
            return(false);
#else
            var mapReference = _addressableAssetMapReferences.Find(x => x.MapStoreId == mapStoreId);
            if (mapReference == null)
            {
                var msg = $"Invalid MapId: {mapStoreId}";
                _logger.LogError(LoggedFeature.Assets, msg);
                return(false);
            }

            EditorUtility.SetDirty(mapReference.AssetReference.editorAsset);
            AssetDatabase.SaveAssets();
            return(true);
#endif
        }
Esempio n. 2
0
        public override bool Equals(object other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (other.GetType() != GetType())
            {
                return(false);
            }

            MapStoreId otherMapStoreId = (MapStoreId)other;

            return(otherMapStoreId.index == index);
        }
        public async UniTask <IMutableMapData> LoadMap(MapStoreId mapStoreId)
        {
            var mapReference = _addressableAssetMapReferences.Find(x => x.MapStoreId == mapStoreId);

            if (mapReference == null)
            {
                var msg = $"Invalid MapId: {mapStoreId}";
                _logger.LogError(LoggedFeature.Assets, msg);
                throw new Exception(msg);
            }

            var handle = mapReference.AssetReference.LoadAssetAsync <SerializedMapData>();
            await UniTask.WaitUntil(() => handle.IsDone)
            .Timeout(TimeSpan.FromSeconds(10));

            if (handle.Status != AsyncOperationStatus.Succeeded)
            {
                throw new Exception($"Failed to load map: {mapReference.MapName}");
            }

            return(handle.Result);
        }