暂存
This commit is contained in:
@@ -181,7 +181,7 @@
|
||||
<Compile Include="Pawn_Comps\ARA_TrainingWork\TrainingSystem_Patcher.cs" />
|
||||
<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" />
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,11 +40,16 @@ namespace ArachnaeSwarm
|
||||
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 +57,8 @@ namespace ArachnaeSwarm
|
||||
base.SpawnSetup(map, respawningAfterLoad);
|
||||
settings = def.GetModExtension<CruiseMissileProperties>() ?? new CruiseMissileProperties();
|
||||
this.isDummy = settings.isDummy;
|
||||
// 初始化我们自己的位置
|
||||
exactPositionInt = origin;
|
||||
}
|
||||
|
||||
private void RandFactor()
|
||||
@@ -166,15 +173,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() 来阻止直线运动逻辑
|
||||
// base.Tick();
|
||||
|
||||
// 更新目标位置
|
||||
if (intendedTarget.Thing is Pawn pawn && pawn.Spawned && !pawn.Destroyed)
|
||||
{
|
||||
if ((pawn.Dead || pawn.Downed) && DistanceCoveredFraction < 0.6f)
|
||||
@@ -183,7 +191,25 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
destination = pawn.DrawPos;
|
||||
}
|
||||
base.Tick();
|
||||
|
||||
// 更新ticksToImpact,这是从基类Projectile复制过来的逻辑
|
||||
ticksToImpact--;
|
||||
if (ticksToImpact <= 0)
|
||||
{
|
||||
// 时间到了,强制撞击
|
||||
Impact(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新我们自己的位置
|
||||
exactPositionInt = BPos(this.DistanceCoveredFraction);
|
||||
|
||||
// 检查是否到达终点
|
||||
if (this.DistanceCoveredFraction >= 1f)
|
||||
{
|
||||
Impact(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void FindNextTarget(Vector3 center)
|
||||
|
||||
Reference in New Issue
Block a user