WeaponRecord record
public sealed record WeaponRecord A weapon record: how a weapon shows on the wheel, what it looks and sounds like, and which behaviour makes it do something. The TOML format is in Making weapons and the weapon wheel. Garry’s Mod’s adapter writes its weapons’ records from the game’s own files, so they read the same way.
A behaviour gets the record resolved down its bases, from IWeaponHolder.Record and from the factory it gave IWeapons.RegisterBehaviour. Every property but Id is null or empty when the record leaves its key out, so read each with a fallback:
sealed class Slugger(WeaponRecord record) : IWeaponBehaviour
{
readonly double damage = record.Damage ?? 10;
readonly ContentId? swing = record.Sound("miss");
readonly WeaponWorldModel? held = record.WorldModelIn(0);
}
- Assembly
- EvilEngine.Formats
- Commit
- 4ff877b1