ShopData.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. /// <summary>
  4. /// Data-only structure for shop generation (not a MonoBehaviour)
  5. /// Used by SettlementContext to define shop properties
  6. /// </summary>
  7. [System.Serializable]
  8. public class ShopData
  9. {
  10. public string buildingName;
  11. public ShopType shopType;
  12. public string shopkeeperName;
  13. public Vector2Int gridPosition;
  14. public Color buildingColor;
  15. public bool isAvailable;
  16. public ShopData(string name, ShopType type, string keeper, Vector2Int position, Color color)
  17. {
  18. buildingName = name;
  19. shopType = type;
  20. shopkeeperName = keeper;
  21. gridPosition = position;
  22. buildingColor = color;
  23. isAvailable = true;
  24. }
  25. /// <summary>
  26. /// Convert this ShopData to a TownShop component on the given GameObject
  27. /// </summary>
  28. public TownShop ApplyToTownShop(GameObject shopObject)
  29. {
  30. var townShop = shopObject.GetComponent<TownShop>();
  31. if (townShop == null)
  32. townShop = shopObject.AddComponent<TownShop>();
  33. townShop.buildingName = buildingName;
  34. townShop.shopType = shopType;
  35. townShop.shopkeeperName = shopkeeperName;
  36. townShop.gridPosition = gridPosition;
  37. townShop.buildingColor = buildingColor;
  38. return townShop;
  39. }
  40. }