Merge branch 'master' of https://git.ra3battle.cn/Kalospacer/ArachnaeSwarm
This commit is contained in:
@@ -182,6 +182,7 @@
|
||||
<Compile Include="Thing_Comps\ARA_CustomUniqueWeapon\CompCustomUniqueWeapon.cs" />
|
||||
<Compile Include="Thing_Comps\ARA_CustomUniqueWeapon\CompProperties_CustomUniqueWeapon.cs" />
|
||||
<Compile Include="Thing_Comps\ARA_IngestionOutcomeDoer_GiveHediff\IngestionOutcomeDoer_GiveHediffByRace.cs" />
|
||||
<Compile Include="Thing_Comps\Filth_Toxic.cs" />
|
||||
<Compile Include="Thing_Comps\OPToxicGas.cs" />
|
||||
<Compile Include="Verbs\Cleave\CompCleave.cs" />
|
||||
<Compile Include="Verbs\Cleave\Verb_MeleeAttack_Cleave.cs" />
|
||||
|
||||
@@ -24,14 +24,13 @@ namespace ArachnaeSwarm
|
||||
|
||||
protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested, int ingestedCount)
|
||||
{
|
||||
// 如果列表是空的或null,则默认对所有的pawn进行操作
|
||||
if (!targetRaces.Contains(pawn.def))
|
||||
// 如果 targetRaces 列表有内容,并且当前pawn的种族不在列表中,则不执行任何操作。
|
||||
if (!targetRaces.NullOrEmpty() && !targetRaces.Contains(pawn.def))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (targetRaces.NullOrEmpty())
|
||||
{
|
||||
}
|
||||
|
||||
// 如果列表为空,或者pawn的种族在列表中,则继续执行后续代码
|
||||
Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn);
|
||||
float effect = ((!(severity > 0f)) ? hediffDef.initialSeverity : severity);
|
||||
AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(pawn, toleranceChemical, ref effect, multiplyByGeneToleranceFactors, divideByBodySize);
|
||||
|
||||
74
Source/ArachnaeSwarm/Thing_Comps/Filth_Toxic.cs
Normal file
74
Source/ArachnaeSwarm/Thing_Comps/Filth_Toxic.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class Filth_Toxic : Filth
|
||||
{
|
||||
protected override void Tick()
|
||||
{
|
||||
base.Tick();
|
||||
// 检查是否到了自动消失的时间
|
||||
if (base.DisappearAfterTicks > 0 && Find.TickManager.TicksGame >= base.DisappearAfterTicks)
|
||||
{
|
||||
this.Destroy(DestroyMode.Vanish);
|
||||
return;
|
||||
}
|
||||
|
||||
// 周期性施加毒气效果
|
||||
if (!base.Destroyed && Find.TickManager.TicksGame % OPToxicDefGetValue.OPToxicGetSevUpVal(this.def) == 0)
|
||||
{
|
||||
Map map = base.Map;
|
||||
IntVec3 position = base.Position;
|
||||
List<Thing> thingList = position.GetThingList(map);
|
||||
if (thingList.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < thingList.Count; i++)
|
||||
{
|
||||
if (thingList[i] is Pawn pawn && !pawn.RaceProps.IsMechanoid && thingList[i].Position == position)
|
||||
{
|
||||
this.DoOPToxicGas(this, pawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DoOPToxicGas(Thing filth, Thing targ)
|
||||
{
|
||||
Pawn pawn = targ as Pawn;
|
||||
if (pawn != null && pawn.health.capacities.CapableOf(PawnCapacityDefOf.Breathing))
|
||||
{
|
||||
HediffDef hediffDef = DefDatabase<HediffDef>.GetNamedSilentFail(OPToxicDefGetValue.OPToxicGetHediff(filth.def));
|
||||
if (hediffDef != null)
|
||||
{
|
||||
Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(hediffDef, false);
|
||||
|
||||
float toxicResistance = pawn.GetStatValue(StatDefOf.ToxicResistance, true, -1);
|
||||
float severityPerTick = OPToxicDefGetValue.OPToxicGetSev(filth.def);
|
||||
|
||||
if (severityPerTick < 0.01f)
|
||||
{
|
||||
severityPerTick = 0.01f;
|
||||
}
|
||||
|
||||
// 考虑污渍厚度对严重性的影响
|
||||
float severityToAdd = Rand.Range(0.01f, severityPerTick) * (1f - toxicResistance) * this.thickness;
|
||||
|
||||
if (hediff != null && severityToAdd > 0f)
|
||||
{
|
||||
hediff.Severity += severityToAdd;
|
||||
}
|
||||
else
|
||||
{
|
||||
Hediff newHediff = HediffMaker.MakeHediff(hediffDef, pawn, null);
|
||||
newHediff.Severity = severityToAdd;
|
||||
pawn.health.AddHediff(newHediff, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,14 +37,18 @@ namespace ArachnaeSwarm
|
||||
private CruiseMissileProperties settings;
|
||||
private bool flag2;
|
||||
private Vector3 Randdd;
|
||||
private Vector3 position2;
|
||||
public Vector3 ExPos;
|
||||
public bool isDummy = false;
|
||||
|
||||
private Vector3 exactPositionInt; // 用于存储我们自己计算的位置
|
||||
public override Vector3 ExactPosition => exactPositionInt; // 重写属性,让游戏获取我们计算的位置
|
||||
public override Quaternion ExactRotation => Quaternion.LookRotation(destination - origin); // 弹头始终朝向目标
|
||||
|
||||
public override void ExposeData()
|
||||
{
|
||||
base.ExposeData();
|
||||
Scribe_Values.Look(ref isDummy, "isDummy", false);
|
||||
Scribe_Values.Look(ref exactPositionInt, "exactPositionInt");
|
||||
}
|
||||
|
||||
public override void SpawnSetup(Map map, bool respawningAfterLoad)
|
||||
@@ -52,6 +56,8 @@ namespace ArachnaeSwarm
|
||||
base.SpawnSetup(map, respawningAfterLoad);
|
||||
settings = def.GetModExtension<CruiseMissileProperties>() ?? new CruiseMissileProperties();
|
||||
this.isDummy = settings.isDummy;
|
||||
// 初始化我们自己的位置
|
||||
exactPositionInt = origin;
|
||||
}
|
||||
|
||||
private void RandFactor()
|
||||
@@ -166,15 +172,16 @@ namespace ArachnaeSwarm
|
||||
);
|
||||
}
|
||||
|
||||
protected override void DrawAt(Vector3 position, bool flip = false)
|
||||
{
|
||||
position2 = BPos(DistanceCoveredFraction - 0.01f);
|
||||
ExPos = position = BPos(DistanceCoveredFraction);
|
||||
base.DrawAt(position, flip);
|
||||
}
|
||||
// 不再需要重写DrawAt,因为ExactPosition现在是正确的
|
||||
// protected override void DrawAt(Vector3 position, bool flip = false)
|
||||
// { ... }
|
||||
|
||||
protected override void Tick()
|
||||
{
|
||||
// 首先调用base.Tick(),让它处理组件更新(比如拖尾特效)和ticksToImpact
|
||||
base.Tick();
|
||||
|
||||
// 更新目标位置
|
||||
if (intendedTarget.Thing is Pawn pawn && pawn.Spawned && !pawn.Destroyed)
|
||||
{
|
||||
if ((pawn.Dead || pawn.Downed) && DistanceCoveredFraction < 0.6f)
|
||||
@@ -183,7 +190,30 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
destination = pawn.DrawPos;
|
||||
}
|
||||
base.Tick();
|
||||
|
||||
// 如果base.Tick()已经处理了撞击,我们就不再继续
|
||||
if (this.Destroyed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 用我们自己的曲线位置覆盖掉base.Tick()计算的直线位置
|
||||
Vector3 newPos = BPos(this.DistanceCoveredFraction);
|
||||
|
||||
// 增加边界检查
|
||||
if (!newPos.InBounds(base.Map))
|
||||
{
|
||||
this.Destroy();
|
||||
return;
|
||||
}
|
||||
exactPositionInt = newPos;
|
||||
|
||||
// 检查是否到达终点
|
||||
if (this.DistanceCoveredFraction >= 1f)
|
||||
{
|
||||
Impact(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void FindNextTarget(Vector3 center)
|
||||
|
||||
Reference in New Issue
Block a user