Refactor products and buildings to support modding
This commit is contained in:
@@ -6,9 +6,9 @@ namespace MyBiz.Core;
|
||||
public class ProductionStep
|
||||
{
|
||||
/// <summary>
|
||||
/// Требуемый продукт
|
||||
/// ID требуемого продукта
|
||||
/// </summary>
|
||||
public ProductType InputProduct { get; set; }
|
||||
public string InputProductId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Количество требуемого продукта
|
||||
@@ -22,16 +22,104 @@ public class ProductionStep
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Производственная цепочка
|
||||
/// Конфигурация производственной цепочки - для моддинга
|
||||
/// </summary>
|
||||
public class ProductionChain
|
||||
public class ProductionChainConfig
|
||||
{
|
||||
public ProductType OutputProduct { get; set; }
|
||||
public BuildingType RequiredBuilding { get; set; }
|
||||
public List<ProductionStep> Steps { get; set; } = new();
|
||||
/// <summary>
|
||||
/// Уникальный идентификатор цепочки
|
||||
/// </summary>
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Название цепочки
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ID выходного продукта
|
||||
/// </summary>
|
||||
public string OutputProductId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Количество выходного продукта за цикл
|
||||
/// </summary>
|
||||
public int OutputQuantity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ID требуемого здания
|
||||
/// </summary>
|
||||
public string RequiredBuildingId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Шаги производства
|
||||
/// </summary>
|
||||
public List<ProductionStep> Steps { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Требуемые технологии
|
||||
/// </summary>
|
||||
public List<string> RequiredTechnologies { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Год, когда цепочка становится доступной
|
||||
/// </summary>
|
||||
public int AvailableFromYear { get; set; } = 1900;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Активная производственная цепочка на здании
|
||||
/// </summary>
|
||||
public class ActiveProductionChain
|
||||
{
|
||||
public ProductionChainConfig Config { get; set; } = null!;
|
||||
public Building Building { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Текущий шаг производства
|
||||
/// </summary>
|
||||
public int CurrentStep { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Прогресс текущего шага (в тиках)
|
||||
/// </summary>
|
||||
public int Progress { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Цепочка активна
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Запущена в тик
|
||||
/// </summary>
|
||||
public int StartedAtTick { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Проверка: завершён ли текущий шаг
|
||||
/// </summary>
|
||||
public bool IsStepComplete => CurrentStep < Config.Steps.Count &&
|
||||
Progress >= Config.Steps[CurrentStep].ProductionTime;
|
||||
|
||||
/// <summary>
|
||||
/// Проверка: завершено ли всё производство
|
||||
/// </summary>
|
||||
public bool IsComplete => CurrentStep >= Config.Steps.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Продвинуть производство на 1 тик
|
||||
/// </summary>
|
||||
public void Tick()
|
||||
{
|
||||
if (!IsActive || IsComplete)
|
||||
return;
|
||||
|
||||
Progress++;
|
||||
|
||||
if (IsStepComplete)
|
||||
{
|
||||
CurrentStep++;
|
||||
Progress = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user