mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Giant refactoring of how the client and server character is handled
This commit is contained in:
@@ -1,9 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "ElevatorGame",
|
"name": "ElevatorGame",
|
||||||
"globIgnorePaths": [
|
|
||||||
"**/package.json",
|
|
||||||
"**/tsconfig.json"
|
|
||||||
],
|
|
||||||
"tree": {
|
"tree": {
|
||||||
"$className": "DataModel",
|
"$className": "DataModel",
|
||||||
"ReplicatedStorage": {
|
"ReplicatedStorage": {
|
||||||
@@ -12,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"ServerScriptService": {
|
"ServerScriptService": {
|
||||||
"$className": "ServerScriptService",
|
"$className": "ServerScriptService",
|
||||||
"rapid-Server": {
|
"rapid/server": {
|
||||||
"$className": "Actor",
|
"$className": "Actor",
|
||||||
"$path": "src/server"
|
"$path": "src/server"
|
||||||
}
|
}
|
||||||
@@ -25,19 +21,12 @@
|
|||||||
"$className": "StarterPlayer",
|
"$className": "StarterPlayer",
|
||||||
"StarterPlayerScripts": {
|
"StarterPlayerScripts": {
|
||||||
"$className": "StarterPlayerScripts",
|
"$className": "StarterPlayerScripts",
|
||||||
"rapid-PlayerRoot": {
|
"rapid/client": {
|
||||||
"$className": "Actor",
|
"$className": "Actor",
|
||||||
"Player": {
|
"Player": {
|
||||||
"$path": "src/client/Player"
|
"$path": "src/client/Player"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"StarterCharacterScripts": {
|
|
||||||
"$className": "StarterCharacterScripts",
|
|
||||||
"rapid-CharacterRoot": {
|
|
||||||
"$className": "Actor",
|
|
||||||
"$path": "src/client/Character"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,113 +0,0 @@
|
|||||||
--!optimize 2
|
|
||||||
--!native
|
|
||||||
--!strict
|
|
||||||
|
|
||||||
type CharacterSharedFolder = Folder
|
|
||||||
type TCP = RemoteEvent
|
|
||||||
|
|
||||||
local Dir = script.Parent
|
|
||||||
local Character = Dir.Parent
|
|
||||||
local CharacterShared = Dir:WaitForChild("shared")
|
|
||||||
|
|
||||||
local preprocessor = {}
|
|
||||||
|
|
||||||
function preprocessor.CharacterShared(): CharacterSharedFolder
|
|
||||||
return CharacterShared
|
|
||||||
end
|
|
||||||
|
|
||||||
_G.include = function(this: LuaSourceContainer, FunName: string, ...)
|
|
||||||
if this:IsDescendantOf(script) then --getfenv is being removed
|
|
||||||
local switch = preprocessor[FunName]
|
|
||||||
return type(switch) == "function" and switch(...) or switch
|
|
||||||
else
|
|
||||||
warn(`Preprocessor append failed "{FunName}"`, debug.traceback())
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
||||||
local RS: RunService = game:GetService("RunService")
|
|
||||||
|
|
||||||
local ClientStorage: Instance = Storage:WaitForChild("Client") :: Folder
|
|
||||||
local LoadCompleted: Instance = ClientStorage:WaitForChild("LoadingComplete") :: BindableFunction
|
|
||||||
local ActionsTCP: TCP = CharacterShared:WaitForChild("Actions")
|
|
||||||
|
|
||||||
--We need to wait for the game to load before spamming functionality
|
|
||||||
repeat
|
|
||||||
local GameIsLoaded = (LoadCompleted :: BindableFunction):Invoke()
|
|
||||||
task.wait()
|
|
||||||
until GameIsLoaded
|
|
||||||
|
|
||||||
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
|
|
||||||
local CameraModule = require(script:WaitForChild("Camera"))
|
|
||||||
local HumanoidModule = require(script:WaitForChild("Humanoid"))
|
|
||||||
local SpineModule = require(script:WaitForChild("SpineKinematics"))
|
|
||||||
local ActionsModule = require(script:WaitForChild("Actions"))
|
|
||||||
local BindModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
|
||||||
|
|
||||||
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
|
|
||||||
local Humanoid = Character:WaitForChild("Humanoid")
|
|
||||||
local CurrentCamera = workspace.CurrentCamera
|
|
||||||
|
|
||||||
local HRPSettings = HumanoidRPSettings.constructor(HumanoidRootPart)
|
|
||||||
local CameraConsturctor = CameraModule.constructor(CurrentCamera, HumanoidRootPart, Humanoid)
|
|
||||||
local HumanoidSettings = HumanoidModule.constructor(Humanoid)
|
|
||||||
local SpineMovement = SpineModule.constructor(CurrentCamera)
|
|
||||||
|
|
||||||
local ClientBindMap = BindModule.constructor(false)
|
|
||||||
|
|
||||||
local function ClientCharacterBinds()
|
|
||||||
local Actions = ActionsModule.constructor(HumanoidSettings, CurrentCamera, ActionsTCP)
|
|
||||||
|
|
||||||
--Crouch
|
|
||||||
ClientBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
|
|
||||||
Actions:EnableCrouch()
|
|
||||||
end)
|
|
||||||
ClientBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
|
|
||||||
Actions:DisableCrouch()
|
|
||||||
end)
|
|
||||||
|
|
||||||
--Walk
|
|
||||||
ClientBindMap:AddInputBegan({
|
|
||||||
Enum.KeyCode.LeftAlt,
|
|
||||||
Enum.KeyCode.RightAlt,
|
|
||||||
Enum.KeyCode.LeftShift,
|
|
||||||
Enum.KeyCode.RightShift
|
|
||||||
}, function(_KeyPressed)
|
|
||||||
Actions:EnableSneak()
|
|
||||||
end)
|
|
||||||
ClientBindMap:AddInputEnded({
|
|
||||||
Enum.KeyCode.LeftAlt,
|
|
||||||
Enum.KeyCode.RightAlt,
|
|
||||||
Enum.KeyCode.LeftShift,
|
|
||||||
Enum.KeyCode.RightShift
|
|
||||||
}, function(_KeyPressed)
|
|
||||||
Actions:DisableSneak()
|
|
||||||
end)
|
|
||||||
|
|
||||||
--Flashlight
|
|
||||||
ClientBindMap:AddInputBegan({Enum.KeyCode.F}, function(KeyPressed: Enum.KeyCode)
|
|
||||||
Actions:ToggleFlashlight(KeyPressed)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
--Needs to be a module maybe
|
|
||||||
local function Crosshair3DVelocity_Effect(): RBXScriptConnection
|
|
||||||
local RootVelocity = ClientStorage:WaitForChild("RootVelocity") :: BindableEvent
|
|
||||||
|
|
||||||
local RootVelocityStep = RS.Heartbeat:ConnectParallel(function(_dt)
|
|
||||||
RootVelocity:Fire(HRPSettings:Velocity())
|
|
||||||
end)
|
|
||||||
return RootVelocityStep
|
|
||||||
end
|
|
||||||
|
|
||||||
HumanoidSettings:SetWalkSpeed()
|
|
||||||
HumanoidSettings:SetJumpHeight()
|
|
||||||
HRPSettings:DisableRobloxSounds()
|
|
||||||
CameraConsturctor:EnableBobbing()
|
|
||||||
--SpineMovement:Enable()
|
|
||||||
|
|
||||||
ClientCharacterBinds()
|
|
||||||
Crosshair3DVelocity_Effect()
|
|
||||||
|
|
||||||
_G.include = nil
|
|
||||||
@@ -3,21 +3,26 @@
|
|||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
type UDP = UnreliableRemoteEvent
|
type UDP = UnreliableRemoteEvent
|
||||||
|
type CharacterSharedFolder = Folder
|
||||||
local Dir = script.Parent
|
|
||||||
local Character = Dir.Parent
|
|
||||||
local preprocessor = {}
|
|
||||||
|
|
||||||
local FlashlightCooldown = .10
|
|
||||||
|
|
||||||
local Players = game:GetService("Players")
|
local Players = game:GetService("Players")
|
||||||
|
|
||||||
--Create the character shared directory here
|
local Dir = script.Parent
|
||||||
local CharacterShared = Instance.new("Folder")
|
local Character = Dir.Parent
|
||||||
CharacterShared.Name = "shared"
|
local preprocessor = {}
|
||||||
CharacterShared.Parent = Dir
|
|
||||||
|
--Production--
|
||||||
|
--if not RS:IsStudio() then
|
||||||
|
task.wait()
|
||||||
|
Dir.Parent = nil
|
||||||
|
--end
|
||||||
|
--
|
||||||
|
|
||||||
|
--Create the character shared directory here
|
||||||
|
local CharacterShared = Instance.new("Folder")
|
||||||
|
CharacterShared.Name = "shared"
|
||||||
|
CharacterShared.Parent = Character
|
||||||
|
|
||||||
type CharacterSharedFolder = Folder
|
|
||||||
function preprocessor.CharacterShared(): Instance
|
function preprocessor.CharacterShared(): Instance
|
||||||
return CharacterShared :: CharacterSharedFolder
|
return CharacterShared :: CharacterSharedFolder
|
||||||
end
|
end
|
||||||
@@ -58,6 +63,8 @@ Character.DescendantAdded:Connect(function(Instance)
|
|||||||
CharacterShadows:PartToggle(Instance, false)
|
CharacterShadows:PartToggle(Instance, false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local FlashlightCooldown = .10
|
||||||
|
|
||||||
Actions:Add(Enum.KeyCode.F, function(_KeyPressed)
|
Actions:Add(Enum.KeyCode.F, function(_KeyPressed)
|
||||||
if not FlashlightDebounce then
|
if not FlashlightDebounce then
|
||||||
Flashlight:Toggle()
|
Flashlight:Toggle()
|
||||||
|
|||||||
125
src/client/Player/Character/init.lua
Normal file
125
src/client/Player/Character/init.lua
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
--!optimize 2
|
||||||
|
--!native
|
||||||
|
--!strict
|
||||||
|
|
||||||
|
type CharacterSharedFolder = Folder
|
||||||
|
type TCP = RemoteEvent
|
||||||
|
|
||||||
|
local CharacterModule = {}
|
||||||
|
CharacterModule.__index = CharacterModule
|
||||||
|
|
||||||
|
local RS = game:GetService("RunService")
|
||||||
|
local Storage = game:GetService("ReplicatedStorage")
|
||||||
|
|
||||||
|
local ClientStorage = Storage:WaitForChild("Client") :: Folder
|
||||||
|
|
||||||
|
local preprocessor = {}
|
||||||
|
local CharacterShared: Folder
|
||||||
|
|
||||||
|
function preprocessor.CharacterShared(): CharacterSharedFolder
|
||||||
|
return CharacterShared
|
||||||
|
end
|
||||||
|
|
||||||
|
_G.include = function(this: LuaSourceContainer, FunName: string, ...)
|
||||||
|
if this:IsDescendantOf(script) then --getfenv is being removed
|
||||||
|
local switch = preprocessor[FunName]
|
||||||
|
return type(switch) == "function" and switch(...) or switch
|
||||||
|
else
|
||||||
|
warn(`Preprocessor append failed "{FunName}"`, debug.traceback())
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function CharacterModule.constructor(Character)
|
||||||
|
CharacterShared = Character:WaitForChild("shared")
|
||||||
|
|
||||||
|
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
|
||||||
|
local CameraModule = require(script:WaitForChild("Camera"))
|
||||||
|
local HumanoidModule = require(script:WaitForChild("Humanoid"))
|
||||||
|
local SpineModule = require(script:WaitForChild("SpineKinematics"))
|
||||||
|
|
||||||
|
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
|
||||||
|
local Humanoid = Character:WaitForChild("Humanoid")
|
||||||
|
|
||||||
|
local self = {}
|
||||||
|
self.ActionsTCP = CharacterShared:WaitForChild("Actions")
|
||||||
|
self.ActionsModule = require(script:WaitForChild("Actions"))
|
||||||
|
self.BindModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
||||||
|
|
||||||
|
self.CurrentCamera = workspace.CurrentCamera
|
||||||
|
self.HRPSettings = HumanoidRPSettings.constructor(HumanoidRootPart)
|
||||||
|
self.CameraConsturctor = CameraModule.constructor(self.CurrentCamera, HumanoidRootPart, Humanoid)
|
||||||
|
self.HumanoidSettings = HumanoidModule.constructor(Humanoid)
|
||||||
|
self.SpineMovement = SpineModule.constructor(self.CurrentCamera)
|
||||||
|
|
||||||
|
return setmetatable(self, CharacterModule)
|
||||||
|
end
|
||||||
|
|
||||||
|
function CharacterModule:CharacterKeyBinds()
|
||||||
|
local ClientBindMap = self.BindModule.constructor(false)
|
||||||
|
local Actions = self.ActionsModule.constructor(self.HumanoidSettings, self.CurrentCamera, self.ActionsTCP)
|
||||||
|
|
||||||
|
--Crouch
|
||||||
|
ClientBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
|
||||||
|
Actions:EnableCrouch()
|
||||||
|
end)
|
||||||
|
ClientBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function(_KeyPressed)
|
||||||
|
Actions:DisableCrouch()
|
||||||
|
end)
|
||||||
|
|
||||||
|
--Walk
|
||||||
|
ClientBindMap:AddInputBegan({
|
||||||
|
Enum.KeyCode.LeftAlt,
|
||||||
|
Enum.KeyCode.RightAlt,
|
||||||
|
Enum.KeyCode.LeftShift,
|
||||||
|
Enum.KeyCode.RightShift
|
||||||
|
}, function(_KeyPressed)
|
||||||
|
Actions:EnableSneak()
|
||||||
|
end)
|
||||||
|
ClientBindMap:AddInputEnded({
|
||||||
|
Enum.KeyCode.LeftAlt,
|
||||||
|
Enum.KeyCode.RightAlt,
|
||||||
|
Enum.KeyCode.LeftShift,
|
||||||
|
Enum.KeyCode.RightShift
|
||||||
|
}, function(_KeyPressed)
|
||||||
|
Actions:DisableSneak()
|
||||||
|
end)
|
||||||
|
|
||||||
|
--Flashlight
|
||||||
|
ClientBindMap:AddInputBegan({Enum.KeyCode.F}, function(KeyPressed: Enum.KeyCode)
|
||||||
|
Actions:ToggleFlashlight(KeyPressed)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function CharacterModule:Crosshair()
|
||||||
|
local RootVelocity = ClientStorage:WaitForChild("RootVelocity") :: BindableEvent
|
||||||
|
|
||||||
|
local RootVelocityStep = RS.Heartbeat:ConnectParallel(function(_dt)
|
||||||
|
RootVelocity:Fire(self.HRPSettings:Velocity())
|
||||||
|
end)
|
||||||
|
return RootVelocityStep
|
||||||
|
end
|
||||||
|
|
||||||
|
function CharacterModule:SetWalkSpeed()
|
||||||
|
self.HumanoidSettings:SetWalkSpeed()
|
||||||
|
end
|
||||||
|
|
||||||
|
function CharacterModule:SetJumpHeight()
|
||||||
|
self.HumanoidSettings:SetJumpHeight()
|
||||||
|
end
|
||||||
|
|
||||||
|
function CharacterModule:DisableRobloxSounds()
|
||||||
|
self.HRPSettings:DisableRobloxSounds()
|
||||||
|
end
|
||||||
|
|
||||||
|
function CharacterModule:EnableCameraBobbing()
|
||||||
|
self.CameraConsturctor:EnableBobbing()
|
||||||
|
end
|
||||||
|
|
||||||
|
function CharacterModule:EnableSpineMovement()
|
||||||
|
self.SpineMovement:Enable()
|
||||||
|
end
|
||||||
|
|
||||||
|
_G.include = nil
|
||||||
|
|
||||||
|
return CharacterModule
|
||||||
@@ -2,40 +2,65 @@
|
|||||||
--!native
|
--!native
|
||||||
--!strict
|
--!strict
|
||||||
|
|
||||||
|
type CurrentCamera = Camera
|
||||||
|
|
||||||
|
local Players = game:GetService("Players")
|
||||||
|
local Storage = game:GetService("ReplicatedStorage")
|
||||||
|
local RS = game:GetService("RunService")
|
||||||
|
|
||||||
|
--Production--
|
||||||
|
--if not RS:IsStudio() then
|
||||||
|
RS.RenderStepped:Wait()
|
||||||
|
script.Parent.Parent = nil
|
||||||
|
--end
|
||||||
|
--
|
||||||
|
|
||||||
local UI = script:WaitForChild("UI")
|
local UI = script:WaitForChild("UI")
|
||||||
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
|
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
|
||||||
local VignetteSettings = require(UI:WaitForChild("Vignette"))
|
local VignetteSettings = require(UI:WaitForChild("Vignette"))
|
||||||
local HealthSettings = require(UI:WaitForChild("Health"))
|
local HealthSettings = require(UI:WaitForChild("Health"))
|
||||||
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
local CoreGuis = require(script:WaitForChild("CoreGuis"))
|
||||||
local Mouse = require(script:WaitForChild("Mouse"))
|
local Mouse = require(script:WaitForChild("Mouse"))
|
||||||
|
local Character = require(script:WaitForChild("Character"))
|
||||||
|
|
||||||
local Players: Players = game:GetService("Players")
|
local function LoadCharacter(CharacterModel)
|
||||||
local Storage: ReplicatedStorage = game:GetService("ReplicatedStorage")
|
local CharacterConstructor = Character.constructor(CharacterModel)
|
||||||
|
|
||||||
local ClientStorage = Storage:WaitForChild("Client")
|
CharacterConstructor:DisableRobloxSounds()
|
||||||
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
|
CharacterConstructor:SetWalkSpeed()
|
||||||
local KeyBindsModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
CharacterConstructor:SetJumpHeight()
|
||||||
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
|
CharacterConstructor:Crosshair()
|
||||||
|
CharacterConstructor:EnableCameraBobbing()
|
||||||
local Player = Players.LocalPlayer
|
CharacterConstructor:CharacterKeyBinds()
|
||||||
local PlayerGui = Player:WaitForChild("PlayerGui") :: PlayerGui
|
end
|
||||||
|
|
||||||
--We need to wait for the game to load before spamming functionality
|
--We need to wait for the game to load before spamming functionality
|
||||||
repeat
|
repeat
|
||||||
local GameIsLoaded = (LoadCompleted :: BindableFunction):Invoke()
|
local GameIsLoaded = game:IsLoaded()
|
||||||
task.wait()
|
task.wait()
|
||||||
until GameIsLoaded
|
until GameIsLoaded
|
||||||
|
|
||||||
local CurrentCamera = nil
|
local CurrentCamera: CurrentCamera
|
||||||
repeat
|
repeat
|
||||||
task.wait()
|
task.wait()
|
||||||
CurrentCamera = workspace.CurrentCamera
|
CurrentCamera = workspace.CurrentCamera
|
||||||
until CurrentCamera
|
until CurrentCamera
|
||||||
|
|
||||||
|
local ClientStorage = Storage:WaitForChild("Client")
|
||||||
|
local KeyBindsModule = require(ClientStorage:WaitForChild("KeyBinds"))
|
||||||
|
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
|
||||||
|
|
||||||
|
local Player = Players.LocalPlayer
|
||||||
|
local PlayerGui = Player:WaitForChild("PlayerGui") :: PlayerGui
|
||||||
|
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
|
||||||
|
|
||||||
local Vignette = VignetteSettings.constructor(PlayerGui)
|
local Vignette = VignetteSettings.constructor(PlayerGui)
|
||||||
local Camera = CameraSettings.constructor(CurrentCamera, Player)
|
local Camera = CameraSettings.constructor(CurrentCamera, Player)
|
||||||
local Crosshair = CrosshairSettings.constructor(PlayerGui)
|
local Crosshair = CrosshairSettings.constructor(PlayerGui)
|
||||||
|
|
||||||
|
LoadCharacter(PlayerCharacter)
|
||||||
|
Player.CharacterAdded:Connect(LoadCharacter)
|
||||||
|
|
||||||
--Keybinds
|
--Keybinds
|
||||||
local function CameraBinds()
|
local function CameraBinds()
|
||||||
local CameraBindMap = KeyBindsModule.constructor(false)
|
local CameraBindMap = KeyBindsModule.constructor(false)
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ type GuiDependencies = {
|
|||||||
FrameworkText: TextLabel,
|
FrameworkText: TextLabel,
|
||||||
SandboxText: TextLabel,
|
SandboxText: TextLabel,
|
||||||
DeveloperText: TextLabel,
|
DeveloperText: TextLabel,
|
||||||
|
Quaternions: ImageLabel,
|
||||||
|
TaylorSeries: ImageLabel,
|
||||||
Xframe: Frame,
|
Xframe: Frame,
|
||||||
Yframe: Frame,
|
Yframe: Frame,
|
||||||
Zframe: Frame,
|
Zframe: Frame,
|
||||||
@@ -41,6 +43,7 @@ type GuiDependencies = {
|
|||||||
local RS = game:GetService("RunService")
|
local RS = game:GetService("RunService")
|
||||||
local Storage = game:GetService("ReplicatedStorage")
|
local Storage = game:GetService("ReplicatedStorage")
|
||||||
local TS = game:GetService("TestService")
|
local TS = game:GetService("TestService")
|
||||||
|
local CoP = game:GetService("ContentProvider")
|
||||||
|
|
||||||
local LoadingFun = true
|
local LoadingFun = true
|
||||||
|
|
||||||
@@ -55,6 +58,8 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
|||||||
local SandboxText = Frame:WaitForChild("Sandbox") :: TextLabel
|
local SandboxText = Frame:WaitForChild("Sandbox") :: TextLabel
|
||||||
local DeveloperText = Frame:WaitForChild("Developer") :: TextLabel
|
local DeveloperText = Frame:WaitForChild("Developer") :: TextLabel
|
||||||
local ShadowGradient = TextShadow:WaitForChild("UIGradient") :: UIGradient
|
local ShadowGradient = TextShadow:WaitForChild("UIGradient") :: UIGradient
|
||||||
|
local Quaternions = Frame:WaitForChild("Quaternions") :: ImageLabel
|
||||||
|
local TaylorSeries = Frame:WaitForChild("TaylorSeries") :: ImageLabel
|
||||||
|
|
||||||
local Xframe = Frame:WaitForChild("X") :: Frame
|
local Xframe = Frame:WaitForChild("X") :: Frame
|
||||||
local Yframe = Frame:WaitForChild("Y") :: Frame
|
local Yframe = Frame:WaitForChild("Y") :: Frame
|
||||||
@@ -73,6 +78,8 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
|||||||
FrameworkText = FrameworkText,
|
FrameworkText = FrameworkText,
|
||||||
SandboxText = SandboxText,
|
SandboxText = SandboxText,
|
||||||
DeveloperText = DeveloperText,
|
DeveloperText = DeveloperText,
|
||||||
|
Quaternions = Quaternions,
|
||||||
|
TaylorSeries = TaylorSeries,
|
||||||
Xframe = Xframe,
|
Xframe = Xframe,
|
||||||
Yframe = Yframe,
|
Yframe = Yframe,
|
||||||
Zframe = Zframe,
|
Zframe = Zframe,
|
||||||
@@ -82,6 +89,9 @@ local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local Size = 300
|
||||||
|
local WorldSize = 3
|
||||||
|
|
||||||
local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can now access the framework
|
local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can now access the framework
|
||||||
--Image if we had HTML and CSS...
|
--Image if we had HTML and CSS...
|
||||||
local Tween = require(Storage:WaitForChild("Tween"))
|
local Tween = require(Storage:WaitForChild("Tween"))
|
||||||
@@ -89,12 +99,28 @@ local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can n
|
|||||||
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Frame, {
|
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Frame, {
|
||||||
BackgroundTransparency = 1
|
BackgroundTransparency = 1
|
||||||
})
|
})
|
||||||
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
|
|
||||||
|
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
|
||||||
TextTransparency = 1
|
TextTransparency = 1
|
||||||
})
|
}):Start()
|
||||||
|
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.TaylorSeries, {
|
||||||
|
ImageTransparency = 1
|
||||||
|
}):Start()
|
||||||
|
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Quaternions, {
|
||||||
|
ImageTransparency = 1
|
||||||
|
}):Start()
|
||||||
|
|
||||||
|
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Xframe_text, {
|
||||||
|
TextTransparency = 1
|
||||||
|
}):Start()
|
||||||
|
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Yframe_text, {
|
||||||
|
TextTransparency = 1
|
||||||
|
}):Start()
|
||||||
|
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Zframe_text, {
|
||||||
|
TextTransparency = 1
|
||||||
|
}):Start()
|
||||||
|
|
||||||
local FrameTween = FrameTween_Constructor:Start()
|
local FrameTween = FrameTween_Constructor:Start()
|
||||||
DeveloperTween_Constructor:Start()
|
|
||||||
|
|
||||||
--Text deleting effect
|
--Text deleting effect
|
||||||
task.spawn(function()
|
task.spawn(function()
|
||||||
@@ -108,9 +134,16 @@ local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can n
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
task.spawn(function()
|
||||||
|
while task.wait() do
|
||||||
|
Size = math.max(0, Size-5)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
FrameTween.Completed:Wait()
|
FrameTween.Completed:Wait()
|
||||||
Stepped:Disconnect()
|
Stepped:Disconnect()
|
||||||
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
|
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
|
||||||
|
script.Parent:Destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
local function RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
||||||
@@ -132,61 +165,63 @@ local function Scalar(X1: number, Y1: number, X2: number, Y2: number): Scalar
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local Size = 300
|
local function UI_3D_Rotation(Gui: GuiDependencies, Delta: number)
|
||||||
local WorldSize = 3
|
local ScreenD = workspace.CurrentCamera.ViewportSize
|
||||||
|
local CenterX = ScreenD.X/2
|
||||||
|
local CenterY = ScreenD.Y/1.4
|
||||||
|
local mX = Delta/1.5
|
||||||
|
local mY = Delta/1.5
|
||||||
|
local mZ = -7.65
|
||||||
|
|
||||||
|
local RMatrix = RotationMatrix(mX,mY,mZ)
|
||||||
|
local X = {Size*RMatrix.Ixx, Size*RMatrix.Ixy}
|
||||||
|
local Y = {Size*RMatrix.Iyx, Size*RMatrix.Iyy}
|
||||||
|
local Z = {Size*RMatrix.Izx, Size*RMatrix.Izy}
|
||||||
|
|
||||||
|
local AXIS_R_3DScalar_X = Scalar(CenterX+X[1],CenterY+X[2],CenterX,CenterY)
|
||||||
|
local AXIS_R_3DScalar_Y = Scalar(CenterX+Y[1],CenterY+Y[2],CenterX,CenterY)
|
||||||
|
local AXIS_R_3DScalar_Z = Scalar(CenterX+Z[1],CenterY+Z[2],CenterX,CenterY)
|
||||||
|
|
||||||
|
Gui.Xframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
||||||
|
Gui.Yframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
||||||
|
Gui.Zframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
||||||
|
|
||||||
|
Gui.Xframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
||||||
|
Gui.Yframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
||||||
|
Gui.Zframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
||||||
|
|
||||||
|
Gui.Xframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_X.Distance, WorldSize)
|
||||||
|
Gui.Yframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Y.Distance, WorldSize)
|
||||||
|
Gui.Zframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Z.Distance, WorldSize)
|
||||||
|
|
||||||
|
Gui.Xframe.Rotation = AXIS_R_3DScalar_X.Rotation
|
||||||
|
Gui.Yframe.Rotation = AXIS_R_3DScalar_Y.Rotation
|
||||||
|
Gui.Zframe.Rotation = AXIS_R_3DScalar_Z.Rotation
|
||||||
|
|
||||||
|
Gui.Xframe_text.Rotation = Gui.Xframe.Rotation
|
||||||
|
Gui.Yframe_text.Rotation = Gui.Yframe.Rotation
|
||||||
|
Gui.Zframe_text.Rotation = Gui.Zframe.Rotation
|
||||||
|
end
|
||||||
|
|
||||||
return function(IntroGui: ScreenGui, load_elapse_start: number)
|
return function(IntroGui: ScreenGui, load_elapse_start: number)
|
||||||
local Gui = GuiDependencies(IntroGui)
|
local Gui = GuiDependencies(IntroGui)
|
||||||
|
|
||||||
local Stepped = RS.Stepped:Connect(function(Delta: number, dt: number)
|
local Stepped = RS.Stepped:Connect(function(Delta: number, _dt: number)
|
||||||
local ScreenD = workspace.CurrentCamera.ViewportSize
|
UI_3D_Rotation(Gui, Delta)
|
||||||
local CenterX = ScreenD.X/2
|
|
||||||
local CenterY = ScreenD.Y/1.4
|
|
||||||
|
|
||||||
local mX = Delta/1.5
|
|
||||||
local mY = Delta/1.5
|
|
||||||
local mZ = -7.65
|
|
||||||
|
|
||||||
local RMatrix = RotationMatrix(mX,mY,mZ)
|
|
||||||
local X = {Size*RMatrix.Ixx, Size*RMatrix.Ixy}
|
|
||||||
local Y = {Size*RMatrix.Iyx, Size*RMatrix.Iyy}
|
|
||||||
local Z = {Size*RMatrix.Izx, Size*RMatrix.Izy}
|
|
||||||
|
|
||||||
local AXIS_R_3DScalar_X = Scalar(CenterX+X[1],CenterY+X[2],CenterX,CenterY)
|
|
||||||
local AXIS_R_3DScalar_Y = Scalar(CenterX+Y[1],CenterY+Y[2],CenterX,CenterY)
|
|
||||||
local AXIS_R_3DScalar_Z = Scalar(CenterX+Z[1],CenterY+Z[2],CenterX,CenterY)
|
|
||||||
|
|
||||||
Gui.Xframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_X.Distance, WorldSize)
|
|
||||||
Gui.Xframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
|
||||||
Gui.Xframe.Rotation = AXIS_R_3DScalar_X.Rotation
|
|
||||||
|
|
||||||
Gui.Xframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
|
||||||
Gui.Xframe_text.Rotation = Gui.Xframe.Rotation
|
|
||||||
|
|
||||||
Gui.Yframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Y.Distance, WorldSize)
|
|
||||||
Gui.Yframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
|
||||||
Gui.Yframe.Rotation = AXIS_R_3DScalar_Y.Rotation
|
|
||||||
|
|
||||||
Gui.Yframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
|
||||||
Gui.Yframe_text.Rotation = Gui.Yframe.Rotation
|
|
||||||
|
|
||||||
Gui.Zframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Z.Distance, WorldSize)
|
|
||||||
Gui.Zframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
|
||||||
Gui.Zframe.Rotation = AXIS_R_3DScalar_Z.Rotation
|
|
||||||
|
|
||||||
Gui.Zframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
|
||||||
Gui.Zframe_text.Rotation = Gui.Zframe.Rotation
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
task.spawn(function()
|
task.spawn(function()
|
||||||
|
CoP:PreloadAsync({Gui.TaylorSeries, Gui.Quaternions}) --Try as early as possible
|
||||||
|
|
||||||
if not game:IsLoaded() then
|
if not game:IsLoaded() then
|
||||||
game.Loaded:Wait()
|
game.Loaded:Wait()
|
||||||
end
|
end
|
||||||
|
|
||||||
local load_elapse = os.clock()-load_elapse_start
|
local load_elapse = os.clock()-load_elapse_start
|
||||||
if LoadingFun then
|
if LoadingFun then
|
||||||
task.wait(math.max(0, 3-load_elapse)) --Only if you take longer than or exactly 3 seconds to load
|
task.wait(math.max(0, 4-load_elapse)) --Only if you take longer than or exactly 4 seconds to load
|
||||||
end
|
end
|
||||||
|
|
||||||
TS:Message("Load elapse: "..tostring(load_elapse), game)
|
TS:Message("Load elapse: "..tostring(load_elapse), game)
|
||||||
|
|
||||||
GUI_LoadFinish(Stepped, Gui)
|
GUI_LoadFinish(Stepped, Gui)
|
||||||
|
|||||||
@@ -6,20 +6,10 @@ local load_elapse_start = os.clock()
|
|||||||
|
|
||||||
local ReplicatedFirst = game:GetService("ReplicatedFirst")
|
local ReplicatedFirst = game:GetService("ReplicatedFirst")
|
||||||
local Players = game:GetService("Players")
|
local Players = game:GetService("Players")
|
||||||
local Storage = game:GetService("ReplicatedStorage")
|
|
||||||
|
|
||||||
local DisabledInStudio = false
|
local DisabledInStudio = game:GetService("RunService"):IsStudio()
|
||||||
local IntroGui = nil
|
local IntroGui = nil
|
||||||
|
|
||||||
local function LoadedBind()
|
|
||||||
local Bind_Completed = Instance.new("BindableFunction")
|
|
||||||
Bind_Completed.Name = "LoadingComplete"
|
|
||||||
Bind_Completed.Parent = Storage:WaitForChild("Client")
|
|
||||||
Bind_Completed.OnInvoke = function()
|
|
||||||
return game:IsLoaded()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function LoadingIntroGUI()
|
local function LoadingIntroGUI()
|
||||||
ReplicatedFirst:RemoveDefaultLoadingScreen()
|
ReplicatedFirst:RemoveDefaultLoadingScreen()
|
||||||
|
|
||||||
@@ -46,6 +36,6 @@ end
|
|||||||
|
|
||||||
if not DisabledInStudio then
|
if not DisabledInStudio then
|
||||||
LoadingIntroGUI()
|
LoadingIntroGUI()
|
||||||
|
else
|
||||||
|
script:Destroy()
|
||||||
end
|
end
|
||||||
|
|
||||||
LoadedBind()
|
|
||||||
@@ -61,9 +61,9 @@ export type LanternsTree = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type LightSwitchProperties = {
|
export type LightSwitchProperties = {
|
||||||
Switch: BasePart?,
|
Switch: Instance?,
|
||||||
Lights: {BasePart}?,
|
Lights: {Instance}?,
|
||||||
LightSources: {PointLight | SpotLight}?,
|
LightSources: {Instance}?,
|
||||||
Prompt: ProximityPrompt?,
|
Prompt: ProximityPrompt?,
|
||||||
ClickSound: Sound?,
|
ClickSound: Sound?,
|
||||||
ColorActivated: Color3?,
|
ColorActivated: Color3?,
|
||||||
@@ -288,10 +288,10 @@ function Tags:__Interactables()
|
|||||||
ptr.Lights = Inst
|
ptr.Lights = Inst
|
||||||
else
|
else
|
||||||
ptr.Lights = {}
|
ptr.Lights = {}
|
||||||
table.insert(ptr.Lights :: {BasePart}, Inst :: BasePart)
|
table.insert(ptr.Lights :: {Instance}, Inst)
|
||||||
end
|
end
|
||||||
elseif InteractType == Enums.InteractType.LightSource then
|
elseif InteractType == Enums.InteractType.LightSource then
|
||||||
ptr.LightSources = {}
|
ptr.LightSources = (type(Inst) == "table" and Inst or {Inst :: Instance}) :: {Instance}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user