Skip to content

FrameBox

namespace Griff.Modules.Fighting;
public struct FrameBox

One box (or circle) on one frame of an animation clip, as a Hitboxes holds them: a hitbox that deals Damage, Knockback and Stun, or a hurtbox that takes hits times its Multiplier. Its place and size are in the entity’s own units, facing right, as its picture is drawn.

public Vector2 Center { get; init; }

Where its middle is, from the entity’s middle, facing right.

public string Clip { get; init; }

The clip it’s on, e.g. “Punch”; OwnFrames for the animation’s own frames (or no animation).

public float Damage { get; init; }

A hitbox’s damage, before the hurtbox it lands on multiplies it.

public int Frame { get; init; }

Which of the clip’s frames, counting from 0.

public int Group { get; init; }

A hitbox’s group: a swing hits something once per group, however many of its frames touch it.

public bool IsCircle { get; }

True for a circle (it has a Radius); false for a box.

public bool IsHit { get; }
public FrameBoxKind Kind { get; init; }
public Vector2 Knockback { get; init; }

How fast a hitbox sends what it hits flying, in units a second: X away from it, Y up.

public float Multiplier { get; init; }

A hurtbox’s multiplier for the damage of hits it takes: 1.5 for a head that takes more.

public float Radius { get; init; }

A circle’s radius; 0 for a box.

public Vector2 Size { get; init; }

How wide and high a box is; for a circle, as wide and high as the circle.

public int Stun { get; init; }

How many steps of the game (frames, at 60 a second) a hitbox leaves what it hits in hitstun.

public FrameBox AsCircle(float radius)

The same box as a circle of radius.

public void Deconstruct(out string Clip, out int Frame, out FrameBoxKind Kind, out Vector2 Center, out Vector2 Size, out float Radius, out float Damage, out Vector2 Knockback, out int Stun, out int Group, out float Multiplier)
public override bool Equals(object obj)
public bool Equals(FrameBox other)
public static IReadOnlyList<string> FormatAll(IEnumerable<FrameBox> boxes)

Writes boxes as Boxes holds them, a line each.

public override int GetHashCode()
public static FrameBox Hitbox(string clip, int frame, Vector2 center, Vector2 size, float damage = 1f, Vector2 knockback = default, int stun = 0, int group = 1)

A new hitbox, size big.

public static FrameBox Hurtbox(string clip, int frame, Vector2 center, Vector2 size, float multiplier = 1f)

A new hurtbox, size big.

public static string Number(float value)

A number as lines write it: up to three decimals, with a point whatever the language.

public static IReadOnlyList<FrameBox> ParseAll(IEnumerable<string>? lines)

Reads lines written like ToString, skipping those that don’t make sense.

public override string ToString()

The line Boxes holds it as, e.g. Punch 2 hit at 0.6,0.3 size 0.5x0.25 damage 3 knockback 4,2 stun 12 or Idle 0 hurt at 0,0.7 radius 0.3 multiplier 1.5: what TryParse reads back. Values left as they are by default (damage 1, group 1, multiplier 1, no knockback or stun) are left out.

public static bool TryParse(string? line, out FrameBox box, out string? problem)

Reads a line written like ToString: the clip, the frame, hit or hurt, then at X,Y and size WxH (or radius R), and for a hitbox any of damage, knockback X,Y, stun and group, for a hurtbox multiplier. False (with why in problem) for a line that doesn’t make sense.

public const string OwnFrames

What a line calls the animation’s own frames, played without a clip (and an entity with no animation’s one frame).