diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index cf6106b..fec6907 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/1.6/1.6/Defs/AbilityDefs/ARA_Abilities.xml b/1.6/1.6/Defs/AbilityDefs/ARA_Abilities.xml index d83cc24..1b2d358 100644 --- a/1.6/1.6/Defs/AbilityDefs/ARA_Abilities.xml +++ b/1.6/1.6/Defs/AbilityDefs/ARA_Abilities.xml @@ -74,7 +74,7 @@ Bullet 21 0 - EggSac + ARA_InteractiveEggSac true diff --git a/1.6/1.6/Defs/Thing_building/ARA_InteractiveEggSac.xml b/1.6/1.6/Defs/Thing_building/ARA_InteractiveEggSac.xml new file mode 100644 index 0000000..dba23de --- /dev/null +++ b/1.6/1.6/Defs/Thing_building/ARA_InteractiveEggSac.xml @@ -0,0 +1,56 @@ + + + + + ARA_InteractiveEggSac + + 一个黏滑的囊状物,可以通过交互来孵化特定的昆虫。 + Building + Building + + Things/Building/EggSac + Graphic_Random + + Building + PassThroughOnly + 0.3 + false + Light + + 20 + 0.4 + -6 + + + true + false + false + false + true + true + false + + +
  • + 6 + (113,141,117,0) +
  • +
  • + +
  • Megascarab
  • +
  • Spelopede
  • +
  • Megaspider
  • + + +
  • ARA_ArachnaeQueen
  • +
    + 300 + true + +
  • + CocoonDestroyed +
  • +
    +
    + +
    \ No newline at end of file diff --git a/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/ArachnaeSwarm_Keys.xml b/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/ArachnaeSwarm_Keys.xml new file mode 100644 index 0000000..f5c49aa --- /dev/null +++ b/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/ArachnaeSwarm_Keys.xml @@ -0,0 +1,6 @@ + + + + 孵化 {0} + + \ No newline at end of file diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj index f6a8da1..06bdd65 100644 --- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj +++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj @@ -68,6 +68,8 @@ + + diff --git a/Source/ArachnaeSwarm/CompProperties_SpawnPawnFromList.cs b/Source/ArachnaeSwarm/CompProperties_SpawnPawnFromList.cs new file mode 100644 index 0000000..14ae742 --- /dev/null +++ b/Source/ArachnaeSwarm/CompProperties_SpawnPawnFromList.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using Verse; +using Verse.AI.Group; + +namespace ArachnaeSwarm +{ + public class CompProperties_SpawnPawnFromList : CompProperties + { + public List pawnKinds; + public List whitelist; + public int delay = 0; + public bool destroyOnSpawn = false; + public Type lordJob; + + public CompProperties_SpawnPawnFromList() + { + compClass = typeof(CompSpawnPawnFromList); + } + + public override IEnumerable ConfigErrors(ThingDef parentDef) + { + foreach (string item in base.ConfigErrors(parentDef)) + { + yield return item; + } + if (lordJob != null && !typeof(LordJob).IsAssignableFrom(lordJob)) + { + yield return $"lordJob {lordJob} must be of type LordJob"; + } + } + } +} \ No newline at end of file diff --git a/Source/ArachnaeSwarm/CompSpawnPawnFromList.cs b/Source/ArachnaeSwarm/CompSpawnPawnFromList.cs new file mode 100644 index 0000000..ccdeb3c --- /dev/null +++ b/Source/ArachnaeSwarm/CompSpawnPawnFromList.cs @@ -0,0 +1,90 @@ +using System.Collections.Generic; +using Verse; +using RimWorld; +using Verse.AI.Group; + +namespace ArachnaeSwarm +{ + public class CompSpawnPawnFromList : ThingComp + { + private CompProperties_SpawnPawnFromList Props => (CompProperties_SpawnPawnFromList)props; + + private int spawnUntilTick = -1; + private PawnKindDef spawningPawnKind; + + public override IEnumerable CompFloatMenuOptions(Pawn selPawn) + { + if (spawnUntilTick > 0) + { + yield break; // 正在延迟中,不显示菜单 + } + + if (Props.whitelist == null || !Props.whitelist.Contains(selPawn.kindDef)) + { + yield break; + } + + if (Props.pawnKinds != null) + { + foreach (PawnKindDef pawnKind in Props.pawnKinds) + { + yield return new FloatMenuOption("ARA_Incubate".Translate(pawnKind.label), () => + { + StartDelayedSpawn(pawnKind); + }); + } + } + } + + private void StartDelayedSpawn(PawnKindDef pawnKind) + { + spawningPawnKind = pawnKind; + spawnUntilTick = Find.TickManager.TicksGame + Props.delay; + } + + public override void CompTick() + { + base.CompTick(); + if (spawnUntilTick > 0 && Find.TickManager.TicksGame >= spawnUntilTick) + { + SpawnPawn(spawningPawnKind); + spawnUntilTick = -1; + spawningPawnKind = null; + } + } + + private void SpawnPawn(PawnKindDef pawnKind) + { + Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnKind, parent.Faction)); + GenSpawn.Spawn(pawn, parent.Position, parent.Map); + + if (Props.lordJob != null) + { + Lord lord = LordMaker.MakeNewLord(parent.Faction, (LordJob)System.Activator.CreateInstance(Props.lordJob), parent.Map); + lord.AddPawn(pawn); + } + + if (Props.destroyOnSpawn) + { + parent.Destroy(DestroyMode.Vanish); + } + } + + public override string CompInspectStringExtra() + { + if (spawnUntilTick > 0) + { + int remainingTicks = spawnUntilTick - Find.TickManager.TicksGame; + return $"Spawning in: {remainingTicks.ToStringTicksToPeriod()}"; + } + return base.CompInspectStringExtra(); + } + + public override void PostExposeData() + { + base.PostExposeData(); + Scribe_Values.Look(ref spawnUntilTick, "spawnUntilTick", -1); + Scribe_Defs.Look(ref spawningPawnKind, "spawningPawnKind"); + } + } +} \ No newline at end of file