Modding Tutorials/Docs/Pawn PsychicEntropyTracker

From RimWorld Wiki
Jump to navigation Jump to search

1.5

also check out solutions

API[edit]

public class Pawn_PsychicEntropyTracker : IExposable
Implementation for a pawn's psycast values

Constructor[edit]

public Pawn_PsychicEntropyTracker(Pawn pawn);

Pawn[edit]

public readonly Pawn Pawn;
A reference to the pawn this Psycast Tracker is attached to.

public readonly Hediff_Psylink Psylink;
A reference to the psylink hediff of the pawn.

public readonly bool IsCurrentlyMeditating;
Checks if the pawn is meditating using the Tick Manager.

public readonly bool NeedsPsyfocus;
Not to be confused with CurrentPsyfocus = 1.0f, NeedsPsyfocus is true IFF the pawn is able to acquire psyfocus.

Psyfocus Gain[edit]

public readonly float CurrentPsyfocus;
Gets the current amount of Psyfocus the pawn has.


public readonly float TargetPsyfocus;
The JobGiver will only consider giving the meditation job to the pawn if CurrentPsyfocus is below this value.


public void SetPsyfocusTarget(float val);
Sets targetPsyfocus to val.


public void GainPsyfocus(focus = null);
Gains Psyfocus equivalent to 1 ticks worth of meditation.


public void OffsetPsyfocusDirectly(float offset);
Directly modifies currentPsyfocus by offset. Offset can be negative. Clamps to a value [0.0f, 1.0f].


public void RechargePsyfocus();
Sets currentPsyfocus to 1.0f.

public readonly float RecoveryRate;
Gets the RecoveryRate stat of the pawn. The same as using GetStatValue().

Psychic Heat[edit]

public readonly float EntropyValue;
Gets the pawns current nerual heat value.

public readonly float EntropyRelativeValue;
Gets the pawns current nerual heat as a percentage of their max.

public readonly float MaxEntropy;
Gets the maximum neural heat stat.

public readonly float MaxPotentialEntropy;
Gets the maximum neural heat before any adjustments. (Needs Expansion and verification)


public bool TryAddEntropy(float value, Thing source = null, bool scale = true, bool overLimit = false);
Attempts to add value neural heat. Returns true if neural heat was succefully added.
Note that value is pre-scaling, before the PsychicEntropyGain stat is applied. Set scale to false to prevent scaling.


public void RemoveAllEntropy();
Sets neural heat to 0.

public bool WouldOverflowEntropy;
Whether or not to prevent neural heat increases that will overflow neural heat.


public bool WouldOverflowEntropy(float value);
Returns true if it is invalid to add value neural heat. If limitEntropyAmount is false, all checks are disregarded and this always returns false. Used to check if an ability can be cast with the current neural heat.

public readonly PsychicEntropySeverity Severity;
Gets the pawns overflow severity.


public float EntropyToRelativeValue(float val);
A helper function to convert a numerical amount of neural heat to a percentage amount. Percentages are in 1.0f scale, and can overflow.

Psychic Sensitivity[edit]

public readonly float PsychicSensitivity;
Gets the pawns Psychic Sensitivity. It is reccomended to use this over the StatDef if you are purely working with sensitivity as a multiplier, as this value is cached.

public readonly bool IsPsychicallySensitive;
Returns whether or not the pawn is able to be affected psychically.

Psyfocus Level[edit]

Not to be confused with the Psycast Hediff Level, this refers to the degredation band. To work with the Psycast Levels, go check out Hediff_Psylink.


public get int PsyfocusBand();
Gets the current Psyfocus Band. See Constants for values.

System[edit]

public void SetInitialPsyfocusLevel();
Sets the psyfocus level to an initial amount. For colonists, this value is 0.75f. For any other pawn, this is a random value 0.5f - 0.7f


public void PsychicEntropyTrackerTick();
The update function. You most likely wont be using or modifying this function.


public override void ExposeData();
See IExposable.

Static Properties[edit]

public const float PercentageAfterGainingPsylink;
The amount of psyfocus a pawn gains upon acquiring a psyfocus (needs verification). Set to 0.75f, or 75%.

public const int PsyfocusUpdateInterval = 150;


public const float PsyfocusCostTolerance = 0.0005f;


public const float PercentageAfterGainingPsylink = 0.75f;


public static Dictionary<PsychicEntropySeverity, SoundDef> EntropyThresholdSounds;


public static readonly Dictionary<PsychicEntropySeverity, float> EntropyThresholds;
A dictionary containing constants for a pawn's neural heat limits


public static void ResetStaticData();
Resets EntropyThresholdSounds. (Requires Verification)

Psyfocus Bands[edit]

public static readonly List<float> PsyfocusBandPercentages = [0.00f, 0.25f, 0.50f, 1.00f];
The values corresponding to each band. Note that PsyfocusBand = 0 for all psyfocus levels between [0, 1], =1 between [1, 2] and =2 between [2, 3].

public static readonly List<float> FallRatePerPsyfocusBand = [0.035f, 0.055f, 0.075f];

The amount of psyfocus lost per day, corresponding to each band.

public static readonly List<float> FallRatePerPsyfocusBand = [2, 4, 6];

The maximum castable ability level corresponding to each band.

Tooltips[edit]

public string PsyfocusTipString(float psyfocusTargetOverride = -1f)
Returns the tooltip display string, translated and colorized.

Psyfocus: XX%
("DesiredPsyfocus".Translate()): XX%
...
(needs expansion)


public bool NeedToShowGizmo();

public Gizmo GetGizmo();

Listeners[edit]

public void Notify_Meditated()

public void Notify_GainedPsylink()

public void Notify_PawnDied()