コード例 #1
0
        public async Task <InvokeResult> AddManagedAssetAsync(ManagedAsset asset, EntityHeader org, EntityHeader user)
        {
            var assetSet = await _assetSetRepo.GetAssetSetAsync(asset.AssetSetId);

            await AuthorizeAsync(assetSet, AuthorizeActions.Update, user, org);

            await _managedAssetRepo.AddManagedAssetAsync(asset);

            return(InvokeResult.Success);
        }
コード例 #2
0
        /// <summary>Updates the properties of an asset.</summary>
        /// <param name="internalAnimalName">The internal name of the animal the sprite sheet is for.</param>
        /// <param name="internalAnimalSubtypeName">The internal name of the subtype the sprite sheet is for.</param>
        /// <param name="sourceIsBaby">The original <see cref="ManagedAsset.IsBaby"/> value.</param>
        /// <param name="sourceIsHarvested">The original <see cref="ManagedAsset.IsHarvested"/> value.</param>
        /// <param name="sourceSeason">The original <see cref="ManagedAsset.Season"/> value.</param>
        /// <param name="destinationIsBaby">The new <see cref="ManagedAsset.IsBaby"/> value.</param>
        /// <param name="destinationIsHarvested">The new <see cref="ManagedAsset.IsHarvested"/> value.</param>
        /// <param name="destinationSeason">The new <see cref="ManagedAsset.Season"/>.</param>
        public void UpdateAsset(string internalAnimalName, string internalAnimalSubtypeName, bool sourceIsBaby, bool sourceIsHarvested, string sourceSeason, bool destinationIsBaby, bool destinationIsHarvested, string destinationSeason)
        {
            var oldManagedAsset = new ManagedAsset(internalAnimalName, internalAnimalSubtypeName, sourceIsBaby, sourceIsHarvested, sourceSeason, null);

            // remove a preexisting asset and add the new one
            var managedAssetEqualityComparer = new ManagedAssetEqualityComparer();
            var registedAsset = RegisteredAssets.FirstOrDefault(ra => managedAssetEqualityComparer.Equals(ra, oldManagedAsset));

            if (registedAsset != null)
            {
                RegisteredAssets.Remove(registedAsset);
                RegisteredAssets.Add(new ManagedAsset(internalAnimalName, internalAnimalSubtypeName, destinationIsBaby, destinationIsHarvested, destinationSeason, registedAsset.RelativeTexturePath, registedAsset.ContentPackAssetOwner));
            }
        }
コード例 #3
0
        /// <summary>Registers a spritesheet for an animal.</summary>
        /// <param name="internalAnimalName">The internal name of the animal the sprite sheet is for.</param>
        /// <param name="internalAnimalSubtypeName">The internal name of the subtype the sprite sheet is for.</param>
        /// <param name="isBaby">Whether the sprite sheet is for the baby version of the animal.</param>
        /// <param name="isHarvested">Whether the sprite sheet is for the harvested version of the animal.</param>
        /// <param name="season">The season the sprite sheet is for of the animal.</param>
        /// <param name="relativeTexturePath">The path to the sprite sheet relative to <paramref name="contentPackOwner"/>.</param>
        /// <param name="contentPackOwner">The content pack that owns the asset.</param>
        public void RegisterAsset(string internalAnimalName, string internalAnimalSubtypeName, bool isBaby, bool isHarvested, string season, string relativeTexturePath, IContentPack contentPackOwner)
        {
            var newManagedAsset = new ManagedAsset(internalAnimalName, internalAnimalSubtypeName, isBaby, isHarvested, season, relativeTexturePath, contentPackOwner);

            // remove a preexisting asset if one exists, this is the case if an animal's asset is being editing by another content pack
            var managedAssetEqualityComparer = new ManagedAssetEqualityComparer();
            var registedAsset = RegisteredAssets.FirstOrDefault(ra => managedAssetEqualityComparer.Equals(ra, newManagedAsset));

            if (registedAsset != null)
            {
                RegisteredAssets.Remove(registedAsset);
            }

            RegisteredAssets.Add(newManagedAsset);
        }
コード例 #4
0
        /*********
        ** Public Methods
        *********/
        /// <summary>Registers a shop icon for an animal to be loaded from game content.</summary>
        /// <param name="internalAnimalName">The internal name of the animal the shop icon is for.</param>
        /// <param name="relativeTexturePath">The path to the shop icon relative to the game content folder.</param>
        /// <param name="sourceRectangle">The source rectangle of the shop icon.</param>
        public void RegisterAsset(string internalAnimalName, string relativeTexturePath, Rectangle sourceRectangle)
        {
            var newManagedAsset = new ManagedAsset(internalAnimalName, relativeTexturePath, sourceRectangle);

            // remove a preexisting asset if one exists, this is the case if an animal's assets are being editing by another pack
            var managedAssetEqualityComparer = new ManagedAssetEqualityComparer();
            var registedAsset = RegisteredAssets.FirstOrDefault(ra => managedAssetEqualityComparer.Equals(ra, newManagedAsset));

            if (registedAsset != null)
            {
                RegisteredAssets.Remove(registedAsset);
            }

            RegisteredAssets.Add(newManagedAsset);
        }