supervisor-simulator/scripts/Models/UnitComponents.cs
wjsjwr b8fecd080f 已把模型层改成组合式结构并补齐 MVC/内容配置骨架:Unit/任务/运行时状态现在通过组件组合,GameManager 作为桥接层改为驱动 GameSession/Controller;同时新增学科/羁绊/装备/任务/肉鸽等定义结构,预留 i18n 与 Mod 内容加载接口。
- 组合式单位与数值基础重构:scripts/Models/UnitModel.cs, scripts/Models/UnitComponents.cs, scripts/Models/StudentModel.cs, scripts/Models/MentorModel.cs, scripts/Models/StaffModel.cs, scripts/Models/PropertyValue.cs, scripts/Models/StatusValue.cs
  - 任务与运行时状态骨架:scripts/Models/Task.cs, scripts/Models/TaskDefinitions.cs, scripts/Models/GameState.cs
  - 配置与规则定义骨架:scripts/Models/DefinitionSupport.cs, scripts/Models/DomainEnums.cs, scripts/Models/Modifiers.cs, scripts/Models/DisciplineDefinitions.cs, scripts/Models/SynergyDefinitions.cs, scripts/Models/ItemDefinitions.cs, scripts/Models/PaperDefinitions.cs, scripts/Models/RogueliteDefinitions.cs, scripts/Models/GameContentDatabase.cs, scripts/Models/CoreIds.cs
  - MVC/会话/系统/i18n/Mod 支撑:scripts/Core/GameSession.cs, scripts/Core/GameSystems.cs, scripts/Core/GameController.cs, scripts/Core/Mvc.cs, scripts/Core/LocalizationService.cs, scripts/Core/ContentRegistry.cs, scripts/Core/ModManifest.cs, scripts/Core/EventBus.cs
  - 主控流程衔接:scripts/GameManager.cs
2025-12-31 23:54:31 +08:00

111 lines
3.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
namespace Models;
/// <summary>
/// Unit 组件集合(组合优于继承)
/// 设计说明:
/// 1) UnitModel 只是“组件容器”,具体能力拆分到小组件中,便于复用与替换。
/// 2) 组件保持低内聚小职责,避免“巨型基类”造成的隐式耦合。
/// 3) 这些组件只描述数据,不包含具体行为,行为交给系统/控制器层。
/// 注意事项:
/// - 不引用 Godot 类型,保持纯数据层,利于测试与序列化。
/// - 标识/标签使用 string Id方便 Mod 扩展新增内容。
/// 未来扩展:
/// - 可以给组件增加“快照/脏标记”,用于高效 UI 刷新。
/// - 需要网络联机时,可在这里加入序列化版本号。
/// </summary>
public static class UnitComponents
{
public readonly struct GridPosition
{
public int X { get; }
public int Y { get; }
public GridPosition(int x, int y)
{
X = x;
Y = y;
}
public static GridPosition Zero => new(0, 0);
}
public sealed class UnitIdentity
{
public Guid Id { get; } = Guid.NewGuid();
public string Name { get; set; }
public string NameKey { get; set; }
public UnitIdentity(string name, string nameKey = null)
{
Name = name;
NameKey = nameKey;
}
}
public sealed class UnitAttributes
{
public PropertyValue Academic { get; set; }
public PropertyValue Engineering { get; set; }
public PropertyValue Writing { get; set; }
public PropertyValue Financial { get; set; }
public PropertyValue Social { get; set; }
public PropertyValue Activation { get; set; }
public UnitAttributes(Random random = null)
{
var rng = random ?? Random.Shared;
Academic = new PropertyValue(rng.Next(0, 100));
Engineering = new PropertyValue(rng.Next(0, 100));
Writing = new PropertyValue(rng.Next(0, 100));
Financial = new PropertyValue(rng.Next(0, 100));
Social = new PropertyValue(rng.Next(0, 100));
Activation = new PropertyValue(rng.Next(0, 100));
}
}
public sealed class UnitStatuses
{
public StatusValue Stress { get; set; }
public StatusValue Sanity { get; set; }
public PropertyValue Mood { get; set; }
public PropertyValue MoveSpeed { get; set; }
public UnitStatuses()
{
Stress = new StatusValue(0, 100, 0);
Sanity = new StatusValue(100, 100, 0);
Mood = new PropertyValue(50);
MoveSpeed = new PropertyValue(50, 0, 200);
}
}
public sealed class UnitTags
{
public string DisciplineId { get; set; }
public List<string> ArchetypeIds { get; } = new();
public List<string> RoleIds { get; } = new();
public List<string> TraitIds { get; } = new();
public bool HasTrait(string traitId) => TraitIds.Contains(traitId);
}
public sealed class UnitAssignment
{
public Guid? CurrentTaskId { get; set; }
}
public sealed class UnitPlacement
{
public GridPosition Current { get; set; } = GridPosition.Zero;
public GridPosition Target { get; set; } = GridPosition.Zero;
}
public sealed class UnitEquipment
{
public List<string> EquippedItemIds { get; } = new();
}
}