Scripting API

Scripting API

FieldValue

Struct in Abyss.Core, from Abyss.Core.

One value of a component's field: a number, or a whole number held exactly in 64 bits.

public readonly struct FieldValue

Remarks

A double holds every number a field holds but not every whole one. Past 2^53 a double skips integers, so a 64-bit counter, a hash or a time in ticks read into one and written back comes back as its nearest neighbor that a double can hold — in a scene file, in the inspector and on a load alike, silently. So a whole number is kept as the 64 bits it is, signed or not, and a fractional one as the double it is, and each is written into a field of any kind as itself.

FieldValue.Number is the value as a double for whatever only shows or compares numbers, and a double converts to a value implicitly, so what writes fractions writes them as before.

Properties

IsWhole

public bool IsWhole { get; }

Whether this is a whole number held exactly, rather than a double.

Number

public double Number { get; }

The value as a double: itself for a fraction, and for a whole number the nearest double, which past 2^53 is not always the number.

Methods

Of

public static FieldValue Of(double number)

A fractional value, or a whole one carried as a double.

Parameters

  • number

Whole

public static FieldValue Whole(long whole)

A whole number, exactly.

Parameters

  • whole

Whole

public static FieldValue Whole(ulong whole)

A whole number with no sign, exactly.

Parameters

  • whole

ToInt64

public long ToInt64(long least = -9223372036854775808, long most = 9223372036854775807)

The value as a whole number within least and most: exactly, where it is whole, and rounded toward zero from the double where it is not, as a field of an integer kind has always stored a fraction. Clamped, not wrapped.

Parameters

  • least
  • most

ToUInt64

public ulong ToUInt64(ulong most = 18446744073709551615)

The value as a whole number with no sign, at most most: exactly, where it is whole and not negative, and from the double where it is a fraction. Clamped, not wrapped.

Parameters

  • most

Equals

public bool Equals(FieldValue other)

Parameters

  • other

Equals

public override bool Equals(object? obj)

Parameters

  • obj

GetHashCode

public override int GetHashCode()

As a double, so a whole number and the double it equals hash alike.

ToString

public override string ToString()

The number as a file writes it: a whole one as its digits, a fraction as the shortest text that reads back as itself.

Operators

implicit operator FieldValue

public static implicit operator FieldValue(double number)

A double is a value, so what writes fractions writes them as it always did.

Parameters

  • number

explicit operator double

public static explicit operator double(FieldValue value)

The value as a double, which past 2^53 is not every whole number; see FieldValue.Number.

Parameters

  • value

operator ==

public static bool operator ==(FieldValue left, FieldValue right)

Two values are the same number: exactly, where both are whole, and as doubles where either is not.

Parameters

  • left
  • right

operator !=

public static bool operator !=(FieldValue left, FieldValue right)

Two values are different numbers.

Parameters

  • left
  • right