267 lines
9.3 KiB
Plaintext
267 lines
9.3 KiB
Plaintext
根据向量相似度分析,与 'CryptosleepCasket' 最相关的代码定义如下:
|
|
|
|
---
|
|
**文件路径:** `C:\Steam\steamapps\common\RimWorld\Data\dll1.6\RimWorld\RoomContents_CryptosleepCasket.txt`
|
|
**相似度:** 0.7176
|
|
|
|
```csharp
|
|
public class RoomContents_CryptosleepCasket : RoomContentsWorker
|
|
{
|
|
private const string OpenedSignal = "OpenedSignal";
|
|
|
|
public override void FillRoom(Map map, LayoutRoom room, Faction faction, float? threatPoints = null)
|
|
{
|
|
if (!room.TryGetRandomCellInRoom(map, out var cell, 3))
|
|
{
|
|
cell = room.rects[0].CenterCell;
|
|
}
|
|
int nextAncientCryptosleepCasketGroupID = Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID();
|
|
PodContentsType type = Gen.RandomEnumValue<PodContentsType>(disallowFirstValue: true);
|
|
Building_AncientCryptosleepCasket pod = RoomGenUtility.SpawnCryptoCasket(cell, map, Rot4.Random, nextAncientCryptosleepCasketGroupID, type, ThingSetMakerDefOf.MapGen_ScarlandsAncientPodContents);
|
|
ThreatSignal = "OpenedSignal" + Find.UniqueIDsManager.GetNextSignalTagID();
|
|
RoomGenUtility.SpawnOpenCryptoCasketSignal(pod, map, ThreatSignal);
|
|
base.FillRoom(map, room, faction, threatPoints);
|
|
}
|
|
}
|
|
```
|
|
---
|
|
**文件路径:** `C:\Steam\steamapps\common\RimWorld\Data\dll1.6\RimWorld\Building_AncientCryptosleepPod.txt`
|
|
**相似度:** 0.7115
|
|
|
|
```csharp
|
|
public class Building_AncientCryptosleepPod : Building_AncientCryptosleepCasket
|
|
{
|
|
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn)
|
|
{
|
|
return Enumerable.Empty<FloatMenuOption>();
|
|
}
|
|
}
|
|
```
|
|
---
|
|
**文件路径:** `C:\Steam\steamapps\common\RimWorld\Data\dll1.6\RimWorld\Building_AncientCryptosleepCasket.txt`
|
|
**相似度:** 0.7023
|
|
|
|
```csharp
|
|
public class Building_AncientCryptosleepCasket : Building_CryptosleepCasket
|
|
{
|
|
public int groupID = -1;
|
|
|
|
public override void ExposeData()
|
|
{
|
|
base.ExposeData();
|
|
Scribe_Values.Look(ref groupID, "groupID", 0);
|
|
}
|
|
|
|
public override void PreApplyDamage(ref DamageInfo dinfo, out bool absorbed)
|
|
{
|
|
base.PreApplyDamage(ref dinfo, out absorbed);
|
|
if (absorbed)
|
|
{
|
|
return;
|
|
}
|
|
if (!contentsKnown && innerContainer.Count > 0 && dinfo.Def.harmsHealth && dinfo.Instigator != null && dinfo.Instigator.Faction != null)
|
|
{
|
|
bool flag = false;
|
|
foreach (Thing item in (IEnumerable<Thing>)innerContainer)
|
|
{
|
|
if (item is Pawn)
|
|
{
|
|
flag = true;
|
|
break;
|
|
}
|
|
}
|
|
if (flag)
|
|
{
|
|
EjectContents();
|
|
}
|
|
}
|
|
absorbed = false;
|
|
}
|
|
|
|
public override void EjectContents()
|
|
{
|
|
bool num = contentsKnown;
|
|
List<Thing> list = null;
|
|
if (!num)
|
|
{
|
|
list = new List<Thing>();
|
|
list.AddRange(innerContainer);
|
|
list.AddRange(UnopenedCasketsInGroup().SelectMany((Building_AncientCryptosleepCasket c) => c.innerContainer));
|
|
list.RemoveDuplicates();
|
|
}
|
|
base.EjectContents();
|
|
if ((bool)ClaimableBy(Faction.OfPlayer))
|
|
{
|
|
SetFaction(null);
|
|
}
|
|
if (num)
|
|
{
|
|
return;
|
|
}
|
|
ThingDef filth_Slime = ThingDefOf.Filth_Slime;
|
|
FilthMaker.TryMakeFilth(base.Position, base.Map, filth_Slime, Rand.Range(8, 12));
|
|
foreach (Building_AncientCryptosleepCasket item in UnopenedCasketsInGroup())
|
|
{
|
|
item.contentsKnown = true;
|
|
item.EjectContents();
|
|
}
|
|
IEnumerable<Pawn> enumerable = from p in list.OfType<Pawn>().ToList()
|
|
where p.RaceProps.Humanlike && p.GetLord() == null && p.Faction == Faction.OfAncientsHostile
|
|
select p;
|
|
if (enumerable.Any())
|
|
{
|
|
LordMaker.MakeNewLord(Faction.OfAncientsHostile, new LordJob_AssaultColony(Faction.OfAncientsHostile, canKidnap: false, canTimeoutOrFlee: true, sappers: false, useAvoidGridSmart: false, canSteal: false), base.Map, enumerable);
|
|
}
|
|
}
|
|
|
|
private IEnumerable<Building_AncientCryptosleepCasket> UnopenedCasketsInGroup()
|
|
{
|
|
yield return this;
|
|
if (groupID == -1)
|
|
{
|
|
yield break;
|
|
}
|
|
foreach (Thing item in base.Map.listerThings.ThingsOfDef(ThingDefOf.AncientCryptosleepCasket))
|
|
{
|
|
Building_AncientCryptosleepCasket building_AncientCryptosleepCasket = item as Building_AncientCryptosleepCasket;
|
|
if (building_AncientCryptosleepCasket.groupID == groupID && !building_AncientCryptosleepCasket.contentsKnown)
|
|
{
|
|
yield return building_AncientCryptosleepCasket;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
---
|
|
**文件路径:** `C:\Steam\steamapps\common\RimWorld\Data\dll1.6\RimWorld\ComplexThreatWorker_CryptosleepPods.txt`
|
|
**相似度:** 0.6424
|
|
|
|
```csharp
|
|
public class ComplexThreatWorker_CryptosleepPods : ComplexThreatWorker
|
|
{
|
|
private const string TriggerOpenAction = "TriggerOpenAction";
|
|
|
|
private const string CompletedOpenAction = "CompletedOpenAction";
|
|
|
|
private const float RoomEntryTriggerChance = 0.25f;
|
|
|
|
protected override bool CanResolveInt(ComplexResolveParams parms)
|
|
{
|
|
if (base.CanResolveInt(parms) && ComplexUtility.TryFindRandomSpawnCell(ThingDefOf.AncientCryptosleepPod, parms.room, parms.map, out var _) && parms.points >= PawnKindDefOf.AncientSoldier.combatPower)
|
|
{
|
|
if (parms.hostileFaction != null)
|
|
{
|
|
return parms.hostileFaction == Faction.OfAncientsHostile;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected override void ResolveInt(ComplexResolveParams parms, ref float threatPointsUsed, List<Thing> outSpawnedThings)
|
|
{
|
|
List<Thing> list = SpawnCasketsWithHostiles(parms.room, parms.points, parms.triggerSignal, parms.map);
|
|
SignalAction_OpenCasket signalAction_OpenCasket = (SignalAction_OpenCasket)ThingMaker.MakeThing(ThingDefOf.SignalAction_OpenCasket);
|
|
signalAction_OpenCasket.signalTag = parms.triggerSignal;
|
|
signalAction_OpenCasket.caskets.AddRange(list);
|
|
signalAction_OpenCasket.completedSignalTag = "CompletedOpenAction" + Find.UniqueIDsManager.GetNextSignalTagID();
|
|
if (parms.delayTicks.HasValue)
|
|
{
|
|
signalAction_OpenCasket.delayTicks = parms.delayTicks.Value;
|
|
SignalAction_Message obj = (SignalAction_Message)ThingMaker.MakeThing(ThingDefOf.SignalAction_Message);
|
|
obj.signalTag = parms.triggerSignal;
|
|
obj.lookTargets = list;
|
|
obj.messageType = MessageTypeDefOf.ThreatBig;
|
|
obj.message = "MessageSleepingThreatDelayActivated".Translate(Faction.OfAncientsHostile, signalAction_OpenCasket.delayTicks.ToStringTicksToPeriod());
|
|
GenSpawn.Spawn(obj, parms.room.rects[0].CenterCell, parms.map);
|
|
}
|
|
GenSpawn.Spawn(signalAction_OpenCasket, parms.map.Center, parms.map);
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
if (!(list[i] is Building_Casket building_Casket))
|
|
{
|
|
continue;
|
|
}
|
|
foreach (Thing item in (IEnumerable<Thing>)building_Casket.GetDirectlyHeldThings())
|
|
{
|
|
if (item is Pawn pawn)
|
|
{
|
|
threatPointsUsed += pawn.kindDef.combatPower;
|
|
}
|
|
}
|
|
}
|
|
SignalAction_Message obj2 = (SignalAction_Message)ThingMaker.MakeThing(ThingDefOf.SignalAction_Message);
|
|
obj2.signalTag = signalAction_OpenCasket.completedSignalTag;
|
|
obj2.lookTargets = list;
|
|
obj2.messageType = MessageTypeDefOf.ThreatBig;
|
|
obj2.message = "MessageSleepingPawnsWokenUp".Translate(Faction.OfAncientsHostile.def.pawnsPlural.CapitalizeFirst());
|
|
GenSpawn.Spawn(obj2, parms.room.rects[0].CenterCell, parms.map);
|
|
}
|
|
|
|
private List<Thing> SpawnCasketsWithHostiles(LayoutRoom room, float threatPoints, string openSignal, Map map)
|
|
{
|
|
int num = Mathf.FloorToInt(threatPoints / PawnKindDefOf.AncientSoldier.combatPower);
|
|
List<Thing> list = new List<Thing>();
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
if (!ComplexUtility.TryFindRandomSpawnCell(ThingDefOf.AncientCryptosleepPod, room, map, out var spawnPosition))
|
|
{
|
|
break;
|
|
}
|
|
Building_AncientCryptosleepPod building_AncientCryptosleepPod = (Building_AncientCryptosleepPod)GenSpawn.Spawn(ThingDefOf.AncientCryptosleepPod, spawnPosition, map);
|
|
building_AncientCryptosleepPod.groupID = Find.UniqueIDsManager.GetNextAncientCryptosleepCasketGroupID();
|
|
building_AncientCryptosleepPod.openedSignal = openSignal;
|
|
ThingSetMakerParams parms = default(ThingSetMakerParams);
|
|
parms.podContentsType = PodContentsType.AncientHostile;
|
|
List<Thing> list2 = ThingSetMakerDefOf.MapGen_AncientPodContents.root.Generate(parms);
|
|
for (int j = 0; j < list2.Count; j++)
|
|
{
|
|
Pawn pawn = list2[j] as Pawn;
|
|
if (!building_AncientCryptosleepPod.TryAcceptThing(list2[j], allowSpecialEffects: false))
|
|
{
|
|
if (pawn != null)
|
|
{
|
|
Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
|
|
}
|
|
else
|
|
{
|
|
list2[i].Destroy();
|
|
}
|
|
}
|
|
}
|
|
list.Add(building_AncientCryptosleepPod);
|
|
}
|
|
return list;
|
|
}
|
|
}
|
|
```
|
|
---
|
|
**文件路径:** `C:\Steam\steamapps\common\RimWorld\Data\Core\Defs\ThingDefs_Buildings\Buildings_Ancient_Active.xml`
|
|
**相似度:** 0.6040
|
|
|
|
```xml
|
|
<ThingDef ParentName="AncientCryptosleepCasket">
|
|
<defName>AncientCryptosleepPod</defName>
|
|
<label>ancient cryptosleep pod</label>
|
|
<thingClass>Building_AncientCryptosleepPod</thingClass>
|
|
<containedPawnsSelectable>true</containedPawnsSelectable>
|
|
<description>A single-use pod for preserving one person in a state of suspended animation. Unlike cryptosleep caskets, cryptosleep pods can only be used once.</description>
|
|
<graphicData>
|
|
<texPath>Things/Building/Ruins/AncientCryptosleepPod</texPath>
|
|
<graphicClass>Graphic_Multi</graphicClass>
|
|
</graphicData>
|
|
<building>
|
|
<deconstructible>false</deconstructible>
|
|
<claimable>false</claimable>
|
|
</building>
|
|
<researchPrerequisites Inherit="False" />
|
|
<hasInteractionCell>false</hasInteractionCell>
|
|
<statBases>
|
|
<WorkToBuild>2000</WorkToBuild>
|
|
<MaxHitPoints>200</MaxHitPoints>
|
|
</statBases>
|
|
<designationCategory Inherit="False" />
|
|
<costList Inherit="False" />
|
|
<comps Inherit="False" />
|
|
</ThingDef>
|
|
``` |