Class PetAttackPriority
The order a pet attack command tries its three ways of choosing a victim, packed into one int so it can ride a broadcast and a settings file.
public static class PetAttackPriority
- Inheritance
-
PetAttackPriority
- Inherited Members
Remarks
Three steps, each used exactly once, tried first to last until one resolves a valid target. The shipped default is pinned, then current, then highest threat — what a player most plausibly means by "attack my target" — and the panel lets a player reorder it.
Layout: bit 0 is a set marker so that 0, the value an old client or an unset field carries, is never a valid order and decodes to the default instead; bits 2-3, 4-5 and 6-7 hold the first, second and third step. Pure, so both peers and the tests agree on it.
Fields
Default
Pinned, then current, then highest threat.
public static readonly int Default
Field Value
StepCount
How many steps an order has.
public const int StepCount = 3
Field Value
Methods
Describe(PetAttackTarget)
The player-facing name of a step.
public static string Describe(PetAttackTarget target)
Parameters
targetPetAttackTarget
Returns
Encode(PetAttackTarget, PetAttackTarget, PetAttackTarget)
Packs an order. The caller is trusted to pass a permutation; see IsValid(int).
public static int Encode(PetAttackTarget first, PetAttackTarget second, PetAttackTarget third)
Parameters
firstPetAttackTargetsecondPetAttackTargetthirdPetAttackTarget
Returns
IsValid(int)
True when packed decodes to a permutation of the three steps.
public static bool IsValid(int packed)
Parameters
packedint
Returns
MoveUp(int, int)
Swaps the step at slot with the one before it, so it is tried one
place earlier. Slot 0 and an invalid slot leave the order as it is.
public static int MoveUp(int packed, int slot)
Parameters
Returns
Normalize(int)
The value itself when valid, else Default.
public static int Normalize(int packed)
Parameters
packedint
Returns
TryDecode(int, PetAttackTarget[])
Unpacks an order into order (first step at index 0).
public static bool TryDecode(int packed, PetAttackTarget[] order)
Parameters
packedintorderPetAttackTarget[]
Returns
- bool
False when the value is not a permutation of the three steps.