using UnityEngine; // Защита ресурсов от грабежа (контракт IResourceProtection, 01.11, ТЕСТ). // Часть запаса прячут Склады и Амбары: EconomyConfig, раздел "Защита ресурсов". Уровни зданий сообщает // App/CitySync; на карте мира, где города нет, действуют последние известные уровни. public sealed class ResourceProtection : IResourceProtection { public static int WarehouseLevels { get; private set; } public static int GranaryLevels { get; private set; } public static void SetLevels(int warehouseLevels, int granaryLevels) { WarehouseLevels = Mathf.Max(0, warehouseLevels); GranaryLevels = Mathf.Max(0, granaryLevels); } public float Protected(ResourceType type) { return EconomyConfig.Load().GetProtected(type, WarehouseLevels, GranaryLevels); } public float Lootable(ResourceType type) { if (!GameServices.TryGet(out IEconomy economy)) return 0f; return Mathf.Max(0f, economy.Get(type) - Protected(type)); } }