Merge branch 'master' of https://git.ra3battle.cn/Kalospacer/ArachnaeSwarm
This commit is contained in:
Binary file not shown.
@@ -3,16 +3,16 @@
|
||||
"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\\thoughts\\ara_creepycrawly.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:thoughts\\ara_creepycrawly.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_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\\mainharmony.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:mainharmony.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\\aradefof.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:aradefof.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}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
@@ -22,50 +22,50 @@
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 2,
|
||||
"SelectedChildIndex": 3,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "MainHarmony.cs",
|
||||
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\MainHarmony.cs",
|
||||
"RelativeDocumentMoniker": "MainHarmony.cs",
|
||||
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\MainHarmony.cs",
|
||||
"RelativeToolTip": "MainHarmony.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABEAAAA+AAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-09-19T03:12:09.458Z",
|
||||
"EditorCaption": ""
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 2,
|
||||
"Title": "ARADefOf.cs",
|
||||
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\ARADefOf.cs",
|
||||
"RelativeDocumentMoniker": "ARADefOf.cs",
|
||||
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\ARADefOf.cs",
|
||||
"RelativeToolTip": "ARADefOf.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAkAAAAfAAAAAAAAAA==",
|
||||
"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-19T03:10:54.9Z",
|
||||
"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": "ARA_CreepyCrawly.cs",
|
||||
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Thoughts\\ARA_CreepyCrawly.cs",
|
||||
"RelativeDocumentMoniker": "Thoughts\\ARA_CreepyCrawly.cs",
|
||||
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Thoughts\\ARA_CreepyCrawly.cs",
|
||||
"RelativeToolTip": "Thoughts\\ARA_CreepyCrawly.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABIAAAANAAAAAAAAAA==",
|
||||
"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==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-09-19T02:36:25.114Z",
|
||||
"WhenOpened": "2025-09-19T06:39:09.674Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompAbilityEffect_GiveSwitchHediff : CompAbilityEffect
|
||||
{
|
||||
public new CompProperties_AbilityGiveHediff Props => (CompProperties_AbilityGiveHediff)props;
|
||||
|
||||
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
||||
{
|
||||
base.Apply(target, dest);
|
||||
if (Props.hediffDef != null)
|
||||
{
|
||||
parent.pawn.health.AddHediff(Props.hediffDef);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ShouldHideGizmo
|
||||
{
|
||||
get
|
||||
{
|
||||
// 如果父级Pawn已经有了这个Hediff,就隐藏“给予”按钮
|
||||
if (parent.pawn?.health.hediffSet.HasHediff(Props.hediffDef) ?? false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return base.ShouldHideGizmo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompAbilityEffect_RemoveSwitchHediff : CompAbilityEffect
|
||||
{
|
||||
public new CompProperties_AbilityRemoveHediff Props => (CompProperties_AbilityRemoveHediff)props;
|
||||
|
||||
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
||||
{
|
||||
base.Apply(target, dest);
|
||||
Hediff firstHediffOfDef = parent.pawn.health.hediffSet.GetFirstHediffOfDef(Props.hediffDef);
|
||||
if (firstHediffOfDef != null)
|
||||
{
|
||||
parent.pawn.health.RemoveHediff(firstHediffOfDef);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ShouldHideGizmo
|
||||
{
|
||||
get
|
||||
{
|
||||
// 如果父级Pawn没有这个Hediff,就隐藏“移除”按钮
|
||||
if (!parent.pawn?.health.hediffSet.HasHediff(Props.hediffDef) ?? true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return base.ShouldHideGizmo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
202
Source/ArachnaeSwarm/Abilities/ARA_AbilitySwitch/WeaponSwitch.cs
Normal file
202
Source/ArachnaeSwarm/Abilities/ARA_AbilitySwitch/WeaponSwitch.cs
Normal file
@@ -0,0 +1,202 @@
|
||||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class CompProperties_Switch : CompProperties_EquippableAbility
|
||||
{
|
||||
public ThingDef changeTo;
|
||||
public CompProperties_Switch()
|
||||
{
|
||||
compClass = typeof(CompSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompSwitch : CompEquippableAbility
|
||||
{
|
||||
public CompProperties_Switch Props => (CompProperties_Switch)props;
|
||||
|
||||
public HediffWithComps hediff;
|
||||
public HediffComp_Disappears Disappears => hediff.GetComp<HediffComp_Disappears>();
|
||||
public override void Notify_Equipped(Pawn pawn)
|
||||
{
|
||||
base.Notify_Equipped(pawn);
|
||||
if (hediff != null)
|
||||
{
|
||||
pawn.health.AddHediff(hediff);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Notify_Unequipped(Pawn pawn)
|
||||
{
|
||||
base.Notify_Unequipped(pawn);
|
||||
if (hediff != null)
|
||||
{
|
||||
pawn.health.RemoveHediff(hediff);
|
||||
}
|
||||
}
|
||||
|
||||
public override string CompInspectStringExtra()
|
||||
{
|
||||
string text = "";
|
||||
if (hediff != null)
|
||||
{
|
||||
text += hediff.LabelBase + ": " + Disappears.ticksToDisappear.ToStringSecondsFromTicks("F0");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
public override void CompTick()
|
||||
{
|
||||
base.CompTick();
|
||||
if (hediff != null)
|
||||
{
|
||||
float severityAdjustment = 0f;
|
||||
Disappears.CompPostTick(ref severityAdjustment);
|
||||
if (Disappears.ticksToDisappear <= 0)
|
||||
{
|
||||
hediff = null;
|
||||
Extension.ChangeOldThing(parent, Props.changeTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void PostExposeData()
|
||||
{
|
||||
base.PostExposeData();
|
||||
Scribe_References.Look(ref hediff, "hediff", true);
|
||||
}
|
||||
}
|
||||
|
||||
public class CompAbilityEffect_Switch : CompAbilityEffect
|
||||
{
|
||||
public Pawn Pawn => parent.pawn;
|
||||
public ThingWithComps BaseForm => Pawn.equipment.Primary;
|
||||
public ThingDef ChangeTo => BaseForm.GetComp<CompSwitch>().Props.changeTo;
|
||||
|
||||
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
||||
{
|
||||
base.Apply(target, dest);
|
||||
Pawn.ChangeEquipThing(BaseForm, ChangeTo);
|
||||
}
|
||||
public override bool AICanTargetNow(LocalTargetInfo target)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class CompAbilityEffect_RemoveHediff : CompAbilityEffect
|
||||
{
|
||||
public Pawn Pawn => parent.pawn;
|
||||
public ThingWithComps BaseForm => Pawn.equipment.Primary;
|
||||
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
||||
{
|
||||
base.Apply(target, dest);
|
||||
CompSwitch comp = BaseForm.GetComp<CompSwitch>();
|
||||
if (comp.hediff != null)
|
||||
{
|
||||
comp.Disappears.ticksToDisappear = 0;
|
||||
Pawn.health.RemoveHediff(comp.hediff);
|
||||
comp.hediff = null;
|
||||
}
|
||||
}
|
||||
public override bool AICanTargetNow(LocalTargetInfo target)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Extension
|
||||
{
|
||||
public static ThingWithComps ChangeThing(ThingWithComps baseForm, ThingDef changeTo)
|
||||
{
|
||||
int hitPoints = baseForm.HitPoints;
|
||||
ThingDef stuff = null;
|
||||
if (baseForm.Stuff != null)
|
||||
{
|
||||
stuff = baseForm.Stuff;
|
||||
}
|
||||
ThingWithComps newThing = (ThingWithComps)ThingMaker.MakeThing(changeTo, stuff);
|
||||
newThing.HitPoints = hitPoints;
|
||||
for (int i = 0; i < newThing.AllComps.Count; i++)
|
||||
{
|
||||
CompProperties Index = newThing.AllComps[i].props;
|
||||
ThingComp baseComp = baseForm.GetCompByDefType(Index);
|
||||
if (baseComp != null)
|
||||
{
|
||||
baseComp.parent = newThing;
|
||||
newThing.AllComps[i] = baseComp;
|
||||
}
|
||||
}
|
||||
CompSwitch compSwitch = newThing.GetComp<CompSwitch>();
|
||||
compSwitch.Initialize(newThing.def.comps.Find(x => x.compClass == typeof(CompSwitch)));
|
||||
ThingStyleDef styleDef = baseForm.StyleDef;
|
||||
if (baseForm.def.randomStyle != null && newThing.def.randomStyle != null)
|
||||
{
|
||||
ThingStyleChance chance = baseForm.def.randomStyle.Find(x => x.StyleDef == styleDef);
|
||||
int index = baseForm.def.randomStyle.IndexOf(chance);
|
||||
newThing.StyleDef = newThing.def.randomStyle[index].StyleDef;
|
||||
}
|
||||
return newThing;
|
||||
}
|
||||
|
||||
public static void ChangeOldThing(ThingWithComps baseForm, ThingDef changeTo)
|
||||
{
|
||||
ThingWithComps newThing = ChangeThing(baseForm, changeTo);
|
||||
IntVec3 intVec3 = baseForm.Position;
|
||||
Map map = baseForm.Map;
|
||||
baseForm.Destroy();
|
||||
GenSpawn.Spawn(newThing, intVec3, map);
|
||||
}
|
||||
|
||||
public static void ChangeEquipThing(this Pawn pawn, ThingWithComps baseForm, ThingDef changeTo)
|
||||
{
|
||||
ThingWithComps newThing = ChangeThing(baseForm, changeTo);
|
||||
pawn.equipment.DestroyEquipment(baseForm);
|
||||
baseForm.Notify_Unequipped(pawn);
|
||||
pawn.equipment.MakeRoomFor(newThing);
|
||||
pawn.equipment.AddEquipment(newThing);
|
||||
}
|
||||
}
|
||||
|
||||
public class HediffCompPropertiesSwitch : HediffCompProperties_GiveAbility
|
||||
{
|
||||
public HediffCompPropertiesSwitch()
|
||||
{
|
||||
compClass = typeof(SwitchWhenDisappear);
|
||||
}
|
||||
}
|
||||
public class SwitchWhenDisappear : HediffComp_GiveAbility
|
||||
{
|
||||
public HediffCompPropertiesSwitch Props => (HediffCompPropertiesSwitch)props;
|
||||
public override void CompPostMake()
|
||||
{
|
||||
base.CompPostMake();
|
||||
CompSwitch compSwitch = Pawn.equipment.Primary.GetComp<CompSwitch>();
|
||||
compSwitch.hediff = parent;
|
||||
}
|
||||
public override void CompPostPostRemoved()
|
||||
{
|
||||
base.CompPostPostRemoved();
|
||||
if (parent.ShouldRemove)
|
||||
{
|
||||
ThingWithComps thing = Pawn.equipment.Primary;
|
||||
if (thing != null)
|
||||
{
|
||||
CompSwitch compSwitch = thing.GetComp<CompSwitch>();
|
||||
compSwitch.hediff = null;
|
||||
if (compSwitch != null)
|
||||
{
|
||||
Pawn.ChangeEquipThing(thing, compSwitch.Props.changeTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,9 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Abilities\ARA_AbilitySwitch\CompAbilityEffect_GiveSwitchHediff.cs" />
|
||||
<Compile Include="Abilities\ARA_AbilitySwitch\CompAbilityEffect_RemoveSwitchHediff.cs" />
|
||||
<Compile Include="Abilities\ARA_AbilitySwitch\WeaponSwitch.cs" />
|
||||
<Compile Include="Abilities\ARA_HuggingFace\CompAbilityEffect_Possess.cs" />
|
||||
<Compile Include="Abilities\ARA_HuggingFace\CompProperties_AbilityPossess.cs" />
|
||||
<Compile Include="Abilities\ARA_HuggingFace\Hediff_Possession.cs" />
|
||||
|
||||
Reference in New Issue
Block a user