改动一大堆

This commit is contained in:
2025-09-20 12:00:15 +08:00
parent 5b231de977
commit feba171a2c
22 changed files with 620 additions and 217 deletions

View File

@@ -3,16 +3,8 @@
"WorkspaceRootPath": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\abilities\\ara_abilityswitch\\compabilityeffect_giveswitchhediff.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:abilities\\ara_abilityswitch\\compabilityeffect_giveswitchhediff.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\abilities\\ara_abilityswitch\\compabilityeffect_removeswitchhediff.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:abilities\\ara_abilityswitch\\compabilityeffect_removeswitchhediff.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\abilities\\ara_abilityswitch\\weaponswitch.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:abilities\\ara_abilityswitch\\weaponswitch.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\hediffs\\ara_hediffcomp_topturret\\hediffcomp_topturret.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:hediffs\\ara_hediffcomp_topturret\\hediffcomp_topturret.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
@@ -22,50 +14,24 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 3,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "WeaponSwitch.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\ARA_AbilitySwitch\\WeaponSwitch.cs",
"RelativeDocumentMoniker": "Abilities\\ARA_AbilitySwitch\\WeaponSwitch.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\ARA_AbilitySwitch\\WeaponSwitch.cs",
"RelativeToolTip": "Abilities\\ARA_AbilitySwitch\\WeaponSwitch.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA4AAAAhAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-09-19T06:39:20.978Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "CompAbilityEffect_RemoveSwitchHediff.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\ARA_AbilitySwitch\\CompAbilityEffect_RemoveSwitchHediff.cs",
"RelativeDocumentMoniker": "Abilities\\ARA_AbilitySwitch\\CompAbilityEffect_RemoveSwitchHediff.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\ARA_AbilitySwitch\\CompAbilityEffect_RemoveSwitchHediff.cs",
"RelativeToolTip": "Abilities\\ARA_AbilitySwitch\\CompAbilityEffect_RemoveSwitchHediff.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAMAAAAXAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-09-19T06:39:18.492Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "CompAbilityEffect_GiveSwitchHediff.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\ARA_AbilitySwitch\\CompAbilityEffect_GiveSwitchHediff.cs",
"RelativeDocumentMoniker": "Abilities\\ARA_AbilitySwitch\\CompAbilityEffect_GiveSwitchHediff.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\ARA_AbilitySwitch\\CompAbilityEffect_GiveSwitchHediff.cs",
"RelativeToolTip": "Abilities\\ARA_AbilitySwitch\\CompAbilityEffect_GiveSwitchHediff.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAMAAAAXAAAAAAAAAA==",
"Title": "HediffComp_TopTurret.cs",
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HediffComp_TopTurret\\HediffComp_TopTurret.cs",
"RelativeDocumentMoniker": "Hediffs\\ARA_HediffComp_TopTurret\\HediffComp_TopTurret.cs",
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HediffComp_TopTurret\\HediffComp_TopTurret.cs",
"RelativeToolTip": "Hediffs\\ARA_HediffComp_TopTurret\\HediffComp_TopTurret.cs",
"ViewState": "AgIAAIUAAAAAAAAAAAAswAoAAAAFAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-09-19T06:39:09.674Z",
"WhenOpened": "2025-09-20T03:55:47.292Z",
"EditorCaption": ""
},
{
"$type": "Bookmark",
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
}
]
}

View File

@@ -133,6 +133,7 @@
<Compile Include="Hediffs\ARA_ConfigurableMutant\HediffComp_NecroticTransformation.cs" />
<Compile Include="Hediffs\ARA_ConfigurableMutant\HediffComp_Symbiosis.cs" />
<Compile Include="Hediffs\ARA_ConfigurableMutant\NecroticTransformationUtility.cs" />
<Compile Include="Hediffs\ARA_HediffComp_TopTurret\HediffComp_TopTurret.cs" />
<Compile Include="Hediffs\ARA_HiveMind\CompAbilityEffect_BindDrone.cs" />
<Compile Include="Hediffs\ARA_HiveMind\CompProperties_AbilityBindDrone.cs" />
<Compile Include="Hediffs\ARA_HiveMind\Hediff_HiveMindDrone.cs" />

View File

@@ -0,0 +1,268 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using Verse;
using Verse.AI;
using RimWorld;
namespace ArachnaeSwarm
{
public class HediffCompProperties_TopTurret : HediffCompProperties
{
public HediffCompProperties_TopTurret()
{
this.compClass = typeof(HediffComp_TopTurret);
}
public ThingDef turretDef;
public float angleOffset;
public bool autoAttack = true;
}
[StaticConstructorOnStartup]
public class HediffComp_TopTurret : HediffComp, IAttackTargetSearcher
{
public Thing Thing
{
get
{
return this.Pawn;
}
}
private HediffCompProperties_TopTurret Props
{
get
{
return (HediffCompProperties_TopTurret)this.props;
}
}
public Verb CurrentEffectiveVerb
{
get
{
return this.AttackVerb;
}
}
public LocalTargetInfo LastAttackedTarget
{
get
{
return this.lastAttackedTarget;
}
}
public int LastAttackTargetTick
{
get
{
return this.lastAttackTargetTick;
}
}
public CompEquippable GunCompEq
{
get
{
return this.gun.TryGetComp<CompEquippable>();
}
}
public Verb AttackVerb
{
get
{
return this.GunCompEq.PrimaryVerb;
}
}
private bool WarmingUp
{
get
{
return this.burstWarmupTicksLeft > 0;
}
}
private bool CanShoot
{
get
{
Pawn pawn;
if ((pawn = (this.Pawn)) != null)
{
if (!pawn.Spawned || pawn.Downed || pawn.Dead || !pawn.Awake())
{
return false;
}
if (pawn.stances.stunner.Stunned)
{
return false;
}
if (this.TurretDestroyed)
{
return false;
}
if (pawn.IsColonyMechPlayerControlled && !this.fireAtWill)
{
return false;
}
}
CompCanBeDormant compCanBeDormant = this.Pawn.TryGetComp<CompCanBeDormant>();
return compCanBeDormant == null || compCanBeDormant.Awake;
}
}
public bool TurretDestroyed
{
get
{
Pawn pawn;
return (pawn = (this.Pawn)) != null && this.AttackVerb.verbProps.linkedBodyPartsGroup != null && this.AttackVerb.verbProps.ensureLinkedBodyPartsGroupAlwaysUsable && PawnCapacityUtility.CalculateNaturalPartsAverageEfficiency(pawn.health.hediffSet, this.AttackVerb.verbProps.linkedBodyPartsGroup) <= 0f;
}
}
private Material TurretMat
{
get
{
if (this.turretMat == null)
{
this.turretMat = MaterialPool.MatFrom(this.Props.turretDef.graphicData.texPath);
}
return this.turretMat;
}
}
public bool AutoAttack
{
get
{
return this.Props.autoAttack;
}
}
public override void CompPostMake()
{
base.CompPostMake();
this.MakeGun();
}
private void MakeGun()
{
this.gun = ThingMaker.MakeThing(this.Props.turretDef, null);
this.UpdateGunVerbs();
}
private void UpdateGunVerbs()
{
List<Verb> allVerbs = this.gun.TryGetComp<CompEquippable>().AllVerbs;
for (int i = 0; i < allVerbs.Count; i++)
{
Verb verb = allVerbs[i];
verb.caster = this.Pawn;
verb.castCompleteCallback = delegate ()
{
this.burstCooldownTicksLeft = this.AttackVerb.verbProps.defaultCooldownTime.SecondsToTicks();
};
}
}
public override void CompPostTick(ref float severityAdjustment)
{
base.CompPostTick(ref severityAdjustment);
if (!this.CanShoot)
{
return;
}
if (this.currentTarget.IsValid)
{
this.curRotation = (this.currentTarget.Cell.ToVector3Shifted() - this.Pawn.DrawPos).AngleFlat() + this.Props.angleOffset;
}
this.AttackVerb.VerbTick();
if (this.AttackVerb.state != VerbState.Bursting)
{
if (this.WarmingUp)
{
this.burstWarmupTicksLeft--;
if (this.burstWarmupTicksLeft == 0)
{
this.AttackVerb.TryStartCastOn(this.currentTarget, false, true, false, true);
this.lastAttackTargetTick = Find.TickManager.TicksGame;
this.lastAttackedTarget = this.currentTarget;
return;
}
}
else
{
if (this.burstCooldownTicksLeft > 0)
{
this.burstCooldownTicksLeft--;
}
if (this.burstCooldownTicksLeft <= 0 && this.Pawn.IsHashIntervalTick(10))
{
this.currentTarget = (Thing)AttackTargetFinder.BestShootTargetFromCurrentPosition(this, TargetScanFlags.NeedThreat | TargetScanFlags.NeedAutoTargetable, null, 0f, 9999f);
if (this.currentTarget.IsValid)
{
this.burstWarmupTicksLeft = 1;
return;
}
this.ResetCurrentTarget();
}
}
}
}
private void ResetCurrentTarget()
{
this.currentTarget = LocalTargetInfo.Invalid;
this.burstWarmupTicksLeft = 0;
}
public override void CompExposeData()
{
base.CompExposeData();
Scribe_Values.Look<int>(ref this.burstCooldownTicksLeft, "burstCooldownTicksLeft", 0, false);
Scribe_Values.Look<int>(ref this.burstWarmupTicksLeft, "burstWarmupTicksLeft", 0, false);
Scribe_TargetInfo.Look(ref this.currentTarget, "currentTarget");
Scribe_Deep.Look<Thing>(ref this.gun, "gun", Array.Empty<object>());
Scribe_Values.Look<bool>(ref this.fireAtWill, "fireAtWill", true, false);
if (Scribe.mode == LoadSaveMode.PostLoadInit)
{
if (this.gun == null)
{
Log.Error("CompTurrentGun had null gun after loading. Recreating.");
this.MakeGun();
return;
}
this.UpdateGunVerbs();
}
}
private const int StartShootIntervalTicks = 10;
private static readonly CachedTexture ToggleTurretIcon = new CachedTexture("UI/Gizmos/ToggleTurret");
public Thing gun;
protected int burstCooldownTicksLeft;
protected int burstWarmupTicksLeft;
protected LocalTargetInfo currentTarget = LocalTargetInfo.Invalid;
private bool fireAtWill = true;
private LocalTargetInfo lastAttackedTarget = LocalTargetInfo.Invalid;
private int lastAttackTargetTick;
private float curRotation;
[Unsaved(false)]
public Material turretMat;
}
}

View File

@@ -31,11 +31,22 @@ namespace ArachnaeSwarm
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))
// 检查种族是否在我们的目标列表中如果列表为空或null则不进行任何操作
if ( pawn.Dead || pawn.health == null || pawn == parent.pawn || !(pawn.Position.DistanceTo(parent.pawn.Position) <= Props.range) || !Props.targetingParameters.CanTarget(pawn))
{
continue;
}
else
{
// 如果列表是空的或null则默认对所有的pawn进行操作
if (Props.targetRaces.NullOrEmpty())
{
}
else if (!Props.targetRaces.Contains(pawn.def))
{
continue;
}
}
Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(Props.hediff);
if (hediff == null)
{