暂存4
This commit is contained in:
Binary file not shown.
@@ -21,6 +21,8 @@
|
|||||||
<WULA.PocketSpace.CannotEnter>无法进入内部空间。</WULA.PocketSpace.CannotEnter>
|
<WULA.PocketSpace.CannotEnter>无法进入内部空间。</WULA.PocketSpace.CannotEnter>
|
||||||
<WULA.PocketSpace.AccessDenied>访问被拒绝。</WULA.PocketSpace.AccessDenied>
|
<WULA.PocketSpace.AccessDenied>访问被拒绝。</WULA.PocketSpace.AccessDenied>
|
||||||
<WULA.PocketSpace.NotSpawned>穿梭机未部署。</WULA.PocketSpace.NotSpawned>
|
<WULA.PocketSpace.NotSpawned>穿梭机未部署。</WULA.PocketSpace.NotSpawned>
|
||||||
|
<WULA.PocketSpace.TransportDisabled>传送功能已禁用(穿梭机飞行中)。</WULA.PocketSpace.TransportDisabled>
|
||||||
|
<WULA.PocketSpace.NoTargetMap>无目标地图。</WULA.PocketSpace.NoTargetMap>
|
||||||
<WULA.PocketSpace.CreationFailed>内部空间创建失败。</WULA.PocketSpace.CreationFailed>
|
<WULA.PocketSpace.CreationFailed>内部空间创建失败。</WULA.PocketSpace.CreationFailed>
|
||||||
<WULA.PocketSpace.TransferSuccess>{0} 名人员已成功传送到内部空间。</WULA.PocketSpace.TransferSuccess>
|
<WULA.PocketSpace.TransferSuccess>{0} 名人员已成功传送到内部空间。</WULA.PocketSpace.TransferSuccess>
|
||||||
<WULA.PocketSpace.SwitchToPocket>即将切换到内部口袋空间。确认吗?</WULA.PocketSpace.SwitchToPocket>
|
<WULA.PocketSpace.SwitchToPocket>即将切换到内部口袋空间。确认吗?</WULA.PocketSpace.SwitchToPocket>
|
||||||
@@ -32,7 +34,6 @@
|
|||||||
<WULA.PocketSpace.NoPawnsSelected>请选择至少一名殖民者进入内部空间。</WULA.PocketSpace.NoPawnsSelected>
|
<WULA.PocketSpace.NoPawnsSelected>请选择至少一名殖民者进入内部空间。</WULA.PocketSpace.NoPawnsSelected>
|
||||||
<WULA.PocketSpace.NoPawnsAvailable>没有可用的殖民者。</WULA.PocketSpace.NoPawnsAvailable>
|
<WULA.PocketSpace.NoPawnsAvailable>没有可用的殖民者。</WULA.PocketSpace.NoPawnsAvailable>
|
||||||
<WULA.PocketSpace.AllColonists>所有殖民者 ({0}人)</WULA.PocketSpace.AllColonists>
|
<WULA.PocketSpace.AllColonists>所有殖民者 ({0}人)</WULA.PocketSpace.AllColonists>
|
||||||
<WULA.PocketSpace.ViewOnly>仅切换视角</WULA.PocketSpace.ViewOnly>
|
|
||||||
|
|
||||||
<!-- 退出点相关 -->
|
<!-- 退出点相关 -->
|
||||||
<WULA.PocketSpace.ExitThroughPortal>通过传送门返回</WULA.PocketSpace.ExitThroughPortal>
|
<WULA.PocketSpace.ExitThroughPortal>通过传送门返回</WULA.PocketSpace.ExitThroughPortal>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
<!-- Message text -->
|
<!-- Message text -->
|
||||||
<WULA.PocketSpace.CannotEnter>Cannot enter pocket space.</WULA.PocketSpace.CannotEnter>
|
<WULA.PocketSpace.CannotEnter>Cannot enter pocket space.</WULA.PocketSpace.CannotEnter>
|
||||||
<WULA.PocketSpace.AccessDenied>Access denied.</WULA.PocketSpace.AccessDenied>
|
<WULA.PocketSpace.AccessDenied>Access denied.</WULA.PocketSpace.AccessDenied>
|
||||||
|
<WULA.PocketSpace.TransportDisabled>Transport functionality disabled (shuttle in flight).</WULA.PocketSpace.TransportDisabled>
|
||||||
|
<WULA.PocketSpace.NoTargetMap>No target map available.</WULA.PocketSpace.NoTargetMap>
|
||||||
<WULA.PocketSpace.NotSpawned>Shuttle not deployed.</WULA.PocketSpace.NotSpawned>
|
<WULA.PocketSpace.NotSpawned>Shuttle not deployed.</WULA.PocketSpace.NotSpawned>
|
||||||
<WULA.PocketSpace.CreationFailed>Pocket space creation failed.</WULA.PocketSpace.CreationFailed>
|
<WULA.PocketSpace.CreationFailed>Pocket space creation failed.</WULA.PocketSpace.CreationFailed>
|
||||||
<WULA.PocketSpace.TransferSuccess>{0} personnel successfully transferred to pocket space.</WULA.PocketSpace.TransferSuccess>
|
<WULA.PocketSpace.TransferSuccess>{0} personnel successfully transferred to pocket space.</WULA.PocketSpace.TransferSuccess>
|
||||||
@@ -32,7 +34,7 @@
|
|||||||
<WULA.PocketSpace.NoPawnsSelected>Please select at least one colonist to enter the pocket space.</WULA.PocketSpace.NoPawnsSelected>
|
<WULA.PocketSpace.NoPawnsSelected>Please select at least one colonist to enter the pocket space.</WULA.PocketSpace.NoPawnsSelected>
|
||||||
<WULA.PocketSpace.NoPawnsAvailable>No available colonists.</WULA.PocketSpace.NoPawnsAvailable>
|
<WULA.PocketSpace.NoPawnsAvailable>No available colonists.</WULA.PocketSpace.NoPawnsAvailable>
|
||||||
<WULA.PocketSpace.AllColonists>All colonists ({0} people)</WULA.PocketSpace.AllColonists>
|
<WULA.PocketSpace.AllColonists>All colonists ({0} people)</WULA.PocketSpace.AllColonists>
|
||||||
<WULA.PocketSpace.ViewOnly>View only</WULA.PocketSpace.ViewOnly>
|
|
||||||
|
|
||||||
<!-- Exit point related -->
|
<!-- Exit point related -->
|
||||||
<WULA.PocketSpace.ExitThroughPortal>Return through portal</WULA.PocketSpace.ExitThroughPortal>
|
<WULA.PocketSpace.ExitThroughPortal>Return through portal</WULA.PocketSpace.ExitThroughPortal>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace WulaFallenEmpire
|
|||||||
/// 结合了武装防御能力和口袋空间技术的复合型载具
|
/// 结合了武装防御能力和口袋空间技术的复合型载具
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StaticConstructorOnStartup]
|
[StaticConstructorOnStartup]
|
||||||
public class Building_ArmedShuttleWithPocket : Building_ArmedShuttle, IThingHolder
|
public class Building_ArmedShuttleWithPocket : Building_ArmedShuttle
|
||||||
{
|
{
|
||||||
#region 静态图标定义(使用原版MapPortal的图标)
|
#region 静态图标定义(使用原版MapPortal的图标)
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ namespace WulaFallenEmpire
|
|||||||
private static readonly Texture2D CancelEnterTex = ContentFinder<Texture2D>.Get("UI/Designators/Cancel");
|
private static readonly Texture2D CancelEnterTex = ContentFinder<Texture2D>.Get("UI/Designators/Cancel");
|
||||||
|
|
||||||
/// <summary>默认进入图标</summary>
|
/// <summary>默认进入图标</summary>
|
||||||
private static readonly Texture2D DefaultEnterTex = ContentFinder<Texture2D>.Get("UI/Commands/EnterCave");
|
private static readonly Texture2D DefaultEnterTex = ContentFinder<Texture2D>.Get("UI/Commands/LoadTransporter");
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region 口袋空间字段
|
#region 口袋空间字段
|
||||||
@@ -50,6 +50,9 @@ namespace WulaFallenEmpire
|
|||||||
/// <summary>允许直接访问(无需骇入)</summary>
|
/// <summary>允许直接访问(无需骇入)</summary>
|
||||||
private bool allowDirectAccess = true;
|
private bool allowDirectAccess = true;
|
||||||
|
|
||||||
|
/// <summary>传送功能是否暂停(飞行时为 true)</summary>
|
||||||
|
private bool transportDisabled = false;
|
||||||
|
|
||||||
// 注意:我们不再使用自定义的innerContainer,
|
// 注意:我们不再使用自定义的innerContainer,
|
||||||
// 所有物品都存储在CompTransporter.innerContainer中,保持简单和一致
|
// 所有物品都存储在CompTransporter.innerContainer中,保持简单和一致
|
||||||
|
|
||||||
@@ -165,6 +168,7 @@ namespace WulaFallenEmpire
|
|||||||
Scribe_Defs.Look(ref mapGenerator, "mapGenerator");
|
Scribe_Defs.Look(ref mapGenerator, "mapGenerator");
|
||||||
Scribe_Defs.Look(ref exitDef, "exitDef");
|
Scribe_Defs.Look(ref exitDef, "exitDef");
|
||||||
Scribe_Values.Look(ref allowDirectAccess, "allowDirectAccess", true);
|
Scribe_Values.Look(ref allowDirectAccess, "allowDirectAccess", true);
|
||||||
|
Scribe_Values.Look(ref transportDisabled, "transportDisabled", false);
|
||||||
|
|
||||||
// 不再序列化innerContainer,只使用CompTransporter的容器
|
// 不再序列化innerContainer,只使用CompTransporter的容器
|
||||||
|
|
||||||
@@ -187,25 +191,72 @@ namespace WulaFallenEmpire
|
|||||||
|
|
||||||
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
|
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
|
||||||
{
|
{
|
||||||
// 清理口袋地图
|
Log.Message($"[WULA-DEBUG] DeSpawn called with mode: {mode}");
|
||||||
|
|
||||||
|
// 只在真正销毁时清理口袋地图,发射时保留
|
||||||
|
if (ShouldDestroyPocketMapOnDeSpawn(mode))
|
||||||
|
{
|
||||||
if (pocketMap != null && pocketMapGenerated)
|
if (pocketMap != null && pocketMapGenerated)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Log.Message("[WULA-DEBUG] Destroying pocket map due to shuttle destruction");
|
||||||
|
|
||||||
// 将口袋空间中的物品和人员转移到主地图
|
// 将口袋空间中的物品和人员转移到主地图
|
||||||
TransferAllFromPocketToMainMap();
|
TransferAllFromPocketToMainMap();
|
||||||
|
|
||||||
// 销毁口袋地图
|
// 销毁口袋地图
|
||||||
PocketMapUtility.DestroyPocketMap(pocketMap);
|
PocketMapUtility.DestroyPocketMap(pocketMap);
|
||||||
|
pocketMap = null;
|
||||||
|
pocketMapGenerated = false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error($"[WULA] Error cleaning up pocket map: {ex}");
|
Log.Error($"[WULA-ERROR] Error cleaning up pocket map: {ex}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Message("[WULA-DEBUG] Preserving pocket map during shuttle launch/transport");
|
||||||
|
// 发射时暂停传送功能,但保留口袋空间
|
||||||
|
transportDisabled = true;
|
||||||
|
if (pocketMap != null && exit != null)
|
||||||
|
{
|
||||||
|
// 标记传送功能暂停
|
||||||
|
Log.Message("[WULA-DEBUG] Transport functionality disabled during flight");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
base.DeSpawn(mode);
|
base.DeSpawn(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断是否应该在DeSpawn时销毁口袋地图
|
||||||
|
/// </summary>
|
||||||
|
private bool ShouldDestroyPocketMapOnDeSpawn(DestroyMode mode)
|
||||||
|
{
|
||||||
|
// 只在真正销毁时删除口袋空间
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case DestroyMode.Vanish: // 发射时使用,保留口袋空间
|
||||||
|
return false;
|
||||||
|
case DestroyMode.Deconstruct: // 拆除,删除口袋空间
|
||||||
|
return true;
|
||||||
|
case DestroyMode.KillFinalize: // 被摧毁,删除口袋空间
|
||||||
|
return true;
|
||||||
|
case DestroyMode.Cancel: // 取消建造,删除口袋空间
|
||||||
|
return true;
|
||||||
|
case DestroyMode.Refund: // 退款,删除口袋空间
|
||||||
|
return true;
|
||||||
|
case DestroyMode.FailConstruction: // 建造失败,删除口袋空间
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
Log.Warning($"[WULA-WARNING] Unknown DestroyMode: {mode}, defaulting to preserve pocket map");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string GetInspectString()
|
public override string GetInspectString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder(base.GetInspectString());
|
StringBuilder sb = new StringBuilder(base.GetInspectString());
|
||||||
@@ -272,6 +323,11 @@ namespace WulaFallenEmpire
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (transportDisabled)
|
||||||
|
{
|
||||||
|
return false; // 飞行中禁用传送功能
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,60 +819,11 @@ namespace WulaFallenEmpire
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加同步物品按钮(用于修复物品消失问题)
|
|
||||||
if (pocketMapGenerated && pocketMap != null)
|
|
||||||
{
|
|
||||||
yield return new Command_Action
|
|
||||||
{
|
|
||||||
defaultLabel = "同步物品",
|
|
||||||
defaultDesc = "将口袋空间中的物品同步到穿梭机容器中。如果物品消失,可以尝试点击此按钮。",
|
|
||||||
icon = ContentFinder<Texture2D>.Get("UI/Commands/LoadTransporter"),
|
|
||||||
action = delegate
|
|
||||||
{
|
|
||||||
SyncPocketItemsToMainContainer();
|
|
||||||
Messages.Message("物品同步完成。" + GetPocketSpaceDebugInfo(), this, MessageTypeDefOf.TaskCompletion);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IThingHolder接口实现
|
|
||||||
|
|
||||||
public ThingOwner GetDirectlyHeldThings()
|
|
||||||
{
|
|
||||||
// 只使用穿梭机的标准容器,保持简单和一致性
|
|
||||||
CompTransporter transporter = this.GetComp<CompTransporter>();
|
|
||||||
if (transporter?.innerContainer != null)
|
|
||||||
{
|
|
||||||
Log.Message($"[WULA-DEBUG] GetDirectlyHeldThings: Returning main container with {transporter.innerContainer.Count} items");
|
|
||||||
return transporter.innerContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果CompTransporter不存在,说明有严重问题,直接报错
|
|
||||||
Log.Error("[WULA-ERROR] CompTransporter is null! This should never happen for a shuttle.");
|
|
||||||
|
|
||||||
// 返回一个临时空容器避免游戏崩溃,但这种情况应该被修复
|
|
||||||
var tempContainer = new ThingOwner<Thing>(this, oneStackOnly: false);
|
|
||||||
Log.Error($"[WULA-ERROR] Created temporary container as fallback. This is a bug!");
|
|
||||||
return tempContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GetChildHolders(List<IThingHolder> outChildren)
|
|
||||||
{
|
|
||||||
// 只添加穿梭机的主容器
|
|
||||||
CompTransporter transporter = this.GetComp<CompTransporter>();
|
|
||||||
if (transporter != null)
|
|
||||||
{
|
|
||||||
outChildren.Add(transporter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region MapPortal兼容接口(使Dialog_EnterPortal能正常工作)
|
#region MapPortal兼容接口(使Dialog_EnterPortal能正常工作)
|
||||||
@@ -838,6 +845,12 @@ namespace WulaFallenEmpire
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (transportDisabled)
|
||||||
|
{
|
||||||
|
reason = "WULA.PocketSpace.TransportDisabled".Translate();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
reason = "";
|
reason = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -927,27 +940,6 @@ namespace WulaFallenEmpire
|
|||||||
options.Add(allOption);
|
options.Add(allOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加“只切换视角”选项
|
|
||||||
FloatMenuOption viewOnlyOption = new FloatMenuOption(
|
|
||||||
"WULA.PocketSpace.ViewOnly".Translate(),
|
|
||||||
delegate
|
|
||||||
{
|
|
||||||
if (pocketMapGenerated)
|
|
||||||
{
|
|
||||||
SwitchToPocketSpace();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CreatePocketMap();
|
|
||||||
if (pocketMapGenerated)
|
|
||||||
{
|
|
||||||
SwitchToPocketSpace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
options.Add(viewOnlyOption);
|
|
||||||
|
|
||||||
// 显示浮动菜单
|
// 显示浮动菜单
|
||||||
FloatMenu floatMenu = new FloatMenu(options);
|
FloatMenu floatMenu = new FloatMenu(options);
|
||||||
Find.WindowStack.Add(floatMenu);
|
Find.WindowStack.Add(floatMenu);
|
||||||
@@ -1146,6 +1138,20 @@ namespace WulaFallenEmpire
|
|||||||
// 更新退出点目标(处理穿梭机重新部署的情况)
|
// 更新退出点目标(处理穿梭机重新部署的情况)
|
||||||
UpdateExitPointTarget();
|
UpdateExitPointTarget();
|
||||||
|
|
||||||
|
// 如果是从飞行状态恢复,重新启用传送功能
|
||||||
|
if (transportDisabled)
|
||||||
|
{
|
||||||
|
Log.Message("[WULA-DEBUG] Re-enabling transport functionality after landing");
|
||||||
|
transportDisabled = false;
|
||||||
|
|
||||||
|
// 如果有口袋空间,确保退出点正确连接到新地图
|
||||||
|
if (pocketMapGenerated && pocketMap != null && exit != null)
|
||||||
|
{
|
||||||
|
Log.Message($"[WULA-DEBUG] Reconnecting pocket space exit to new map: {map?.uniqueID} at {this.Position}");
|
||||||
|
// 退出点会在 UpdateExitPointTarget 中自动更新
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 从 ThingDef 中读取 portal 配置
|
// 从 ThingDef 中读取 portal 配置
|
||||||
if (def.HasModExtension<PocketMapProperties>())
|
if (def.HasModExtension<PocketMapProperties>())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Verse;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace WulaFallenEmpire
|
namespace WulaFallenEmpire
|
||||||
{
|
{
|
||||||
@@ -75,7 +76,7 @@ namespace WulaFallenEmpire
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重写是否可进入,检查目标地图是否存在(模仿原版MapPortal.IsEnterable)
|
/// 重写是否可进入,检查目标地图是否存在及传送状态(模仿原版MapPortal.IsEnterable)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool IsEnterable(out string reason)
|
public override bool IsEnterable(out string reason)
|
||||||
{
|
{
|
||||||
@@ -84,6 +85,25 @@ namespace WulaFallenEmpire
|
|||||||
reason = "WULA.PocketSpace.NoTargetMap".Translate();
|
reason = "WULA.PocketSpace.NoTargetMap".Translate();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查父穿梭机的传送状态
|
||||||
|
if (parentShuttle != null)
|
||||||
|
{
|
||||||
|
// 使用反射获取 transportDisabled 字段值
|
||||||
|
var transportDisabledField = typeof(Building_ArmedShuttleWithPocket).GetField("transportDisabled",
|
||||||
|
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||||
|
|
||||||
|
if (transportDisabledField != null)
|
||||||
|
{
|
||||||
|
bool transportDisabled = (bool)transportDisabledField.GetValue(parentShuttle);
|
||||||
|
if (transportDisabled)
|
||||||
|
{
|
||||||
|
reason = "WULA.PocketSpace.TransportDisabled".Translate();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reason = "";
|
reason = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -107,9 +127,9 @@ namespace WulaFallenEmpire
|
|||||||
public override string EnterString => "WULA.PocketSpace.ExitToMainMap".Translate();
|
public override string EnterString => "WULA.PocketSpace.ExitToMainMap".Translate();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重写进入按钮图标,使用原版的ViewCave图标
|
/// 重写进入按钮图标,使用装载按钮的贴图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override Texture2D EnterTex => ContentFinder<Texture2D>.Get("UI/Commands/ViewCave");
|
protected override Texture2D EnterTex => ContentFinder<Texture2D>.Get("UI/Commands/LoadTransporter");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user