Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using MoreSuitsMod.Model.Factories.Interfaces;
- using MoreSuitsMod.Model.Suit;
- using UnityEngine;
- namespace MoreSuitsMod.Model.Factories;
- /// <summary>
- /// Factory that creates a list of Unlockable Items that represents of all the Modded Unlockable Suits within the game.
- /// </summary>
- public class UnlockableSuitFactory : MonoBehaviour, IUnlockableSuitFactory
- {
- /// <inheritdoc/>
- public List<ISuit> CustomSuits { get; set; }
- /// <inheritdoc/>
- public UnlockableItem OriginalSuit { get; set; }
- /// <summary>
- /// Creates the list of Custom Unlockable Suits.
- /// </summary>
- /// <returns>The Unlockable Suits list.</returns>
- public List<UnlockableItem> Create()
- {
- List<UnlockableItem> unlockableItems = [];
- foreach (var customSuit in CustomSuits)
- {
- unlockableItems.Add(InitSuit (customSuit, unlockableItems.Count));
- }
- return unlockableItems;
- }
- /// <summary>
- /// Initializes a Custom Unlockable Suit, via the data within a Custom Suit instance.
- /// </summary>
- /// <param name="suit">The suit to create the Custom Unlockable Suit instance from.</param>
- /// <returns>The created Custom Unlockable Suit.</returns>
- private UnlockableItem InitSuit(ISuit suit, int id)
- {
- var unlockableSuit = suit.IsDefault ? OriginalSuit :
- JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson(OriginalSuit));
- unlockableSuit.suitMaterial = suit.SuitMaterial;
- unlockableSuit.unlockableName = suit.UnlockableName;
- return !suit.Price.Equals(0) ? MoreSuits.MoreSuitsMod
- .StartOfRoundPatch
- .AddSuitToShop(unlockableSuit, suit.Price, id) :
- unlockableSuit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment