Documentation
¶
Index ¶
- func Encode(w io.Writer, c *Character) error
- func EncodeBytes(c *Character) ([]byte, error)
- func PlayerStatIndexByName(name string) (int, bool)
- func PlayerStatNames() []string
- func SkillNames() []string
- func SkillTypeByName(name string) (int32, bool)
- type Character
- func (c *Character) AddInventoryItem(item Item)
- func (c *Character) CreditCraftedItem(item Item) Item
- func (c *Character) PlaceInventoryItem(item Item) error
- func (c *Character) PutInventoryItem(item Item, replace bool) error
- func (c *Character) RemoveInventoryItem(name string) error
- func (c *Character) SetPlayerStat(index int, name string, value float32) error
- func (c *Character) SetSkill(skillType int32, level float32)
- func (c *Character) UpsertCustomData(key string, value string)
- func (c *Character) UpsertEnemyStat(name string, value float32)
- func (c *Character) UpsertMaterialStat(name string, value float32)
- func (c *Character) Validate() error
- type Food
- type GuardianPower
- type Item
- type ItemCatalog
- type ItemMetadata
- type MapSection
- type PlayerData
- type Skill
- type StatEntry
- type Station
- type TextEntry
- type TimedEntry
- type Trailer
- type Vector3
- type WorldKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeBytes ¶
func PlayerStatIndexByName ¶
func PlayerStatNames ¶
func PlayerStatNames() []string
PlayerStatNames returns known player stat names in saved stat order.
func SkillNames ¶
func SkillNames() []string
SkillNames returns known skill names sorted alphabetically.
func SkillTypeByName ¶
Types ¶
type Character ¶
type Character struct {
FileLength uint32 `json:"fileLength"`
Version uint32 `json:"version"`
PlayerStatCount uint32 `json:"playerStatCount"`
PlayerStats []StatEntry `json:"playerStats,omitempty"`
Map MapSection `json:"map"`
Player PlayerData `json:"player"`
Trailer Trailer `json:"trailer"`
RemainingBytes int `json:"remainingBytes"`
}
func DecodeBytes ¶
func (*Character) AddInventoryItem ¶
AddInventoryItem appends item to the character inventory.
func (*Character) CreditCraftedItem ¶
CreditCraftedItem credits character as crafter when item is a recipe output and does not already have explicit crafter metadata.
func (*Character) PlaceInventoryItem ¶
PlaceInventoryItem adds item to the first empty normal inventory slot.
func (*Character) PutInventoryItem ¶
PutInventoryItem adds item unless its grid slot is occupied. When replace is true, the item at the same grid slot is overwritten.
func (*Character) RemoveInventoryItem ¶
RemoveInventoryItem removes the first inventory item with an exact name match.
func (*Character) SetPlayerStat ¶
SetPlayerStat sets a player stat by index and keeps PlayerStatCount synchronized.
func (*Character) UpsertCustomData ¶
UpsertCustomData updates player custom data by key or appends it.
func (*Character) UpsertEnemyStat ¶
UpsertEnemyStat updates an enemy stat by case-insensitive name or appends it.
func (*Character) UpsertMaterialStat ¶
UpsertMaterialStat updates a material stat by case-insensitive name or appends it.
type GuardianPower ¶
type Item ¶
type Item struct {
Name string `json:"name"`
Stack int32 `json:"stack"`
Durability float32 `json:"durability"`
GridX int32 `json:"gridX"`
GridY int32 `json:"gridY"`
Equipped bool `json:"equipped"`
Quality int32 `json:"quality"`
Variant int32 `json:"variant"`
CrafterID uint64 `json:"crafterId"`
CrafterName string `json:"crafterName"`
CustomData []TextEntry `json:"customData,omitempty"`
WorldLevel uint32 `json:"worldLevel"`
PickedUp bool `json:"pickedUp"`
}
type ItemCatalog ¶
type ItemCatalog struct {
// contains filtered or unexported fields
}
ItemCatalog holds Valheim ObjectDB item prefab metadata.
func (*ItemCatalog) List ¶
func (c *ItemCatalog) List() []ItemMetadata
List returns all known Valheim item prefab metadata sorted by name.
func (*ItemCatalog) Lookup ¶
func (c *ItemCatalog) Lookup(name string) (ItemMetadata, bool)
Lookup returns metadata for a Valheim item prefab name.
func (*ItemCatalog) Names ¶
func (c *ItemCatalog) Names() []string
Names returns all known Valheim item prefab names sorted by name.
type ItemMetadata ¶
type ItemMetadata struct {
Name string `json:"name"`
InventoryValid bool `json:"inventoryValid"`
Recipes []string `json:"recipes,omitempty"`
BaseDurability float32 `json:"baseDurability"`
DurabilityStep float32 `json:"durabilityStep"`
MaxQuality int32 `json:"maxQuality"`
MaxStack int32 `json:"maxStack"`
}
ItemMetadata describes a Valheim ObjectDB item prefab that can be written to inventory records.
func (ItemMetadata) Durability ¶
func (m ItemMetadata) Durability(quality int32) float32
Durability returns the default full durability for the requested quality.
type MapSection ¶
type PlayerData ¶
type PlayerData struct {
Name string `json:"name"`
PlayerID uint64 `json:"playerId"`
StartSeed string `json:"startSeed"`
UsedCheats bool `json:"usedCheats"`
DateCreatedUnix int64 `json:"dateCreatedUnix"`
KnownWorlds []TimedEntry `json:"knownWorlds,omitempty"`
KnownWorldKeys []WorldKey `json:"knownWorldKeys,omitempty"`
KnownCommands []StatEntry `json:"-"`
EnemyStats []StatEntry `json:"enemyStats,omitempty"`
MaterialStats []StatEntry `json:"materialStats,omitempty"`
RecipeStats []StatEntry `json:"recipeStats,omitempty"`
GuardianPower GuardianPower `json:"guardianPower"`
HasPlayerData bool `json:"hasPlayerData"`
PlayerDataLength uint32 `json:"playerDataLength"`
PlayerVersion uint32 `json:"playerVersion"`
MaxHealth float32 `json:"maxHealth"`
Health float32 `json:"health"`
MaxStamina float32 `json:"maxStamina"`
Stamina float32 `json:"stamina"`
MaxEitr float32 `json:"maxEitr"`
Eitr float32 `json:"eitr"`
TimeSinceDeath float32 `json:"timeSinceDeath"`
InventoryVersion uint32 `json:"inventoryVersion"`
Inventory []Item `json:"inventory,omitempty"`
KnownRecipes []string `json:"knownRecipes,omitempty"`
KnownStations []Station `json:"knownStations,omitempty"`
KnownMaterials []string `json:"knownMaterials,omitempty"`
ShownTutorials []string `json:"-"`
Uniques []string `json:"uniques,omitempty"`
Trophies []string `json:"trophies,omitempty"`
KnownBiomes []uint32 `json:"knownBiomes,omitempty"`
PlayerKnownTexts []TextEntry `json:"-"`
Beard string `json:"beard,omitempty"`
Hair string `json:"hair,omitempty"`
SkinColor Vector3 `json:"skinColor"`
HairColor Vector3 `json:"hairColor"`
ModelIndex uint32 `json:"modelIndex"`
Foods []Food `json:"foods,omitempty"`
SkillVersion uint32 `json:"skillVersion,omitempty"`
Skills []Skill `json:"skills,omitempty"`
CustomData []TextEntry `json:"customData,omitempty"`
// contains filtered or unexported fields
}
