我去忘记提交了

This commit is contained in:
Tourswen
2025-11-09 22:05:40 +08:00
parent 84f3fe33ab
commit 6e16cf3828
198 changed files with 4957 additions and 2388 deletions

View File

@@ -10,13 +10,13 @@ namespace WulaFallenEmpire
public ThingDef aircraftDef; // 对应的战机定义
public int aircraftCount = 1; // 起飞后提供的战机数量
public ThingDef skyfallerLeaving; // 起飞时的天空坠落者效果
// 新增:自动发射配置
public bool autoLaunchEnabled = false; // 是否启用自动发射
public int autoLaunchDelayTicks = 600; // 自动发射延迟ticks默认10秒
public bool autoLaunchOnConstruction = true; // 建造完成后自动发射
public bool autoLaunchOnPowerOn = false; // 通电时自动发射
public CompProperties_AircraftHangar()
{
compClass = typeof(CompAircraftHangar);
@@ -26,16 +26,16 @@ namespace WulaFallenEmpire
public class CompAircraftHangar : ThingComp
{
public CompProperties_AircraftHangar Props => (CompProperties_AircraftHangar)props;
// 新增:自动发射状态
private bool autoLaunchScheduled = false;
private int autoLaunchTick = -1;
private bool hasLaunched = false;
public override void PostSpawnSetup(bool respawningAfterLoad)
{
base.PostSpawnSetup(respawningAfterLoad);
if (!respawningAfterLoad && Props.autoLaunchEnabled && Props.autoLaunchOnConstruction)
{
ScheduleAutoLaunch();
@@ -53,7 +53,7 @@ namespace WulaFallenEmpire
public override void CompTick()
{
base.CompTick();
// 处理自动发射
if (Props.autoLaunchEnabled && !hasLaunched)
{
@@ -94,7 +94,7 @@ namespace WulaFallenEmpire
autoLaunchScheduled = true;
autoLaunchTick = Find.TickManager.TicksGame + Props.autoLaunchDelayTicks;
Messages.Message("AircraftAutoLaunchScheduled".Translate(Props.aircraftDef.LabelCap, (Props.autoLaunchDelayTicks / 60f).ToString("F1")), parent, MessageTypeDefOf.NeutralEvent);
}
@@ -160,7 +160,7 @@ namespace WulaFallenEmpire
// 获取全局战机管理器
WorldComponent_AircraftManager aircraftManager = Find.World.GetComponent<WorldComponent_AircraftManager>();
if (aircraftManager == null)
{
Log.Error("AircraftManagerNotFound".Translate());
@@ -169,10 +169,10 @@ namespace WulaFallenEmpire
// 立即向全局管理器注册战机
aircraftManager.AddAircraft(Props.aircraftDef, Props.aircraftCount, parent.Faction);
// 显示消息
Messages.Message("AircraftLaunched".Translate(Props.aircraftCount, Props.aircraftDef.LabelCap), parent, MessageTypeDefOf.PositiveEvent);
// 创建起飞效果(仅视觉效果)
if (Props.skyfallerLeaving != null)
{
@@ -195,25 +195,25 @@ namespace WulaFallenEmpire
// 创建 1 单位 Chemfuel 作为 Skyfaller 的内容物
Thing chemfuel = ThingMaker.MakeThing(ThingDefOf.Chemfuel);
chemfuel.stackCount = 1;
// 创建包含 Chemfuel 的 Skyfaller
Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(Props.skyfallerLeaving, chemfuel);
// 设置起飞位置(建筑当前位置)
IntVec3 takeoffPos = parent.Position;
// 检查地图是否有效
if (parent.Map == null)
{
Log.Error("TakeoffEffectMapNull".Translate());
return;
}
// 生成 Skyfaller
GenSpawn.Spawn(skyfaller, takeoffPos, parent.Map);
Log.Message("TakeoffSkyfallerCreated".Translate(takeoffPos));
// 销毁原建筑
parent.Destroy(DestroyMode.Vanish);
}

View File

@@ -1,35 +0,0 @@
using Verse;
namespace WulaFallenEmpire
{
public class CompProperties_FlyOverType : CompProperties
{
public int laneLevel = 0; // 航道等级
public string flyOverType = "default"; // FlyOver 类型标识符
public bool isRequiredForDrop = true; // 是否是需要用于空投的类型
public CompProperties_FlyOverType()
{
compClass = typeof(CompFlyOverType);
}
}
public class CompFlyOverType : ThingComp
{
private CompProperties_FlyOverType Props => (CompProperties_FlyOverType)props;
public int LaneLevel => Props.laneLevel;
public string FlyOverType => Props.flyOverType;
public bool IsRequiredForDrop => Props.isRequiredForDrop;
public override void PostExposeData()
{
base.PostExposeData();
}
public override string CompInspectStringExtra()
{
return $"FlyOver Type: {FlyOverType}, Lane Level: {LaneLevel}";
}
}
}

View File

@@ -14,100 +14,10 @@ namespace WulaFallenEmpire
{
if (!base.CanApplyOn(target, dest))
return false;
// 检查航道等级系统
if (Props.useLaneLevelSystem)
{
string disableReason;
if (!CanSpawnWithLaneLevelCheck(out disableReason))
{
return false;
}
}
return true;
}
// 新增:航道等级检查逻辑
private bool CanSpawnWithLaneLevelCheck(out string disableReason)
{
disableReason = null;
Map map = parent.pawn.Map;
if (map == null)
return true;
// 获取地图上所有的 FlyOver 物体
var existingFlyOvers = map.listerThings.ThingsOfDef(Props.flyOverDef)
.OfType<FlyOver>()
.Where(f => f.Spawned && !f.Destroyed)
.ToList();
// 获取当前技能的航道等级和类型
int currentLaneLevel = Props.laneLevel;
string currentFlyOverType = Props.flyOverTypeName;
Log.Message($"Lane Level Check: Current level={currentLaneLevel}, type={currentFlyOverType}, existing flyovers={existingFlyOvers.Count}");
// 规则1航道等级0可以不受限制召唤
if (currentLaneLevel == 0)
{
return true;
}
// 规则2检查是否有更高航道等级的flyover存在
var higherLevelFlyOvers = existingFlyOvers
.Where(f => GetFlyOverLaneLevel(f) > currentLaneLevel)
.ToList();
if (higherLevelFlyOvers.Any())
{
disableReason = "Cannot summon: Higher lane level flyover exists";
Log.Message($"Cannot summon: Found {higherLevelFlyOvers.Count} higher level flyovers");
return false;
}
// 规则3检查是否有相同航道等级和类型的flyover存在
var sameTypeAndLevelFlyOvers = existingFlyOvers
.Where(f => GetFlyOverLaneLevel(f) == currentLaneLevel &&
GetFlyOverType(f) == currentFlyOverType)
.ToList();
if (sameTypeAndLevelFlyOvers.Any())
{
disableReason = $"Cannot summon: Same lane level and type flyover already exists";
Log.Message($"Cannot summon: Found {sameTypeAndLevelFlyOvers.Count} same type and level flyovers");
return false;
}
return true;
}
// 新增获取FlyOver的航道等级
private int GetFlyOverLaneLevel(FlyOver flyOver)
{
var comp = flyOver.GetComp<CompFlyOverType>();
return comp?.LaneLevel ?? 0;
}
// 新增获取FlyOver的类型
private string GetFlyOverType(FlyOver flyOver)
{
var comp = flyOver.GetComp<CompFlyOverType>();
return comp?.FlyOverType ?? "default";
}
// 新增强制销毁低等级FlyOver
private void DestroyLowerLevelFlyOvers()
{
Map map = parent.pawn.Map;
if (map == null) return;
var existingFlyOvers = map.listerThings.ThingsOfDef(Props.flyOverDef)
.OfType<FlyOver>()
.Where(f => f.Spawned && !f.Destroyed)
.ToList();
int currentLaneLevel = Props.laneLevel;
string currentFlyOverType = Props.flyOverTypeName;
// 查找需要销毁的低等级FlyOver
var flyOversToDestroy = existingFlyOvers
.Where(f => GetFlyOverLaneLevel(f) < currentLaneLevel ||
(GetFlyOverLaneLevel(f) == currentLaneLevel &&
GetFlyOverType(f) != currentFlyOverType))
.ToList();
foreach (var flyOver in flyOversToDestroy)
{
Log.Message($"Destroying lower level flyover: Level={GetFlyOverLaneLevel(flyOver)}, Type={GetFlyOverType(flyOver)}");
flyOver.EmergencyDestroy();
}
if (flyOversToDestroy.Count > 0)
{
Log.Message($"Destroyed {flyOversToDestroy.Count} lower level flyovers");
}
}
// 在 CompAbilityEffect_SpawnFlyOver.cs 中修改航道检查方法:
// 修改 DestroyLowerLevelFlyOvers 方法(现在由全局管理器处理):
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{
base.Apply(target, dest);
@@ -115,18 +25,6 @@ namespace WulaFallenEmpire
return;
try
{
// 检查航道等级系统
if (Props.useLaneLevelSystem)
{
string disableReason;
if (!CanSpawnWithLaneLevelCheck(out disableReason))
{
Messages.Message(disableReason, MessageTypeDefOf.RejectInput);
return;
}
// 强制销毁低等级FlyOver
DestroyLowerLevelFlyOvers();
}
Log.Message($"FlyOver skill activated by {parent.pawn.Label} at position {parent.pawn.Position}");
Log.Message($"Target cell: {target.Cell}, Dest: {dest.Cell}");
// 计算起始和结束位置
@@ -183,19 +81,6 @@ namespace WulaFallenEmpire
{
baseInfo = $"扇形监视: 约{Props.strafeWidth * 2 + 1}格宽度\n(具体参数在飞行物定义中)";
}
// 添加航道等级信息
if (Props.useLaneLevelSystem)
{
if (!string.IsNullOrEmpty(baseInfo))
baseInfo += "\n";
baseInfo += $"航道等级: {Props.laneLevel}";
// 检查是否可以被召唤
string disableReason;
if (!CanSpawnWithLaneLevelCheck(out disableReason))
{
baseInfo += $"\n<color=red>{disableReason}</color>";
}
}
return baseInfo;
}
// 更新:验证方法,包含航道等级检查
@@ -207,19 +92,6 @@ namespace WulaFallenEmpire
return false;
if (!target.Cell.IsValid || !target.Cell.InBounds(parent.pawn.Map))
return false;
// 航道等级检查
if (Props.useLaneLevelSystem)
{
string disableReason;
if (!CanSpawnWithLaneLevelCheck(out disableReason))
{
if (throwMessages)
{
Messages.Message(disableReason, MessageTypeDefOf.RejectInput);
}
return false;
}
}
return true;
}
// 更新:创建标准飞越方法,添加航道等级组件
@@ -241,19 +113,6 @@ namespace WulaFallenEmpire
);
flyOver.spawnContentsOnImpact = Props.dropContentsOnImpact;
flyOver.playFlyOverSound = Props.playFlyOverSound;
// 设置航道等级信息
if (Props.useLaneLevelSystem)
{
var laneComp = flyOver.GetComp<CompFlyOverType>();
if (laneComp != null)
{
Log.Message($"FlyOver created with lane level: {Props.laneLevel}, type: {Props.flyOverTypeName}");
}
else
{
Log.Warning("FlyOver def does not have CompFlyOverType component!");
}
}
if (Props.customSound != null)
{
// 自定义音效逻辑
@@ -281,15 +140,6 @@ namespace WulaFallenEmpire
// 设置基本属性
flyOver.spawnContentsOnImpact = Props.dropContentsOnImpact;
flyOver.playFlyOverSound = Props.playFlyOverSound;
// 设置航道等级信息
if (Props.useLaneLevelSystem)
{
var laneComp = flyOver.GetComp<CompFlyOverType>();
if (laneComp != null)
{
Log.Message($"Ground Strafing FlyOver created with lane level: {Props.laneLevel}, type: {Props.flyOverTypeName}");
}
}
// 获取扫射组件并设置预处理后的目标单元格
CompGroundStrafing strafingComp = flyOver.GetComp<CompGroundStrafing>();
if (strafingComp != null)
@@ -344,15 +194,6 @@ namespace WulaFallenEmpire
// 设置基本属性
flyOver.spawnContentsOnImpact = Props.dropContentsOnImpact;
flyOver.playFlyOverSound = Props.playFlyOverSound;
// 设置航道等级信息
if (Props.useLaneLevelSystem)
{
var laneComp = flyOver.GetComp<CompFlyOverType>();
if (laneComp != null)
{
Log.Message($"Sector Surveillance FlyOver created with lane level: {Props.laneLevel}, type: {Props.flyOverTypeName}");
}
}
Log.Message($"SectorSurveillance FlyOver created: {flyOver} from {startPos} to {endPos}");
}
// 新增:验证和优化飞行路径

View File

@@ -47,11 +47,6 @@ namespace WulaFallenEmpire
public bool showSectorPreview = true; // 是否显示扇形预览
public Color sectorPreviewColor = new Color(0.3f, 0.7f, 1f, 0.3f);
// 航道等级系统配置
public bool useLaneLevelSystem = false; // 是否使用航道等级系统
public int laneLevel = 0; // 该技能的航道等级
public string flyOverTypeName = "default"; // FlyOver类型名称
public CompProperties_AbilitySpawnFlyOver()
{
this.compClass = typeof(CompAbilityEffect_SpawnFlyOver);