69 lines
1.5 KiB
Plaintext
69 lines
1.5 KiB
Plaintext
local Players = game:GetService("Players")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local DataTypes = require(ReplicatedStorage.Data.DataTypes)
|
|
local sharedBotUtils = require(ReplicatedStorage.Shared.SharedUtils.sharedBotUtils)
|
|
|
|
local TankShowcase = {}
|
|
|
|
local GarageFolder = workspace.Garage
|
|
local TankDisplay = GarageFolder:WaitForChild("TankDisplay")
|
|
|
|
local cCamera = workspace.CurrentCamera
|
|
|
|
local rotOffset = CFrame.Angles(0, 0, 0)
|
|
local currentTank
|
|
|
|
--[[
|
|
Anim
|
|
2:From right to center
|
|
1:From left to center
|
|
0:No Anim
|
|
|
|
|
|
]]
|
|
|
|
function _cleanupTank()
|
|
if currentTank then
|
|
currentTank:Destroy()
|
|
currentTank = nil
|
|
end
|
|
end
|
|
|
|
function _resetRot()
|
|
rotOffset = CFrame.Angles(0, 0, 0)
|
|
end
|
|
|
|
function TankShowcase.Focus()
|
|
cCamera.CameraType = Enum.CameraType.Scriptable
|
|
local position = TankDisplay.Position + TankDisplay.CFrame:VectorToWorldSpace(Vector3.new(0, 0, 10))
|
|
local newCFrame = CFrame.lookAt(position, TankDisplay.Position)
|
|
cCamera.CFrame = newCFrame
|
|
end
|
|
|
|
function TankShowcase.UnFocus()
|
|
cCamera.CameraType = Enum.CameraType.Custom
|
|
end
|
|
|
|
function TankShowcase.Showcase(loadout: DataTypes.Loadout)
|
|
_cleanupTank()
|
|
local new = sharedBotUtils.CreateBot(loadout)
|
|
print(new)
|
|
new:PivotTo(TankDisplay.CFrame)
|
|
_resetRot()
|
|
currentTank = new
|
|
currentTank.Parent = workspace
|
|
end
|
|
|
|
function TankShowcase.Update(dt)
|
|
if currentTank then
|
|
rotOffset = rotOffset * CFrame.Angles(0, math.rad(dt), 0)
|
|
currentTank:PivotTo(CFrame.new(currentTank:GetPivot().Position) * rotOffset)
|
|
else
|
|
_resetRot()
|
|
end
|
|
end
|
|
|
|
function TankShowcase:Init() end
|
|
|
|
return TankShowcase
|