Files
WulaFallenEmpireRW/Source/WulaFallenEmpire/WULA_Shuttle/PocketSpaceThingHolder.cs
2025-08-25 15:06:43 +08:00

71 lines
2.1 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;
using Verse;
namespace WulaFallenEmpire
{
/// <summary>
/// 用于武装穿梭机口袋空间的IThingHolder实现与CompTransporter的容器分离
/// </summary>
public class PocketSpaceThingHolder : IThingHolder, IExposable
{
/// <summary>持有的物品容器</summary>
public ThingOwner<Thing> innerContainer;
/// <summary>该容器的拥有者通常是Building_ArmedShuttleWithPocket</summary>
private IThingHolder owner;
/// <summary>实现IThingHolder.ParentHolder属性</summary>
public IThingHolder ParentHolder => owner;
public PocketSpaceThingHolder()
{
innerContainer = new ThingOwner<Thing>(this);
}
public PocketSpaceThingHolder(IThingHolder owner) : this()
{
this.owner = owner;
}
/// <summary>
/// 获取直接持有的物品
/// </summary>
public ThingOwner GetDirectlyHeldThings()
{
return innerContainer;
}
/// <summary>
/// 获取子持有者
/// </summary>
public void GetChildHolders(List<IThingHolder> outChildren)
{
// 目前没有子持有者,留空
}
/// <summary>
/// 通知物品被添加
/// </summary>
public void Notify_ThingAdded(Thing t)
{
// 这里可以添加逻辑来处理物品被添加到口袋空间的情况
Log.Message($"[WULA] Item {t.LabelCap} added to pocket space container.");
}
/// <summary>
/// 通知物品被移除
/// </summary>
public void Notify_ThingRemoved(Thing t)
{
// 这里可以添加逻辑来处理物品被从口袋空间移除的情况
Log.Message($"[WULA] Item {t.LabelCap} removed from pocket space container.");
}
public void ExposeData()
{
Scribe_Deep.Look(ref innerContainer, "innerContainer", this);
// owner 通常在构造函数中设置,不需要序列化
}
}
}