# API

All exports and events that script provides for developers.

## Exports

### startTreeBuild

* Start prop placer for building tree.
* Side: `client`
* Usage:

```lua
--- void
exports.rcore_xmas:startTreeBuild()
```

### startSnowmanBuild

* Start prop placer for building snowman.
* Side: `client`
* Usage:

```lua
--- void
exports.rcore_xmas:startSnowmanBuild()
```

### isEntitySnowmanPart

* Returns true/false if provided entity is part of building process of man snowman
* Side: `client`
* Usage:

```lua
local entity = ...
--- snowmanPart: boolean (true/false)
local snowmanPart = exports.rcore_xmas:isEntitySnowmanPart(entity)

if snowmanPart then
    ...
end
```

### getTrees

* Returns table of all cached trees from database around map
* Side: `server`
* Usage:

```lua
--- {
---
---     [key: id]: string = {
---         model: int,
---         coords: vector3,
---         rotation: vector3,
---         heading: float,
---         owner: string
---     }: table
---
--- }: table
local cachedTrees = exports.rcore_xmas:getTrees()
for treeId, tree in pairs(cachedTrees) do
    local model = tree.model
    local coords = tree.coords
    local rotation = tree.rotation
    local heading = tree.model
    local owner = tree.model
    ...
end
```

### getTreesByOwner

* Returns table of all cached trees from database around map by provided owner id in parameter
* Side: `server`
* Usage:

```lua
local client = source?
--- {
---
---     [key: id]: string = {
---         model: int,
---         coords: vector3,
---         rotation: vector3,
---         heading: float,
---         owner: string
---     }: table
---
--- }: table
local trees = exports.rcore_xmas:getTreesByOwner(client)
```

### getCollectedPresents

* Returns all player's collected presents for present hunt directly and synchronously from database
* Side: `server`
* Usage:

```lua
local client = source?
--- {
---
---     [key: presentId]: string = boolean
---
--- }: table
local collectedPresents = exports.rcore_xmas:getCollectedPresents(client)
```

### getSpawnedSnowmans

* Returns all currently spawned snowmans.
* Side: `server`
* Usage:

```lua
--- {
---
---     [key: id]: string = Entity (number)
---
--- }: table
local snowmans = exports.rcore_xmas:getSpawnedSnowmans()
```

### isEntitySnowman

* Returns if entity in parameter is snowman built by script
* Side: `server`
* Usage:

```lua
--- boolean (true/false)
local entity = ...
if exports.rcore_xmas:isEntitySnowman(entity) then
    ...
end
```

### getPresentsPositions

* Returns table of all positions from `shared/present-hunt/sh-positions.lua` for present hunt
* Side: `shared`
* Usage:

```lua
--- {
---
---     {
---         position: vector3,
---         rotation: vector3
---     }: table
--
--- }: table
local presentsPositions = exports.rcore_xmas:getPresentsPositions()
```
