mirror of
https://github.com/FalloutCollaborationProject/FCP-Tools.git
synced 2026-07-27 16:59:37 -07:00
Reorganize and add core features: move many source files into Source/FCPTools/FalloutCore and remove obsolete project/assembly binaries under 1.6/Assemblies. Introduce pre-war computer terminals (wall & table): ThingDefs, textures, language key, CompProperties_Terminal/CompTerminal, hacking components, and a new mapgen GenStep_WallTerminals. Add crucifixion mechanics: HediffDefs (FCP_Crucified, FCP_CrucifixionExhaustion, FCP_WasCrucified) and related JobDefs (strap/remove from power line). Add many new source modules (power line/terminal buildings, power armor jobs, homing projectiles, gauntlet spawners, gooification, shotgunz, spawn-on-ingest, ignore-config-errors, weapon requirements, etc.) and numerous Harmony patches. Misc: update damage workerClass namespaces to FCP.Core, change some production building draw sizes, make research techprints require specific benches, and rename/move many files while deleting legacy files and assemblies.
133 lines
3.5 KiB
C#
133 lines
3.5 KiB
C#
using RimWorld;
|
|
using Verse;
|
|
|
|
namespace FCP.Core.Buildings;
|
|
|
|
public class Building_PowerLine : Building
|
|
{
|
|
private Pawn containedPawn;
|
|
private Corpse containedCorpse;
|
|
private Faction storedHostFaction;
|
|
private GuestStatus? storedGuestStatus;
|
|
|
|
public Pawn ContainedPawn => containedPawn;
|
|
public Corpse ContainedCorpse => containedCorpse;
|
|
|
|
public bool HasPawn
|
|
{
|
|
get
|
|
{
|
|
if (containedPawn != null && !containedPawn.Destroyed)
|
|
{
|
|
if (containedPawn.Dead)
|
|
{
|
|
ConvertToCorpse(containedPawn.Corpse);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool HasCorpse => containedCorpse != null && !containedCorpse.Destroyed;
|
|
|
|
private void ConvertToCorpse(Corpse corpse)
|
|
{
|
|
containedCorpse = corpse;
|
|
containedPawn = null;
|
|
storedHostFaction = null;
|
|
storedGuestStatus = null;
|
|
corpse.Rotation = Rotation.Opposite;
|
|
}
|
|
|
|
public override void ExposeData()
|
|
{
|
|
base.ExposeData();
|
|
Scribe_References.Look(ref containedPawn, "containedPawn");
|
|
Scribe_References.Look(ref containedCorpse, "containedCorpse");
|
|
Scribe_References.Look(ref storedHostFaction, "storedHostFaction");
|
|
Scribe_Values.Look(ref storedGuestStatus, "storedGuestStatus");
|
|
}
|
|
|
|
public bool TryAcceptPawn(Pawn p)
|
|
{
|
|
if (HasPawn || HasCorpse || p == null)
|
|
return false;
|
|
containedPawn = p;
|
|
if (p.guest != null && !p.Dead)
|
|
{
|
|
storedHostFaction = p.HostFaction;
|
|
storedGuestStatus = p.guest.GuestStatus;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool TryAcceptCorpse(Corpse corpse)
|
|
{
|
|
if (HasPawn || HasCorpse || corpse == null)
|
|
return false;
|
|
containedCorpse = corpse;
|
|
return true;
|
|
}
|
|
|
|
public Pawn EjectContents()
|
|
{
|
|
if (!HasPawn)
|
|
return null;
|
|
Pawn p = containedPawn;
|
|
containedPawn = null;
|
|
if (p.guest != null && !p.Dead && storedGuestStatus != null)
|
|
p.guest.SetGuestStatus(storedHostFaction, storedGuestStatus.Value);
|
|
storedHostFaction = null;
|
|
storedGuestStatus = null;
|
|
return p;
|
|
}
|
|
|
|
public Corpse EjectCorpse()
|
|
{
|
|
if (!HasCorpse)
|
|
return null;
|
|
Corpse c = containedCorpse;
|
|
containedCorpse = null;
|
|
return c;
|
|
}
|
|
|
|
public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
|
|
{
|
|
if (HasPawn)
|
|
{
|
|
Pawn p = EjectContents();
|
|
if (!p.Spawned)
|
|
GenSpawn.Spawn(p, Position, Map);
|
|
if (!p.Dead)
|
|
p.health.AddHediff(HediffDefOf.FCP_WasCrucified);
|
|
}
|
|
if (HasCorpse)
|
|
{
|
|
Corpse c = EjectCorpse();
|
|
if (c != null && !c.Spawned)
|
|
GenSpawn.Spawn(c, Position, Map);
|
|
}
|
|
base.Destroy(mode);
|
|
}
|
|
|
|
public override string GetInspectString()
|
|
{
|
|
string text = base.GetInspectString();
|
|
if (HasPawn)
|
|
{
|
|
if (!text.NullOrEmpty())
|
|
text += "\n";
|
|
text += "FCP_ContainedPawn".Translate(containedPawn.LabelShort);
|
|
}
|
|
else if (HasCorpse)
|
|
{
|
|
if (!text.NullOrEmpty())
|
|
text += "\n";
|
|
text += "FCP_ContainedCorpse".Translate(containedCorpse.InnerPawn.LabelShort);
|
|
}
|
|
return text;
|
|
}
|
|
}
|