<commit_before>package common

import (
	"time"

	"github.com/golang/geo/r3"

	st "github.com/markus-wa/demoinfocs-golang/sendtables"
)

const (
	maxEdictBits                 = 11
	entityHandleSerialNumberBits = 10
	entityHandleBits             = maxEdictBits + entityHandleSerialNumberBits
	invalidEntityHandle          = (1 << entityHandleBits) - 1
)

// Player contains mostly game-relevant player information.
type Player struct {
	demoInfoProvider demoInfoProvider // provider for demo info such as tick-rate or current tick

	SteamID                     int64     // int64 representation of the User's Steam ID
	Position                    r3.Vector // In-game coordinates. Like the one you get from cl_showpos 1
	LastAlivePosition           r3.Vector // The location where the player was last alive. Should be equal to Position if the player is still alive.
	Velocity                    r3.Vector // Movement velocity
	EntityID                    int       // The ID of the player-entity, see Entity field
	UserID                      int       // Mostly used in game-events to address this player
	Name                        string    // Steam / in-game user name
	Hp                          int
	Armor                       int
	Money                       int
	CurrentEquipmentValue       int
	FreezetimeEndEquipmentValue int
	RoundStartEquipmentValue    int
	ActiveWeaponID              int                // Used internally to set the active weapon, see ActiveWeapon()
	RawWeapons                  map[int]*Equipment // All weapons the player is currently carrying
	AmmoLeft                    [32]int            // Ammo left for special weapons (e.g. grenades), index corresponds Equipment.AmmoType
	Entity                      st.IEntity
	AdditionalPlayerInformation *AdditionalPlayerInformation // Mostly scoreboard information such as kills, deaths, etc.
	ViewDirectionX              float32                      // Yaw in degrees, 0 to 360
	ViewDirectionY              float32                      // Pitch in degrees, 270 to 90 (270=-90)
	FlashDuration               float32                      // Blindness duration from the flashbang currently affecting the player (seconds)
	FlashTick                   int                          // In-game tick at which the player was last flashed
	TeamState                   *TeamState                   // When keeping the reference make sure you notice when the player changes teams
	Team                        Team
	IsBot                       bool // True if this is a bot-entity. See also IsControllingBot and ControlledBot().
	IsConnected                 bool
	IsDucking                   bool
	IsDefusing                  bool
	IsPlanting                  bool
	IsReloading                 bool
	IsUnknown                   bool // Used to identify unknown/broken players. see https://github.com/markus-wa/demoinfocs-golang/issues/162
	HasDefuseKit                bool
	HasHelmet                   bool
}

// String returns the player's name.
// Implements fmt.Stringer.
func (p *Player) String() string {
	if p == nil {
		return "(nil)"
	}
<commit_msg>common: document that Player.Entity may be nil (#170)<commit_after>package common

import (
	"time"

	"github.com/golang/geo/r3"

	st "github.com/markus-wa/demoinfocs-golang/sendtables"
)

const (
	maxEdictBits                 = 11
	entityHandleSerialNumberBits = 10
	entityHandleBits             = maxEdictBits + entityHandleSerialNumberBits
	invalidEntityHandle          = (1 << entityHandleBits) - 1
)

// Player contains mostly game-relevant player information.
type Player struct {
	demoInfoProvider demoInfoProvider // provider for demo info such as tick-rate or current tick

	SteamID                     int64     // int64 representation of the User's Steam ID
	Position                    r3.Vector // In-game coordinates. Like the one you get from cl_showpos 1
	LastAlivePosition           r3.Vector // The location where the player was last alive. Should be equal to Position if the player is still alive.
	Velocity                    r3.Vector // Movement velocity
	EntityID                    int       // The ID of the player-entity, see Entity field
	UserID                      int       // Mostly used in game-events to address this player
	Name                        string    // Steam / in-game user name
	Hp                          int
	Armor                       int
	Money                       int
	CurrentEquipmentValue       int
	FreezetimeEndEquipmentValue int
	RoundStartEquipmentValue    int
	ActiveWeaponID              int                          // Used internally to set the active weapon, see ActiveWeapon()
	RawWeapons                  map[int]*Equipment           // All weapons the player is currently carrying
	AmmoLeft                    [32]int                      // Ammo left for special weapons (e.g. grenades), index corresponds Equipment.AmmoType
	Entity                      st.IEntity                   // May be nil between player-death and re-spawn
	AdditionalPlayerInformation *AdditionalPlayerInformation // Mostly scoreboard information such as kills, deaths, etc.
	ViewDirectionX              float32                      // Yaw in degrees, 0 to 360
	ViewDirectionY              float32                      // Pitch in degrees, 270 to 90 (270=-90)
	FlashDuration               float32                      // Blindness duration from the flashbang currently affecting the player (seconds)
	FlashTick                   int                          // In-game tick at which the player was last flashed
	TeamState                   *TeamState                   // When keeping the reference make sure you notice when the player changes teams
	Team                        Team
	IsBot                       bool // True if this is a bot-entity. See also IsControllingBot and ControlledBot().
	IsConnected                 bool
	IsDucking                   bool
	IsDefusing                  bool
	IsPlanting                  bool
	IsReloading                 bool
	IsUnknown                   bool // Used to identify unknown/broken players. see https://github.com/markus-wa/demoinfocs-golang/issues/162
	HasDefuseKit                bool
	HasHelmet                   bool
}

// String returns the player's name.
// Implements fmt.Stringer.
func (p *Player) String() string {
	if p == nil {
		return "(nil)"
	}

{'fraction_non_alphanumeric': 0.051221804511278196, 'fraction_numerical': 0.01300125313283208, 'mean_word_length': 1.6157312576812781, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '458288', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1475, 'n_words': 570}