server/character_editor.go (910B)
1 package main 2 3 // A detached editing snapshot combines character fields and item references. 4 type characterEditor struct { 5 playerProfile 6 playerPosition 7 Vitals playerVitals 8 Inventory inventoryReferences 9 Equipment map[string]*uint32 10 Bank map[string]*uint32 11 } 12 13 func (character *character) editor() characterEditor { 14 record := character.record() 15 items := character.inventory.references() 16 return characterEditor{record.Profile, record.Position.editor(), record.Vitals, items.inventoryReferences, items.Equipment, items.Bank} 17 } 18 19 func (data characterEditor) character() *character { 20 position := storedPosition{Playfield: data.Playfield, Position: data.Position, Rotation: data.Rotation} 21 if data.ReturnDoor != nil { 22 position.ReturnPlayfield, position.ReturnDoor = data.ReturnDoor.Playfield, data.ReturnDoor.Door 23 } 24 return (characterRecord{data.playerProfile, position, data.Vitals}).character() 25 }