forked from Benjamin-Dobell/ge_tts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerDropZone.ttslua
45 lines (34 loc) · 1.74 KB
/
PlayerDropZone.ttslua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
local TableUtils = require('ge_tts.TableUtils')
local DropZone = require('ge_tts.DropZone')
---@class ge_tts__PlayerDropZone : ge_tts__DropZone
---@shape ge_tts__PlayerDropZone_SavedState : ge_tts__DropZone_SavedState
---@field ownerColor tts__PlayerColor
---@class ge_tts__static_PlayerDropZone : ge_tts__static_DropZone
local PlayerDropZone = {}
setmetatable(PlayerDropZone, TableUtils.merge(getmetatable(DropZone), {
---@param zonePositionOrSavedState tts__VectorShape | table
---@param zoneRotation tts__VectorShape
---@param zoneScale tts__VectorShape
---@param occupantScale nil | number @Optional - occupant's desired X-axis scale. When scaling is applied it is applied to all dimensions i.e. aspect ratio is preserved. `nil` means dropped objects will not have their scale altered.
---@param owner tts__Player @TTS player that owns this PlayerDropZone
__call = function(_, zonePositionOrSavedState, zoneRotation, zoneScale, occupantScale, owner)
local self = --[[---@type ge_tts__PlayerDropZone]] DropZone(zonePositionOrSavedState, zoneRotation, zoneScale, occupantScale)
function self.getOwner()
return owner
end
local superSave = self.save
---@return ge_tts__PlayerDropZone_SavedState
function self.save()
return --[[---@type ge_tts__PlayerDropZone_SavedState]] TableUtils.merge(superSave(), {
ownerColor = owner.color
})
end
if PlayerDropZone.isSavedState(zonePositionOrSavedState) then
local data = --[[---@type ge_tts__PlayerDropZone_SavedState]] zonePositionOrSavedState
owner = Player[data.ownerColor]
end
return self
end,
__index = DropZone,
}))
return PlayerDropZone