到底有多强
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class CompProperties_AbilityLaunchMultiProjectile : CompProperties_AbilityLaunchProjectile
|
||||
{
|
||||
public int numProjectiles = 1;
|
||||
|
||||
public CompProperties_AbilityLaunchMultiProjectile()
|
||||
{
|
||||
compClass = typeof(CompAbilityEffect_LaunchMultiProjectile);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompAbilityEffect_LaunchMultiProjectile : CompAbilityEffect
|
||||
{
|
||||
public new CompProperties_AbilityLaunchMultiProjectile Props => (CompProperties_AbilityLaunchMultiProjectile)props;
|
||||
|
||||
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
||||
{
|
||||
base.Apply(target, dest);
|
||||
for (int i = 0; i < Props.numProjectiles; i++)
|
||||
{
|
||||
LaunchProjectile(target);
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchProjectile(LocalTargetInfo target)
|
||||
{
|
||||
if (Props.projectileDef != null)
|
||||
{
|
||||
Pawn pawn = parent.pawn;
|
||||
Projectile projectile = (Projectile)GenSpawn.Spawn(Props.projectileDef, pawn.Position, pawn.Map);
|
||||
projectile.Launch(pawn, pawn.DrawPos, target, target, ProjectileHitFlags.IntendedTarget, parent.verb.preventFriendlyFire);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool AICanTargetNow(LocalTargetInfo target)
|
||||
{
|
||||
return target.Pawn != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
// 核心补丁:修复威胁禁用检查
|
||||
[HarmonyPatch(typeof(Pawn), "ThreatDisabled")]
|
||||
public static class Patch_Pawn_ThreatDisabled
|
||||
{
|
||||
public static void Postfix(Pawn __instance, IAttackTargetSearcher disabledFor, ref bool __result)
|
||||
{
|
||||
if (!__result) return;
|
||||
if (!__instance.IsColonyMech) return;
|
||||
|
||||
var comp = __instance.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.CanFightAutonomously)
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 核心补丁:修复机械师需求检查 - 正确的方法在 MechanitorUtility 中
|
||||
[HarmonyPatch(typeof(MechanitorUtility), "IsColonyMechRequiringMechanitor")]
|
||||
public static class Patch_MechanitorUtility_IsColonyMechRequiringMechanitor
|
||||
{
|
||||
public static void Postfix(Pawn mech, ref bool __result)
|
||||
{
|
||||
if (__result && mech.IsColonyMech)
|
||||
{
|
||||
var comp = mech.GetComp<CompAutonomousMech>();
|
||||
if (comp != null && comp.CanFightAutonomously)
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,16 @@ namespace WulaFallenEmpire
|
||||
return CanBeAutonomous;
|
||||
}
|
||||
}
|
||||
public bool IsInCombatMode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MechPawn == null || MechPawn.Dead || MechPawn.Downed)
|
||||
return false;
|
||||
// 被征召或处于自主战斗模式
|
||||
return MechPawn.Drafted || (CanFightAutonomously && MechPawn.mindState?.duty?.def == DutyDefOf.AssaultColony);
|
||||
}
|
||||
}
|
||||
|
||||
// 在 CompAutonomousMech 类中添加这个新属性
|
||||
public bool CanFightAutonomously
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class CompProperties_SkyfallerPawnSpawner : CompProperties
|
||||
{
|
||||
public PawnKindDef pawnKind;
|
||||
public FactionDef faction;
|
||||
public bool spawnDrafted = false;
|
||||
public bool spawnHostile = false;
|
||||
|
||||
public CompProperties_SkyfallerPawnSpawner()
|
||||
{
|
||||
compClass = typeof(CompSkyfallerPawnSpawner);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompSkyfallerPawnSpawner : ThingComp
|
||||
{
|
||||
public CompProperties_SkyfallerPawnSpawner Props => (CompProperties_SkyfallerPawnSpawner)props;
|
||||
|
||||
public void SpawnPawn(Map map, IntVec3 position)
|
||||
{
|
||||
if (Props.pawnKind == null)
|
||||
{
|
||||
Log.Error("CompSkyfallerPawnSpawner: pawnKind is null");
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建 Pawn
|
||||
PawnGenerationRequest request = new PawnGenerationRequest(
|
||||
Props.pawnKind,
|
||||
faction: GetFaction(),
|
||||
context: PawnGenerationContext.NonPlayer,
|
||||
fixedBiologicalAge: 0,
|
||||
fixedChronologicalAge: 0
|
||||
);
|
||||
|
||||
Pawn pawn = PawnGenerator.GeneratePawn(request);
|
||||
|
||||
// 设置阵营关系
|
||||
if (Props.spawnHostile)
|
||||
{
|
||||
pawn.SetFaction(Faction.OfAncientsHostile);
|
||||
}
|
||||
|
||||
// 生成 Pawn
|
||||
GenSpawn.Spawn(pawn, position, map);
|
||||
|
||||
// 如果需要,设置为征召状态
|
||||
if (Props.spawnDrafted && pawn.drafter != null)
|
||||
{
|
||||
pawn.drafter.Drafted = true;
|
||||
}
|
||||
|
||||
// 发送生成消息
|
||||
Messages.Message("SkyfallerPawnLanded".Translate(pawn.LabelShortCap), pawn, MessageTypeDefOf.NeutralEvent);
|
||||
}
|
||||
|
||||
private Faction GetFaction()
|
||||
{
|
||||
if (Props.faction != null)
|
||||
{
|
||||
return FactionUtility.DefaultFactionFrom(Props.faction);
|
||||
}
|
||||
|
||||
if (Props.spawnHostile)
|
||||
{
|
||||
return Faction.OfAncientsHostile;
|
||||
}
|
||||
|
||||
return Faction.OfAncients;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class Skyfaller_PawnSpawner : Skyfaller
|
||||
{
|
||||
private CompSkyfallerPawnSpawner pawnSpawnerComp;
|
||||
|
||||
public override void PostPostMake()
|
||||
{
|
||||
base.PostPostMake();
|
||||
pawnSpawnerComp = GetComp<CompSkyfallerPawnSpawner>();
|
||||
}
|
||||
|
||||
protected override void Impact()
|
||||
{
|
||||
// 在调用基类 Impact 之前保存位置信息
|
||||
IntVec3 impactPosition = base.Position;
|
||||
Map impactMap = base.Map;
|
||||
|
||||
// 调用基类 Impact 方法(这会处理爆炸、碎片等效果)
|
||||
base.Impact();
|
||||
|
||||
// 生成 Pawn
|
||||
if (pawnSpawnerComp != null && impactMap != null)
|
||||
{
|
||||
pawnSpawnerComp.SpawnPawn(impactMap, impactPosition);
|
||||
}
|
||||
}
|
||||
|
||||
// 可选:重写 SpawnThings 方法以防止生成原版的内容
|
||||
protected override void SpawnThings()
|
||||
{
|
||||
// 如果我们要生成 Pawn,可能不想生成原版的物品
|
||||
// 但保留原版逻辑以防有其他内容需要生成
|
||||
base.SpawnThings();
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
{
|
||||
base.ExposeData();
|
||||
if (Scribe.mode == LoadSaveMode.LoadingVars)
|
||||
{
|
||||
pawnSpawnerComp = GetComp<CompSkyfallerPawnSpawner>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,7 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Ability\CompAbilityEffect_LaunchMultiProjectile.cs" />
|
||||
<Compile Include="Ability\CompAbilityEffect_ResearchPrereq.cs" />
|
||||
<Compile Include="Ability\WULA_AbilityBombardment\CompAbilityEffect_Bombardment.cs" />
|
||||
<Compile Include="Ability\WULA_AbilityBombardment\CompProperties_AbilityBombardment.cs" />
|
||||
@@ -142,6 +143,7 @@
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_FloatMenuOptionProvider_SelectedPawnValid.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_IsColonyMechPlayerControlled.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_MechanitorUtility_CanDraftMech.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_Pawn_ThreatDisabled.cs" />
|
||||
<Compile Include="HarmonyPatches\WULA_AutonomousMech\Patch_UncontrolledMechDrawPulse.cs" />
|
||||
<Compile Include="HediffComp\HediffCompProperties_NanoRepair.cs" />
|
||||
<Compile Include="HediffComp\HediffCompProperties_SwitchableHediff.cs" />
|
||||
@@ -220,6 +222,8 @@
|
||||
<Compile Include="BuildingComp\WULA_Shuttle\Dialog_ArmedShuttleTransfer.cs" />
|
||||
<Compile Include="BuildingComp\WULA_Shuttle\GenStep_WulaPocketSpaceSmall.cs" />
|
||||
<Compile Include="BuildingComp\WULA_Shuttle\PocketSpaceThingHolder.cs" />
|
||||
<Compile Include="ThingComp\WULA_SkyfallerPawnSpawner\CompProperties_SkyfallerPawnSpawner.cs" />
|
||||
<Compile Include="ThingComp\WULA_SkyfallerPawnSpawner\Skyfaller_PawnSpawner.cs" />
|
||||
<Compile Include="Utils\BezierUtil.cs" />
|
||||
<Compile Include="Verb\MeleeAttack_Cleave\CompCleave.cs" />
|
||||
<Compile Include="HarmonyPatches\Caravan_NeedsTracker_TrySatisfyPawnNeeds_Patch.cs" />
|
||||
|
||||
Reference in New Issue
Block a user