Table of Contents

Class PetAttackPriority

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

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

int

StepCount

How many steps an order has.

public const int StepCount = 3

Field Value

int

Methods

Describe(PetAttackTarget)

The player-facing name of a step.

public static string Describe(PetAttackTarget target)

Parameters

target PetAttackTarget

Returns

string

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

first PetAttackTarget
second PetAttackTarget
third PetAttackTarget

Returns

int

IsValid(int)

True when packed decodes to a permutation of the three steps.

public static bool IsValid(int packed)

Parameters

packed int

Returns

bool

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

packed int
slot int

Returns

int

Normalize(int)

The value itself when valid, else Default.

public static int Normalize(int packed)

Parameters

packed int

Returns

int

TryDecode(int, PetAttackTarget[])

Unpacks an order into order (first step at index 0).

public static bool TryDecode(int packed, PetAttackTarget[] order)

Parameters

packed int
order PetAttackTarget[]

Returns

bool

False when the value is not a permutation of the three steps.