127 lines
3.6 KiB
C#
127 lines
3.6 KiB
C#
using Verse;
|
|
|
|
namespace BlaxCastes
|
|
{
|
|
/// <summary>
|
|
/// A pawn's place in the caste system. Caste null means "casteless by choice": the player (or a
|
|
/// deleted caste) took the pawn out, and later safety nets leave it alone. A pawn with no record at
|
|
/// all never had a caste.
|
|
/// </summary>
|
|
public class CasteMembership : IExposable
|
|
{
|
|
public Caste caste;
|
|
/// <summary>True when a join row set it, false when the player did.</summary>
|
|
public bool auto;
|
|
public string reason;
|
|
public int tick;
|
|
|
|
public CasteMembership()
|
|
{
|
|
}
|
|
|
|
public CasteMembership(Caste caste, bool auto, string reason, int tick)
|
|
{
|
|
this.caste = caste;
|
|
this.auto = auto;
|
|
this.reason = reason;
|
|
this.tick = tick;
|
|
}
|
|
|
|
public bool Casteless => caste == null;
|
|
|
|
public void ExposeData()
|
|
{
|
|
Scribe_References.Look(ref caste, "caste");
|
|
Scribe_Values.Look(ref auto, "auto");
|
|
Scribe_Values.Look(ref reason, "reason");
|
|
Scribe_Values.Look(ref tick, "tick");
|
|
}
|
|
}
|
|
|
|
public enum JoinRowMode
|
|
{
|
|
NoCaste,
|
|
DefaultCaste,
|
|
SpecificCaste,
|
|
}
|
|
|
|
/// <summary>What a way of joining does: no caste, the default caste, or one specific caste.</summary>
|
|
public class JoinRow : IExposable
|
|
{
|
|
public string reason;
|
|
public JoinRowMode mode = JoinRowMode.NoCaste;
|
|
/// <summary>Only used with SpecificCaste.</summary>
|
|
public Caste caste;
|
|
|
|
public JoinRow()
|
|
{
|
|
}
|
|
|
|
public JoinRow(string reason)
|
|
{
|
|
this.reason = reason;
|
|
}
|
|
|
|
public void ExposeData()
|
|
{
|
|
Scribe_Values.Look(ref reason, "reason");
|
|
Scribe_Values.Look(ref mode, "mode", JoinRowMode.NoCaste);
|
|
Scribe_References.Look(ref caste, "caste");
|
|
}
|
|
}
|
|
|
|
/// <summary>A join waiting for the next tick. Filled and applied by JoinDefaults.</summary>
|
|
public class QueuedJoin : IExposable
|
|
{
|
|
public Pawn pawn;
|
|
public string reason;
|
|
public int tick;
|
|
|
|
public QueuedJoin()
|
|
{
|
|
}
|
|
|
|
public QueuedJoin(Pawn pawn, string reason, int tick)
|
|
{
|
|
this.pawn = pawn;
|
|
this.reason = reason;
|
|
this.tick = tick;
|
|
}
|
|
|
|
public void ExposeData()
|
|
{
|
|
Scribe_References.Look(ref pawn, "pawn");
|
|
Scribe_Values.Look(ref reason, "reason");
|
|
Scribe_Values.Look(ref tick, "tick");
|
|
}
|
|
}
|
|
|
|
/// <summary>Reason strings stored in memberships, join rows and the join queue.</summary>
|
|
public static class JoinReason
|
|
{
|
|
// The five join rows in 1.0.
|
|
public const string BoughtSlave = "boughtSlave";
|
|
public const string BoughtColonist = "boughtColonist";
|
|
public const string NewColonist = "newColonist";
|
|
public const string NewSlave = "newSlave";
|
|
public const string NewPrisoner = "newPrisoner";
|
|
|
|
// Reasons that are not join rows.
|
|
public const string Manual = "manual";
|
|
public const string CasteDeleted = "casteDeleted";
|
|
|
|
/// <summary>The join rows in display order.</summary>
|
|
public static readonly string[] Rows = { BoughtSlave, BoughtColonist, NewColonist, NewSlave, NewPrisoner };
|
|
|
|
public static bool IsRow(string reason)
|
|
{
|
|
for (int i = 0; i < Rows.Length; i++)
|
|
{
|
|
if (Rows[i] == reason)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|