raceaura
This commit is contained in:
Binary file not shown.
30
1.6/1.6/Defs/HediffDefs/Hediffs_WULA_AuraExample.xml
Normal file
30
1.6/1.6/Defs/HediffDefs/Hediffs_WULA_AuraExample.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
|
||||
<HediffDef>
|
||||
<defName>MyWulaAura</defName>
|
||||
<label>乌拉共鸣光环</label>
|
||||
<description>这是一个如何使用HediffComp_GiveHediffsInRangeToRace组件的示例。</description>
|
||||
<hediffClass>HediffWithComps</hediffClass>
|
||||
<comps>
|
||||
<!-- 这里使用我们新创建的C#类的完整名称 -->
|
||||
<li Class="WulaFallenEmpire.HediffCompProperties_GiveHediffsInRangeToRace">
|
||||
<range>10</range>
|
||||
<hediff>PsychicSoothe</hediff> <!-- 举例:要施加的Hediff -->
|
||||
|
||||
<!-- 定义可以被影响的种族列表 -->
|
||||
<targetRaces>
|
||||
<li>WulaSpecies</li> <!-- 您的乌拉种族 -->
|
||||
<li>Human</li> <!-- 也可以添加其他种族 -->
|
||||
</targetRaces>
|
||||
|
||||
<!-- 其他参数和原版一样 -->
|
||||
<targetingParameters>
|
||||
<canTargetAllies>true</canTargetAllies>
|
||||
</targetingParameters>
|
||||
<onlyPawnsInSameFaction>true</onlyPawnsInSameFaction>
|
||||
</li>
|
||||
</comps>
|
||||
</HediffDef>
|
||||
|
||||
</Defs>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class HediffCompProperties_GiveHediffsInRangeToRace : HediffCompProperties
|
||||
{
|
||||
public float range;
|
||||
public TargetingParameters targetingParameters;
|
||||
public HediffDef hediff;
|
||||
public ThingDef mote;
|
||||
public bool hideMoteWhenNotDrafted;
|
||||
public float initialSeverity = 1f;
|
||||
public bool onlyPawnsInSameFaction = true;
|
||||
public List<ThingDef> targetRaces; // 新增:可配置的目标种族列表
|
||||
|
||||
public HediffCompProperties_GiveHediffsInRangeToRace()
|
||||
{
|
||||
compClass = typeof(HediffComp_GiveHediffsInRangeToRace);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class HediffComp_GiveHediffsInRangeToRace : HediffComp
|
||||
{
|
||||
private Mote mote;
|
||||
|
||||
public HediffCompProperties_GiveHediffsInRangeToRace Props => (HediffCompProperties_GiveHediffsInRangeToRace)props;
|
||||
|
||||
public override void CompPostTick(ref float severityAdjustment)
|
||||
{
|
||||
if (!parent.pawn.Awake() || parent.pawn.health == null || parent.pawn.health.InPainShock || !parent.pawn.Spawned)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Props.hideMoteWhenNotDrafted || parent.pawn.Drafted)
|
||||
{
|
||||
if (Props.mote != null && (mote == null || mote.Destroyed))
|
||||
{
|
||||
mote = MoteMaker.MakeAttachedOverlay(parent.pawn, Props.mote, Vector3.zero);
|
||||
}
|
||||
if (mote != null)
|
||||
{
|
||||
mote.Maintain();
|
||||
}
|
||||
}
|
||||
IReadOnlyList<Pawn> pawns = ((!Props.onlyPawnsInSameFaction || parent.pawn.Faction == null) ? parent.pawn.Map.mapPawns.AllPawnsSpawned : parent.pawn.Map.mapPawns.SpawnedPawnsInFaction(parent.pawn.Faction));
|
||||
foreach (Pawn pawn in pawns)
|
||||
{
|
||||
// 修改点:检查种族是否在我们的目标列表中,如果列表为空或null则不进行任何操作
|
||||
if ((Props.targetRaces.NullOrEmpty() || !Props.targetRaces.Contains(pawn.def)) || pawn.Dead || pawn.health == null || pawn == parent.pawn || !(pawn.Position.DistanceTo(parent.pawn.Position) <= Props.range) || !Props.targetingParameters.CanTarget(pawn))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(Props.hediff);
|
||||
if (hediff == null)
|
||||
{
|
||||
hediff = pawn.health.AddHediff(Props.hediff, pawn.health.hediffSet.GetBrain());
|
||||
hediff.Severity = Props.initialSeverity;
|
||||
HediffComp_Link hediffComp_Link = hediff.TryGetComp<HediffComp_Link>();
|
||||
if (hediffComp_Link != null)
|
||||
{
|
||||
hediffComp_Link.drawConnection = true;
|
||||
hediffComp_Link.other = parent.pawn;
|
||||
}
|
||||
}
|
||||
HediffComp_Disappears hediffComp_Disappears = hediff.TryGetComp<HediffComp_Disappears>();
|
||||
if (hediffComp_Disappears == null)
|
||||
{
|
||||
Log.Error("HediffComp_GiveHediffsInRangeToRace has a hediff in props which does not have a HediffComp_Disappears");
|
||||
}
|
||||
else
|
||||
{
|
||||
hediffComp_Disappears.ticksToDisappear = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,6 +185,8 @@
|
||||
<Compile Include="Hediff_DamageShield.cs" />
|
||||
<Compile Include="DRMDamageShield.cs" />
|
||||
<Compile Include="CompUseEffect_AddDamageShieldCharges.cs" />
|
||||
<Compile Include="HediffCompProperties_GiveHediffsInRangeToRace.cs" />
|
||||
<Compile Include="HediffComp_GiveHediffsInRangeToRace.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
Reference in New Issue
Block a user