Table of Contents

Class WildlifeRules

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

The rules wildlife lives by, outside the faction system. Every check that would otherwise ask a faction asks here first: the harm rule (MayHarm(ICharacter, ICharacter, out ICharacter)) and the AI's search for something to fight or flee.

public static class WildlifeRules
Inheritance
WildlifeRules
Inherited Members

Methods

Decides(WildlifeRole, WildlifeRole)

True when either side is wildlife, so MayHarm(WildlifeRole, int, WildlifeRole, int) decides.

public static bool Decides(WildlifeRole attacker, WildlifeRole defender)

Parameters

attacker WildlifeRole
defender WildlifeRole

Returns

bool

FleeHeading(Vector3, IReadOnlyList<Vector3>, Vector3)

The flat direction prey should run: away from every threat at once, each weighted by how close it is (1/d), so a deer between two wolves runs out sideways rather than from one into the other. Pure, so it is tested on its own.

public static Vector3 FleeHeading(Vector3 position, IReadOnlyList<Vector3> threats, Vector3 fallback)

Parameters

position Vector3

The prey's position.

threats IReadOnlyList<Vector3>

Where the threats stand.

fallback Vector3

Used when the threats cancel out or stand on top of it: the way it already faces, reversed by the caller as it likes.

Returns

Vector3

A unit vector on the ground plane.

MayHarm(WildlifeRole, int, WildlifeRole, int)

Whether harm between two characters, at least one of them wildlife, is allowed: always, except between members of one pack. Pure, so it is tested on its own.

public static bool MayHarm(WildlifeRole attacker, int attackerPack, WildlifeRole defender, int defenderPack)

Parameters

attacker WildlifeRole
attackerPack int
defender WildlifeRole
defenderPack int

Returns

bool

Notices(ICharacter, ICharacter, out bool)

Whether a wild animal's search should pick other: a predator what it may hunt, a territorial animal what it charges, prey what it flees from. decided is false when the searcher is not wildlife, and the faction rules answer instead. Pure, so it is tested on its own.

public static bool Notices(ICharacter searcher, ICharacter other, out bool decided)

Parameters

searcher ICharacter
other ICharacter
decided bool

Returns

bool

Remarks

A predator hunts everything but its pack. Prey runs from everything but other prey and territorial animals (a boar grazing beside deer does not scatter them). A territorial animal ignores prey and its own kind and charges anything else that comes inside its (short) detection radius.

Notices(WildlifeRole, int, WildlifeRole, int, out bool)

Whether a wild animal's search should pick other: a predator what it may hunt, a territorial animal what it charges, prey what it flees from. decided is false when the searcher is not wildlife, and the faction rules answer instead. Pure, so it is tested on its own.

public static bool Notices(WildlifeRole searcher, int searcherPack, WildlifeRole other, int otherPack, out bool decided)

Parameters

searcher WildlifeRole
searcherPack int
other WildlifeRole
otherPack int
decided bool

Returns

bool

Remarks

A predator hunts everything but its pack. Prey runs from everything but other prey and territorial animals (a boar grazing beside deer does not scatter them). A territorial animal ignores prey and its own kind and charges anything else that comes inside its (short) detection radius.

PackOf(ICharacter)

The character's pack (its spawner's group, server only); 0 for none.

public static int PackOf(ICharacter character)

Parameters

character ICharacter

Returns

int

RoleOf(ICharacter)

The character's wildlife role: None for anything that is not wildlife.

public static WildlifeRole RoleOf(ICharacter character)

Parameters

character ICharacter

Returns

WildlifeRole