big commit

This commit is contained in:
2024-02-08 18:59:42 -05:00
commit 699fe50fea
38 changed files with 2327 additions and 0 deletions

View File

@@ -0,0 +1,114 @@
local Bobbing = {}
Bobbing.__index = Bobbing
Bobbing.TurnAlpha = 0.050
Bobbing.LeanMultiplier = 1.7
Bobbing.SwayMultiplier = 1.5
Bobbing.AnimationAlpha = 0.5
Bobbing.MaxGimbalLockY = 65
Bobbing.AnimationSpeed = 200
Bobbing.Tick = 0
Bobbing.ForceStop = false
type AnimationsMap = {[string]: (tick: number, dt: number) -> Euler}
local Animations: AnimationsMap = {}
type Euler = CFrame
type HumanoidRootPart = BasePart
local UIS = game:GetService("UserInputService")
local CN = CFrame.new
local ANG = CFrame.Angles
local CameraLean = CN()
local Animation = CN()
function Bobbing.constructor(HumanoidRootPart: HumanoidRootPart, CurrentCamera: Camera, Humanoid: Humanoid)
return setmetatable({
HumanoidRootPart = HumanoidRootPart,
CurrentCamera = CurrentCamera,
Humanoid = Humanoid
}, Bobbing)
end
type deltatime = number
type tick = number
type EulerValue = number
function Animations.Idle(t: tick, dt: deltatime)
return ANG(
math.rad(math.cos(t/80)/(Bobbing.AnimationSpeed+50)),
math.rad(math.sin(t/50)/Bobbing.AnimationSpeed),
math.rad(math.sin(t/70)/(Bobbing.AnimationSpeed-50))
)
end
function Animations.Walk(t: tick, dt: deltatime)
-- return ANG(
-- math.rad(-10*math.cos(t)/2),
-- 0,
-- math.rad(5*math.cos(t)/2)
-- )
return ANG(
0,
0,
0
)
end
function Animations.Stop()
return ANG(0,0,0)
end
function Animations.Falling()
return ANG(0,0,0)
end
local function maxmin(min: number, mid: number, max: number): number
return math.max(min, math.min(mid, max))
end
local function Camera_YArc(Camera: Camera): EulerValue --stop Euler gimbal lock when you're looking directly up or down
local EulerY,_,_ = Camera.CFrame.Rotation:ToEulerAnglesYXZ()
return math.abs(math.deg(EulerY))
end
local function CameraAnimation(self, dt: deltatime)
--crying
Bobbing.Tick += 1
local Root: BasePart = self.HumanoidRootPart
local Velocity: Vector3 = Root:GetVelocityAtPosition(Root.Position)
local RootMagnitude: number = Velocity.Magnitude
--go go boolean algebra
local MaxMinY: boolean = Camera_YArc(self.CurrentCamera)>Bobbing.MaxGimbalLockY --TODO: instead, make this an equation so it will just subtract from the existing animation radians
local ForceStop: boolean = Bobbing.ForceStop and "Stop"
local AnimationType: string = ForceStop or RootMagnitude>1 and "Walk" or (not MaxMinY and "Idle" or "Stop")
local CurrentAnimation: CFrame = Animations[AnimationType](Bobbing.Tick, dt)
--"Lerp" so the transitions between walking and idling are smoothed instead of instant
return Animation:Lerp(CurrentAnimation, Bobbing.AnimationAlpha)
end
function Bobbing:Frame(dt: number)
local Camera = self.CurrentCamera
local Humanoid = self.Humanoid
local CameraCF = Camera.CFrame
Animation = CameraAnimation(self, dt)
--Lean the camera based on looking and moving direction(s)
local MouseDelta = UIS:GetMouseDelta()
local LeanDegree_Roll = -CameraCF.RightVector:Dot(Humanoid.MoveDirection)*Bobbing.LeanMultiplier
--Jump?!
--local LeanDegree_Pitch = -CameraCF.UpVector:Dot(Humanoid.MoveDirection)*Bobbing.LeanMultiplier
local LeanMult_Roll = maxmin(-Bobbing.SwayMultiplier, LeanDegree_Roll-MouseDelta.X, Bobbing.SwayMultiplier)
CameraLean = CameraLean:Lerp(ANG(0, 0, math.rad(LeanMult_Roll)), Bobbing.TurnAlpha)
Camera.CFrame *= Animation*CameraLean
end
return Bobbing

View File

@@ -0,0 +1,41 @@
local Camera = {}
local FakeCamera = {}
Camera.__index = Camera
FakeCamera.__index = FakeCamera
local RS = game:GetService("RunService")
local Bobbing = require(script:WaitForChild("Bobbing"))
type FakeCamera = BasePart
function Camera.constructor(CurrentCamera: Camera, HumanoidRootPart: BasePart, Humanoid: Humanoid)
local self = {}
self.CameraFPS = false
self.CurrentCamera = CurrentCamera
self.HumanoidRootPart = HumanoidRootPart
self.BobbingCamera = Bobbing.constructor(HumanoidRootPart, CurrentCamera, Humanoid)
return setmetatable(self, Camera)
end
function Camera:EnableBobbing()
if not self.CameraFPS then
RS:BindToRenderStep("CameraAnimations", Enum.RenderPriority.Camera.Value+1, function(dt)
self.BobbingCamera:Frame(dt)
end)
self.CameraFPS = true
else
print("Character Camera: Cannot call EnableBobbing while its active", debug.traceback())
end
end
function Camera:DisableBobbing()
if self.CameraFPS then
RS:UnbindFromRenderStep("CameraAnimations")
self.CameraFPS = false
else
print("Character Camera: DisableBobbing was called before EnableBobbing", debug.traceback())
end
self.CurrentCamera.CFrame *= CFrame.Angles(0,0,0)
end
return Camera

View File

@@ -0,0 +1,37 @@
local CrouchModule = {
StandHeight = 2.1,
CrouchHeight = .6,
WalkSpeedMultiplier = 6,
CrouchSpeed = .2
}
CrouchModule.__index = CrouchModule
local Tween = require(game:GetService("ReplicatedStorage"):WaitForChild("Tween"))
function CrouchModule.constructor(Humanoid: Humanoid)
return setmetatable({
Humanoid = Humanoid
}, CrouchModule)
end
local CrouchTween = Tween.constructor()
function CrouchModule:Crouch(StandingWalkSpeed: number)
local Easing = TweenInfo.new(CrouchModule.CrouchSpeed, Enum.EasingStyle.Linear)
CrouchTween:Start(self.Humanoid, {
HipHeight = CrouchModule.CrouchHeight,
WalkSpeed = math.max(1, StandingWalkSpeed-CrouchModule.WalkSpeedMultiplier)
}, Easing)
end
function CrouchModule:Stand(CrouchingWalkSpeed: number)
local Easing = TweenInfo.new(CrouchModule.CrouchSpeed, Enum.EasingStyle.Linear)
CrouchTween:Start(self.Humanoid, {
HipHeight = CrouchModule.StandHeight,
WalkSpeed = math.max(1, CrouchingWalkSpeed+CrouchModule.WalkSpeedMultiplier)
}, Easing)
end
return CrouchModule

View File

@@ -0,0 +1,21 @@
local HumanoidModule = {}
HumanoidModule.__index = HumanoidModule
type WalkSpeed = number?
type JumpHeight = number?
function HumanoidModule.constructor(Humanoid: Humanoid)
return setmetatable({
Humanoid = Humanoid
}, HumanoidModule)
end
function HumanoidModule:SetWalkSpeed(Speed: WalkSpeed)
self.Humanoid.WalkSpeed = Speed or 10
end
function HumanoidModule:SetJumpHeight(Height: JumpHeight)
self.Humanoid.JumpHeight = Height or 7.2
end
return HumanoidModule

View File

@@ -0,0 +1,21 @@
local HumanoidRPSettings = {}
HumanoidRPSettings.__index = HumanoidRPSettings
function HumanoidRPSettings.constructor(HumanoidRootPart: BasePart)
return setmetatable({
HumanoidRootPart = HumanoidRootPart
}, HumanoidRPSettings)
end
function HumanoidRPSettings:DisableRobloxSounds()
local HRP_objects = self.HumanoidRootPart:GetChildren()
for i = 1, #HRP_objects do
local Object = HRP_objects[i]
if Object:IsA("Sound") then
Object.Volume = 0
end
end
end
return HumanoidRPSettings

View File

@@ -0,0 +1,46 @@
local Spine = {
Running = false
}
Spine.__index = Spine
local Storage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Delta = require(Storage:WaitForChild("Delta"))
local Player = Players.LocalPlayer
local CharacterShared = _G.include(script, "CharacterShared")
type CurrentCamera = Camera
type struct_Spine = {
Remote: UnreliableRemoteEvent,
CurrentCamera: CurrentCamera
}
type CharacterSharedFolder = Folder
function Spine.constructor(CurrentCamera: CurrentCamera)
local self: struct_Spine = {}
self.Remote = CharacterShared:WaitForChild("SpineStream")
self.CurrentCamera = CurrentCamera
return setmetatable(self, Spine)
end
function Spine:Enable()
Spine.Running = true
while Spine.Running do
local IsFirstPerson = Player.CameraMode == Enum.CameraMode.LockFirstPerson
self.Remote:FireServer(self.CurrentCamera.CFrame, IsFirstPerson)
Delta:time()
end
end
function Spine:Disable()
Spine.Running = false
Delta:time()
end
return Spine

View File

@@ -0,0 +1,63 @@
local Character = script.Parent
local preprocessor = {}
type CharacterSharedFolder = Folder
function preprocessor.CharacterShared(): CharacterSharedFolder
return script.Parent:WaitForChild("shared")
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())
end
end
local Storage = game:GetService("ReplicatedStorage")
local ClientStorage = Storage:WaitForChild("Client")
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
--We need to wait for the game to load before spamming functionality
repeat
local GameIsLoaded = LoadCompleted:Invoke()
task.wait()
until GameIsLoaded
local HumanoidRPSettings = require(script:WaitForChild("HumanoidRootPart"))
local CameraModule = require(script:WaitForChild("Camera"))
local CrouchModule = require(script:WaitForChild("Crouch"))
local HumanoidModule = require(script:WaitForChild("Humanoid"))
local SpineModule = require(script:WaitForChild("SpineKinematics"))
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 function CrouchFeature()
local CrouchConstructor = CrouchModule.constructor(Humanoid)
local CourchBindMap = BindModule.constructor()
CourchBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
CrouchConstructor:Crouch(10)
end)
CourchBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
CrouchConstructor:Stand(5)
end)
end
HumanoidSettings:SetWalkSpeed()
HumanoidSettings:SetJumpHeight()
HRPSettings:DisableRobloxSounds()
CameraConsturctor:EnableBobbing()
SpineMovement:Enable()
CrouchFeature()

View File

@@ -0,0 +1,35 @@
--This really should be only client
local Shadows = {}
Shadows.__index = Shadows
type Character = Model
function Shadows.constructor(Character: Character)
return setmetatable({
Character = Character
}, Shadows)
end
function Shadows:PartToggle(Instance: BasePart, CastingShadow: boolean)
if Instance:IsA("BasePart") then --not 100%, but im sure types are only in effect on the editor side
Instance.CastShadow = CastingShadow
end
end
local function CharacterShadows(self, enabled: boolean)
local CharacterDescendants = self.Character:GetDescendants()
for i = 1, #CharacterDescendants do
self:PartToggle(CharacterDescendants[i], enabled)
end
end
function Shadows:on()
CharacterShadows(self, true)
end
function Shadows:off()
CharacterShadows(self, false)
end
return Shadows

View File

@@ -0,0 +1,84 @@
local Spine = {
Enabled = true,
Multiplier = .5
}
Spine.__index = Spine
type Head = BasePart
type UpperTorso = BasePart
type Neck = Motor6D
type NeckC0 = CFrame
type WaistC0 = CFrame
type struct_Spine = {
Remote: UnreliableRemoteEvent,
Head: Head,
UpperTorso: UpperTorso,
Neck: Neck,
NeckC0: NeckC0,
WaistC0: WaistC0
}
local Remote = Instance.new("UnreliableRemoteEvent")
Remote.Name = "SpineStream"
Remote.Parent = _G.include(script, "CharacterShared")
function Spine.constructor(Head: Head, UpperTorso: UpperTorso)
local self: struct_Spine = {}
self.Head = Head
self.UpperTorso = UpperTorso
self.Neck = Head:WaitForChild("Neck")
self.Waist = UpperTorso:WaitForChild("Waist")
self.Remote = Remote
self.NeckC0 = self.Neck.C0
self.WaistC0 = self.Waist.C0
return setmetatable(self, Spine)
end
type struct_SpineMovement = {
Neck: CFrame,
Waist: CFrame
}
local function SpineMovement(self, CameraCFrame: CFrame, IsFirstPerson: boolean): struct_SpineMovement
local HeadCFrame: CFrame = self.Head.CFrame
local TorsoPosition: Vector3 = self.UpperTorso.Position
local TorsoLookVector: Vector3 = self.UpperTorso.CFrame.LookVector
local HeadPosition: Vector3 = HeadCFrame.Position
local CameraPosition: Vector3 = CameraCFrame.Position
local HeadDelta: Vector3 = HeadPosition-CameraPosition
local TorsoDeltaNormal: Vector3 = (TorsoPosition-CameraPosition).Unit
local HeadDeltaNormal: Vector3 = HeadDelta.Unit
local HeadDeltaMagnitude: number = HeadDelta.Magnitude
local arc = Spine.Multiplier*math.asin(HeadDelta.Y/HeadDeltaMagnitude)
local Neck = CFrame.Angles(arc, 0, 0)
local Waist = CFrame.Angles(arc, 0, 0)
if not IsFirstPerson then
--Make this less cringe at some point, combine the dot product into the equation
local LookingAtSelf = CameraCFrame.LookVector:Dot(HeadCFrame.LookVector)<0 --Make our head face the camera if we are looking at ourself
local HeadCrossDelta = Spine.Multiplier*HeadDeltaNormal:Cross(TorsoLookVector).Y
local TorsoCrossDelta = Spine.Multiplier*TorsoDeltaNormal:Cross(TorsoLookVector).Y
Neck*=CFrame.Angles(0, HeadCrossDelta, 0)
Waist*=CFrame.Angles(0, LookingAtSelf and TorsoCrossDelta or -TorsoCrossDelta, 0)
end
return {
Neck = Neck,
Waist = Waist
}
end
function Spine:Move(CameraCFrame: CFrame, IsFirstPerson: boolean)
local SpineIK = SpineMovement(self, CameraCFrame, IsFirstPerson)
self.Neck.C0 = self.Neck.C0:Lerp(self.NeckC0*SpineIK.Neck, .9)
self.Waist.C0 = self.Waist.C0:Lerp(self.WaistC0*SpineIK.Waist, .9)
end
return Spine

View File

@@ -0,0 +1,52 @@
local Character = script.Parent
local preprocessor = {}
--Create the character shared directory here
local CharacterShared = Instance.new("Folder")
CharacterShared.Name = "shared"
CharacterShared.Parent = Character
type CharacterSharedFolder = Folder
function preprocessor.CharacterShared(): CharacterSharedFolder
return CharacterShared
end
_G.include = function(this: LuaSourceContainer, FunName: string, ...)
--its not extremely necessary to have security for the server-side
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())
end
end
local Players = game:GetService("Players")
local Shadows = require(script:WaitForChild("Shadows"))
local SpineModule = require(script:WaitForChild("SpineKinematics"))
local Head = Character:WaitForChild("Head")
local UpperTorso = Character:WaitForChild("UpperTorso")
local LocalPlayer = Players:GetPlayerFromCharacter(Character)
local CharacterShadows = Shadows.constructor(Character)
local Spine = SpineModule.constructor(Head, UpperTorso)
CharacterShadows:off() --I plan having 2 player support and characters block a ton of light
Character.DescendantAdded:Connect(function(Instance)
task.wait() --Wait for the instance to properly replicate?
CharacterShadows:PartToggle(Instance, false)
end)
Spine.Remote.OnServerEvent:Connect(function(Messenger: Player, CameraPosition: Vector3, IsFirstPerson: boolean)
if Messenger.UserId == LocalPlayer.UserId then
if Spine.Enabled then
Spine:Move(CameraPosition, IsFirstPerson)
end
else
warn("hacker")
end
end)

View File

@@ -0,0 +1,80 @@
local CoreGuis = {
AllowReset = false,
AllowEmotes = true,
AllowBackpack = false,
AllowPlayerList = false
}
CoreGuis.__index = CoreGuis
local SG = game:GetService("StarterGui")
local Players = game:GetService("Players")
type CustomCoreGuiEnums = {Enum.CoreGuiType}
local function CustomCoreGuiEnums(): CustomCoreGuiEnums
local CoreElements = Enum.CoreGuiType:GetEnumItems()
table.remove(CoreElements, table.find(CoreElements, Enum.CoreGuiType.All))
if CoreGuis.AllowBackpack then
table.remove(CoreElements, table.find(CoreElements, Enum.CoreGuiType.Backpack))
end
if CoreGuis.AllowEmotes then
table.remove(CoreElements, table.find(CoreElements, Enum.CoreGuiType.EmotesMenu))
end
if CoreGuis.AllowPlayerList then
table.remove(CoreElements, table.find(CoreElements, Enum.CoreGuiType.PlayerList))
end
return CoreElements
end
local function ResetEnabled(enabled: boolean)
--Roblox actually doesn't register this fast enough so we gotta resort to cringe tactics
repeat
local PossibleMemoryLeak = pcall(SG.SetCore, SG, "ResetButtonCallback", enabled)
task.wait()
until PossibleMemoryLeak
end
function CoreGuis:On()
local Elements = CustomCoreGuiEnums()
for i = 1, #Elements do
SG:SetCoreGuiEnabled(Elements[i], true)
end
ResetEnabled(CoreGuis.AllowReset)
end
function CoreGuis:Off()
if #Players:GetPlayers()>1 then
--Enable multiplayer features
self:On()
local PlayerAdded --So weird...
PlayerAdded = Players.PlayerAdded:Connect(function(_)
if #Players:GetPlayers()>1 then
self:On()
--We dont need to listen for players anymore
PlayerAdded:Disconnect()
end
end)
else
local Elements = CustomCoreGuiEnums()
for i = 1, #Elements do
SG:SetCoreGuiEnabled(Elements[i], false)
end
end
ResetEnabled(CoreGuis.AllowReset)
end
function CoreGuis:ForceOff()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
ResetEnabled(false)
end
function CoreGuis:ForceOn()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
ResetEnabled(true)
end
return CoreGuis

View File

@@ -0,0 +1,8 @@
local GuiModule = {}
GuiModule.__index = GuiModule
local GuiService = game:GetService("GuiService")
return GuiModule

View File

@@ -0,0 +1,13 @@
local Mouse = {}
local UIS = game:GetService("UserInputService")
function Mouse:DisablePointer()
UIS.MouseIconEnabled = false
end
function Mouse:EnablePointer()
UIS.MouseIconEnabled = true
end
return Mouse

View File

@@ -0,0 +1,31 @@
local CrosshairModule = {
Icon = "rbxassetid://12643750723"
}
CrosshairModule.__index = CrosshairModule
--Use a custom crosshair so we can do effects to it
type rbxassetid = string
function CrosshairModule.constructor(PlayerGui: PlayerGui)
local Screen = PlayerGui:WaitForChild("Crosshair")
local Icon = Screen:WaitForChild("ImageLabel")
return setmetatable({
Screen = Screen,
Icon = Icon
}, CrosshairModule)
end
function CrosshairModule:Enable()
self.Screen.Enabled = true
end
function CrosshairModule:Disable()
self.Screen.Enabled = false
end
function CrosshairModule:Change(ID: rbxassetid)
self.Icon.Image = ID or CrosshairModule.Icon
end
return CrosshairModule

View File

@@ -0,0 +1,27 @@
local VignetteModule = {
Enabled = false,
Icon = "rbxassetid://4576475446"
}
VignetteModule.__index = VignetteModule
function VignetteModule.constructor(PlayerGui: PlayerGui)
local Screen = PlayerGui:WaitForChild("Vignette")
local Icon = Screen:WaitForChild("ImageLabel")
return setmetatable({
Screen = Screen,
Icon = Icon
}, VignetteModule)
end
function VignetteModule:Enable()
VignetteModule.Enabled = true
self.Screen.Enabled = true
end
function VignetteModule:Disable()
VignetteModule.Enabled = false
self.Screen.Enabled = false
end
return VignetteModule

View File

@@ -0,0 +1,51 @@
local UI = script:WaitForChild("UI")
local CrosshairSettings = require(UI:WaitForChild("Crosshair"))
local VignetteSettings = require(UI:WaitForChild("Vignette"))
local CoreGuis = require(script:WaitForChild("CoreGuis"))
local Mouse = require(script:WaitForChild("Mouse"))
local Players = game:GetService("Players")
local Storage = game:GetService("ReplicatedStorage")
local ClientStorage = Storage:WaitForChild("Client")
local LoadCompleted = ClientStorage:WaitForChild("LoadingComplete")
local KeyBindsModule = require(ClientStorage:WaitForChild("KeyBinds"))
local CameraSettings = require(ClientStorage:WaitForChild("Camera"))
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
--We need to wait for the game to load before spamming functionality
repeat
local GameIsLoaded = LoadCompleted:Invoke()
task.wait()
until GameIsLoaded
local CurrentCamera = nil
repeat
task.wait()
CurrentCamera = workspace.CurrentCamera
until CurrentCamera
local Vignette = VignetteSettings.constructor(PlayerGui)
local Camera = CameraSettings.constructor(CurrentCamera, Player)
local Crosshair = CrosshairSettings.constructor(PlayerGui)
--Keybinds
local function CameraBinds()
local CameraBindMap = KeyBindsModule.constructor()
CameraBindMap:AddInputBegan({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
Camera:ZoomIn(Vignette, Crosshair)
end)
CameraBindMap:AddInputEnded({Enum.KeyCode.C, Enum.KeyCode.Z}, function()
Camera:ZoomOut(Vignette, Crosshair)
end)
end
CoreGuis:Off()
Camera:FirstPerson()
Mouse:DisablePointer()
Crosshair:Enable()
CameraBinds()

121
src/load/intro/IntroGui.lua Normal file
View File

@@ -0,0 +1,121 @@
--Not a good idea to call modules from other services here
--Who said UI on here cant look like a web design lole,
local RS = game:GetService("RunService")
local Storage = game:GetService("ReplicatedStorage")
local LoadingFun = true
local function GuiDependencies(IntroGui: ScreenGui): typeof(GuiDependencies)
IntroGui.Enabled = true
local Frame = IntroGui:WaitForChild("Frame")
local Viewport = Frame:WaitForChild("ViewportFrame")
local FrameGradient = Frame:WaitForChild("UIGradient")
local TextShadow = Frame:WaitForChild("TextShadow")
local FrameworkText = Frame:WaitForChild("Framework")
local SandboxText = Frame:WaitForChild("Sandbox")
local DeveloperText = Frame:WaitForChild("Developer")
local ShadowGradient = TextShadow:WaitForChild("UIGradient")
local ViewportCamera = Instance.new("Camera")
ViewportCamera.FieldOfView = 50
ViewportCamera.Parent = Viewport
Viewport.CurrentCamera = ViewportCamera
local GL_Cube = Viewport:WaitForChild("GL_Cube")
return {
IntroGui = IntroGui,
Frame = Frame,
Viewport = Viewport,
ViewportCamera = ViewportCamera,
GL_Cube = GL_Cube,
FrameGradient = FrameGradient,
TextShadow = TextShadow,
ShadowGradient = ShadowGradient,
FrameworkText = FrameworkText,
SandboxText = SandboxText,
DeveloperText = DeveloperText
}
end
type GUIs = typeof(GuiDependencies)
type Stepped = RBXScriptConnection
local function GUI_LoadFinish(Stepped: Stepped, Gui: GUIs) --We can now access the framework
--Image if we had HTML and CSS...
local Tween = require(Storage:WaitForChild("Tween"))
local EaseStyle = Enum.EasingStyle.Linear
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.Frame, {
BackgroundTransparency = 1
})
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.DeveloperText, {
TextTransparency = 1
})
local ViewportFrame_Constructor = Tween.constructor(TweenInfo.new(3, EaseStyle), Gui.Viewport, {
Position = UDim2.fromScale(0.5, 2) --Guaranteed off screen
})
FrameTween_Constructor:Start()
DeveloperTween_Constructor:Start()
local ViewportTween = ViewportFrame_Constructor:Start() --The longest tween
--Text deleting effect
task.spawn(function()
local sandbox_text_len = #Gui.SandboxText.Text
for i = sandbox_text_len, 1, -1 do --"A sandbox experience" has the longest text
local rhpid_text_len = #Gui.FrameworkText.Text
Gui.SandboxText.Text = Gui.SandboxText.Text:sub(1,i-1)
if rhpid_text_len ~= 0 then
Gui.FrameworkText.Text = Gui.FrameworkText.Text:sub(1,i-1)
Gui.TextShadow.Text = Gui.FrameworkText.Text --heh hack
end
task.wait(.05)
end
end)
ViewportTween.Completed:Wait()
Stepped:Disconnect()
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
end
type GL_Cube = BasePart
type GL_Side = BasePart
type LoadFinishedSignal = RBXScriptSignal
return function(IntroGui: ScreenGui, load_elapse_start: number): LoadFinishedSignal
local Gui = GuiDependencies(IntroGui)
Gui.ViewportCamera.CFrame = CFrame.lookAt(Gui.GL_Cube.Position-Vector3.new(3,-2.5,5), Gui.GL_Cube.Position)
local Cube_CF = Gui.GL_Cube.CFrame
local Stepped = RS.Stepped:Connect(function(delta, dt)
--Magic number heaven
local d2 = delta*10
Gui.FrameGradient.Rotation=d2
Gui.ShadowGradient.Rotation=d2*4
Gui.GL_Cube.CFrame = Cube_CF*CFrame.Angles(math.rad(100*math.cos(delta/8)), 0, delta/2)
end)
task.spawn(function()
if not game:IsLoaded() then
game.Loaded:Wait()
end
local load_elapse = os.clock()-load_elapse_start
if LoadingFun then
task.wait(math.max(0, 3-load_elapse)) --Only if you take longer than or exactly 3 seconds to load
end
print(load_elapse)
GUI_LoadFinish(Stepped, Gui)
end)
end

View File

@@ -0,0 +1,47 @@
local load_elapse_start = os.clock()
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local Players = game:GetService("Players")
local Storage = game:GetService("ReplicatedStorage")
local DisabledInStudio = game:GetService("RunService"):IsStudio()
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 RunIntroGui = require(script:WaitForChild("IntroGui"))
local Player = Players.LocalPlayer
if not Player then
repeat
Player = Players.LocalPlayer
task.wait()
until Player
end
local PlayerGui = Player:WaitForChild("PlayerGui")
IntroGui = PlayerGui:WaitForChild("rhpidframework_intro", 10)
if IntroGui then
--Let the magic begin
RunIntroGui(IntroGui, load_elapse_start)
else
warn("Waited 10 seconds for the intro gui without success")
end
end
if not DisabledInStudio then
LoadingIntroGUI()
end
LoadedBind()
ReplicatedFirst:RemoveDefaultLoadingScreen()

View File

@@ -0,0 +1,6 @@
local Leveling: {[number]: number} = {
[1] = 13.205,
[10] = 239.216
}
return Leveling

View File

@@ -0,0 +1,24 @@
return function(ElevatorBox: BasePart, StartPosition: Vector3)
local BoxAttachment = Instance.new("Attachment")
BoxAttachment.Parent = ElevatorBox
local BoxAlignPosition = Instance.new("AlignPosition")
BoxAlignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment
BoxAlignPosition.Attachment0 = BoxAttachment
BoxAlignPosition.MaxForce = math.huge
BoxAlignPosition.Position = StartPosition
-- BoxAlignPosition.RigidityEnabled = true
-- Lines below are disabled with RigidityEnabled true
BoxAlignPosition.Responsiveness = 5
BoxAlignPosition.MaxVelocity = 10
--
BoxAlignPosition.Parent = ElevatorBox
local BoxAlignOrientation = Instance.new("AlignOrientation")
BoxAlignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
BoxAlignOrientation.Attachment0 = BoxAttachment
BoxAlignOrientation.RigidityEnabled = true
BoxAlignOrientation.CFrame = CFrame.new(0,0,0)*CFrame.fromOrientation(0,0,0)
BoxAlignOrientation.Parent = ElevatorBox
return BoxAttachment, BoxAlignPosition, BoxAlignOrientation
end

View File

@@ -0,0 +1,122 @@
local Doors = {
Closed = true,
DontLeakMemory = nil
}
Doors.__index = Doors
local RS = game:GetService("RunService")
local Storage = game:GetService("ReplicatedStorage")
local Tween = require(Storage:WaitForChild("Tween"))
local Tags = require(Storage:WaitForChild("Tags"))
function Doors.constructor(ElevatorBox: BasePart, ElevatorDoor1: BasePart, ElevatorDoor2: BasePart, ElevatorDoorSensor: Folder)
local DoorTween1 = Tween.constructor(nil, ElevatorDoor1)
local DoorTween2 = Tween.constructor(nil, ElevatorDoor2)
local DoorSensor: {[string]: BasePart} = {
Start = ElevatorDoorSensor:WaitForChild("Start"),
End = ElevatorDoorSensor:WaitForChild("End")
}
return setmetatable({
DoorTween1 = DoorTween1,
DoorTween2 = DoorTween2,
DoorSensor = DoorSensor,
ElevatorBox = ElevatorBox,
ElevatorDoor1 = ElevatorDoor1,
ElevatorDoor2 = ElevatorDoor2
}, Doors)
end
local function DoorsAnimation(self, opening: boolean?, stopping: boolean?)
local ElevatorDoor1_P = self.ElevatorDoor1.Position
local ElevatorDoor2_P = self.ElevatorDoor2.Position
local Door1Stopped_X = stopping and Vector3.xAxis*ElevatorDoor1_P.X-Vector3.xAxis*2.9 or Vector3.xAxis*2.9
local Door2Stopped_X = stopping and Vector3.xAxis*ElevatorDoor2_P.X-Vector3.xAxis*6 or Vector3.xAxis*6
local Door1Tween = self.DoorTween1:Start(nil, {
Position = opening and ElevatorDoor1_P+Door1Stopped_X or ElevatorDoor1_P-Door1Stopped_X
}, TweenInfo.new(
opening and 3.5 or 5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut
))
local Door2Tween = self.DoorTween2:Start(nil, {
Position = opening and ElevatorDoor2_P+Door2Stopped_X or ElevatorDoor2_P-Door2Stopped_X
}, TweenInfo.new(
opening and 3.5 or 5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut
))
if Doors.DontLeakMemory then
Doors.DontLeakMemory:Disconnect()
end
Doors.DontLeakMemory = self:__Sensor(Door1Tween, Door2Tween)
return Door1Tween, Door2Tween
end
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true --sure ig
--heh..
local RayIgnoring = {}
local workspace_items = workspace:GetChildren()
for n: number = 1, #workspace_items do
if workspace_items[n]:IsA("Folder") then
table.insert(RayIgnoring, workspace_items[n])
end
end
function Doors:__Sensor(DoorTween1, DoorTween2): nil | RBXScriptSignal
local Step = nil
if Doors.Closed then
raycastParams.FilterDescendantsInstances = {self.ElevatorBox, table.unpack(RayIgnoring)}
Step = RS.Stepped:Connect(function(_delta, _dt)
print("Running")
local DoorSensor = workspace:Raycast(self.DoorSensor.Start.Position, self.DoorSensor.End.Position, raycastParams)
if DoorSensor and DoorSensor.Instance and DoorSensor.Instance:IsA("BasePart") then
Step:Disconnect()
print("Hit=",DoorSensor.Instance:GetFullName())
DoorTween1:Pause()
DoorTween2:Pause()
task.wait(1) --elevator at work has this delay
DoorsAnimation(self, true, true)
-- DoorTween1:Destroy()
-- DoorTween2:Destroy()
end
end)
end
return Step
end
function Doors:Opening(opening: boolean?)
--short circuiting central
if opening then
if Doors.Closed then
Doors.Closed = not Doors.Closed
else
print("Doors are already closed, doing nothing")
return
end
else
if not Doors.Closed then
Doors.Closed = not Doors.Closed
else
print("Doors are already open, doing nothing")
return
end
end
self.ElevatorBox.Anchored = true
local Door1Tween, Door2Tween = DoorsAnimation(self, opening)
Door2Tween.Completed:Wait()
if Doors.DontLeakMemory then
Doors.DontLeakMemory:Disconnect()
end
self.ElevatorBox.Anchored = false
end
return Doors

View File

@@ -0,0 +1,41 @@
local Elevator = script.Parent
local Elevators = Elevator.Parent
local RS = game:GetService("ReplicatedStorage")
local Tags = require(RS:WaitForChild("Tags"))
local Leveling = require(Elevators:WaitForChild("Leveling"))
local Doors = require(Elevator:WaitForChild("Doors"))
local ElevatorBox_1960: BasePart = Tags.ElevatorMover_1960
local ElevatorBoxStartPos = ElevatorBox_1960.Position
local ElevatorMover = require(Elevators:WaitForChild("Mover"))
local _BoxAttachment, BoxAlignPosition, _BoxAlignOrientation = ElevatorMover(ElevatorBox_1960, ElevatorBoxStartPos)
local ElevatorBox: BasePart = Tags.ElevatorMover_1960
local ElevatorDoor1: BasePart = Tags.ElevatorDoor_1960_1
local ElevatorDoor2: BasePart = Tags.ElevatorDoor_1960_2
local ElevatorDoorSensor: Folder = Tags.ElevatorDoor_Sensor_1960
local ElevatorDoors = Doors.constructor(ElevatorBox, ElevatorDoor1, ElevatorDoor2, ElevatorDoorSensor)
local function MoveFloors(level: number)
local ElevatorBoxCurrentPos = ElevatorBox.Position
--Its gonna use raycasting inside of the shaft to detect when its near and when to stop
BoxAlignPosition.Position = Vector3.new(ElevatorBoxCurrentPos.X, level, ElevatorBoxCurrentPos.Z)
end
local function GoTo_Level(requested_level: number)
local level: number = Leveling[requested_level]
if level then
MoveFloors(level)
end
end
--"it will solve the issue of exploiters messing with the elevator"
ElevatorBox_1960:SetNetworkOwner(nil)
task.wait(2)
ElevatorDoors:Opening(true)
task.wait(2)
ElevatorDoors:Opening(false)

View File

@@ -0,0 +1,83 @@
--All debugging objects such as light source indicating objects will be turned invisible
local Players = game:GetService("Players")
export type Entities = {
IndexedEntities: {Instance}
}
local StudioEntities: Entities = {
IndexedEntities = {}
}
local function HidePart(Part: BasePart, enabled: boolean)
Part.Transparency = enabled and 1 or .9
Part.CanCollide = false
Part.CastShadow = false
end
local function HideBarrierCollision(Part: BasePart, enabled: boolean)
Part.Transparency = enabled and 1 or .9
Part.CastShadow = false
Part.CanCollide = true
end
local function HideRaycastContainers(Folder: Folder, enabled: boolean)
local End = Folder:WaitForChild("End")
local Start = Folder:WaitForChild("Start")
End.CanCollide = false
End.CastShadow = false
End.Transparency = enabled and 1 or .9
Start.CanCollide = false
Start.CastShadow = false
Start.Transparency = enabled and 1 or .9
end
local EditorEntities = {
["LightSource"] = HidePart,
["PulleyRopeContact"] = HidePart,
["BarrierCollision"] = HideBarrierCollision,
["StairSource"] = HideBarrierCollision,
["RaycastContainer"] = HideRaycastContainers
}
function StudioEntities.indexAll(enabled: boolean): Entities
if #StudioEntities.IndexedEntities == 0 then
--Run when the server starts
local WorkspaceEnt = workspace:GetDescendants()
for i = 1, #WorkspaceEnt do
local Item: Instance = WorkspaceEnt[i]
local Case: Instance = EditorEntities[Item.Name]
if Case then
table.insert(StudioEntities.IndexedEntities, Item)
Case(Item, enabled)
end
if Item:IsA("BasePart") then --Do micro optimizations
Item.CanTouch = false
elseif Item:IsA("LuaSourceContainer") then --Cant allow scripts outside of the framework
--mini algorthim to see if the script is part of the rhpid-framework character or not
local Model = Item:FindFirstAncestorOfClass("Model")
if not Players:GetPlayerFromCharacter(Model) then
local Path = Item:GetFullName()
pcall(function()
Item.Enabled = false
end)
Item:Destroy()
warn(`Script: "{Item.Name}" ({Item.ClassName}) was removed because it was outside of the rhpid-framework boundries,`, Path)
end
end
end
else
for i = 1, #StudioEntities.IndexedEntities do
local Entity: Instance = EditorEntities[i]
EditorEntities[Entity.Name](Entity, enabled)
end
end
return StudioEntities.IndexedEntities
end
return StudioEntities

View File

@@ -0,0 +1,49 @@
local function Sky(): Sky
local SkyBox = Instance.new("Sky")
SkyBox.MoonAngularSize = 8
SkyBox.MoonTextureId = "rbxassetid://62326944"
SkyBox.SkyboxBk = "rbxassetid://9544505500"
SkyBox.SkyboxDn = "rbxassetid://9544547905"
SkyBox.SkyboxFt = "rbxassetid://9544504852"
SkyBox.SkyboxLf = "rbxassetid://9544547694"
SkyBox.SkyboxRt = "rbxassetid://9544547542"
SkyBox.SkyboxUp = "rbxassetid://9544547398"
SkyBox.SunTextureId = "rbxassetid://5392574622"
SkyBox.StarCount = 200
SkyBox.SunAngularSize = 9
return SkyBox
end
local function Atmosphere(): Atmosphere
local Atmosp = Instance.new("Atmosphere")
Atmosp.Density = .25
Atmosp.Offset = 0
Atmosp.Color = Color3.fromRGB(199, 199, 199)
Atmosp.Decay = Color3.fromRGB(106, 112, 125)
return Atmosp
end
local function Clouds(): Clouds
local _Clouds = Instance.new("Clouds")
_Clouds.Cover = .7
_Clouds.Density = .15
_Clouds.Color = Color3.fromRGB(180,180,180)
return _Clouds
end
export type exports = {
Sky: Sky,
Atmosphere: Atmosphere,
Clouds: Clouds,
}
local export: exports = {
Sky = Sky,
Atmosphere = Atmosphere,
Clouds = Clouds
}
return export

View File

@@ -0,0 +1,55 @@
local Lighting = game:GetService("Lighting")
local Terrain = workspace:WaitForChild("Terrain")
local Sky = require(script:WaitForChild("Sky"))
type LightingProps = { [string]: Color3 | number | boolean | string }
local Lighting_PropsTree: LightingProps = {
["Ambient"] = Color3.fromRGB(40,40,40),
["Brightness"] = 3,
["ColorShift_Bottom"] = Color3.new(0,0,0),
["ColorShift_Top"] = Color3.new(0,0,0),
["EnvironmentDiffuseScale"] = 1,
["EnvironmentSpecularScale"] = .7,
["GlobalShadows"] = true,
["OutdoorAmbient"] = Color3.fromRGB(50,50,50),
["ShadowSoftness"] = 1,
["ClockTime"] = 0,
["GeographicLatitude"] = 0,
["Name"] = "Lighting",
["ExposureCompensation"] = 0,
["FogColor"] = Color3.new(0,0,0),
["FogEnd"] = 100000,
["FogStart"] = 100000,
}
export type Effects = {
ColorCorrection: ColorCorrectionEffect
}
return function(): Effects
Lighting:ClearAllChildren()
Terrain:ClearAllChildren()
--VFX Effects for later
local ColorCorrection = Instance.new("ColorCorrectionEffect")
ColorCorrection.Parent = Lighting
for Light_Prop, Light_Value in Lighting_PropsTree do
local changed, err = pcall(function()
Lighting[Light_Prop] = Light_Value
end)
if not changed then
warn("Server Lighting:", err, debug.traceback())
end
end
Sky.Sky().Parent = Lighting
Sky.Atmosphere().Parent = Lighting
Sky.Clouds().Parent = Terrain
return {
ColorCorrection = ColorCorrection
}
end

View File

@@ -0,0 +1,6 @@
local StarterPlayer = game:GetService("StarterPlayer")
return function()
StarterPlayer.CharacterWalkSpeed = 0
StarterPlayer.CharacterJumpHeight = 0
end

View File

@@ -0,0 +1,3 @@
return function()
workspace.Gravity = 150
end

View File

@@ -0,0 +1,23 @@
local HideEditorEntities = require(script:WaitForChild("EditorEntities"))
local Lighting_Stuff = require(script:WaitForChild("Lighting"))
local Workspace_Stuff = require(script:WaitForChild("Workspace"))
local StarterPlayer_Stuff = require(script:WaitForChild("StarterPlayer"))
local RS = game:GetService("RunService")
local Storage = game:GetService("ReplicatedStorage")
local ServerStorage = Storage:WaitForChild("Server")
local EditorEntities = Instance.new("BindableFunction")
EditorEntities.Name = "StudioIndexedEntities"
EditorEntities.Parent = ServerStorage
local StudioEntities = HideEditorEntities.indexAll(not RS:IsStudio())
StarterPlayer_Stuff()
Lighting_Stuff()
Workspace_Stuff()
EditorEntities.OnInvoke = function(): HideEditorEntities.Entities
return StudioEntities.IndexedEntities
end

View File

@@ -0,0 +1,30 @@
--My versions
type EaseFunction = (n: number) -> number
export type EasingStyles = {
Linear: EaseFunction,
InOutBack: EaseFunction,
OutBounce: EaseFunction
}
local Ease: EasingStyles = {}
--Google straight up gives wrong/bad math
function Ease.Linear(a,b,t)
return a-a*t+b*t
end
local c = 2.59491
function Ease.InOutBack(n)
return n<.5 and 2*n*n*(-c+2*n+2*c*n) or 3*(-1+n)*(-1+n)*(-2-c+2*n+2*c*n)
end
local n1, d1 = 7.5625, 2.75
function Ease.OutBounce(n)
return (n<0.363636 and n*n*n1 or
n<0.727273 and (.75*(1.*d1-2.*n*n1)) or
n<0.909091 and (.9375*(1.*d1-2.4*n*n1)/d1)) or (.984375*(1.*d1-2.66667*n*n1))/d1
end
return Ease

View File

@@ -0,0 +1,98 @@
local Camera = {}
Camera.__index = Camera
Camera.FOV = {
Default = 70,
Zoomed = 30,
}
Camera.FOV.Speed = {
In = 0.3,
Out = 0.4
}
Camera.VignetteEnabled = true
Camera.CrosshairEffect = true
Camera.EffectsEase = Enum.EasingStyle.Quad
local Storage = game:GetService("ReplicatedStorage")
local Tween = require(Storage:WaitForChild("Tween"))
local ZoomTween = Tween.constructor()
local VignetteTween = Tween.constructor()
function Camera.constructor(CurrentCamera: Camera, Player: Player)
return setmetatable({
Camera = CurrentCamera,
Player = Player,
}, Camera)
end
function Camera:FirstPerson()
self.Player.CameraMode = Enum.CameraMode.LockFirstPerson
end
function Camera:ThirdPerson()
self.Player.CameraMode = Enum.CameraMode.Classic
end
--damn...
type Vignette = any
type Crosshair = any
function Camera:ZoomIn(Vignette: Vignette?, Crosshair: Crosshair?)
ZoomTween:Start(self.Camera, {
FieldOfView = Camera.FOV.Zoomed
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
if Camera.VignetteEnabled then
if Vignette then
Vignette.Screen.Enabled = true
VignetteTween:Start(Vignette.Icon, {
ImageTransparency = 0
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
else
warn("Camera: no Vignette object was provided for the camera", debug.traceback())
end
end
if Camera.CrosshairEffect then
if Crosshair then
VignetteTween:Start(Crosshair.Icon, {
ImageTransparency = .9
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
else
warn("Camera: no Crosshair object was provided for the camera", debug.traceback())
end
end
end
function Camera:ZoomOut(Vignette: Vignette?, Crosshair: Crosshair?)
ZoomTween:Start(self.Camera, {
FieldOfView = Camera.FOV.Default
}, TweenInfo.new(Camera.FOV.Speed.Out, Camera.EffectsEase))
if Camera.VignetteEnabled then
if Vignette then
Vignette.Screen.Enabled = true
VignetteTween:Start(Vignette.Icon, {
ImageTransparency = 1
}, TweenInfo.new(Camera.FOV.Speed.Out, Camera.EffectsEase))
else
warn("Camera: no Vignette object was provided for the camera", debug.traceback())
end
end
if Camera.CrosshairEffect then
if Crosshair then
VignetteTween:Start(Crosshair.Icon, {
ImageTransparency = 0
}, TweenInfo.new(Camera.FOV.Speed.In, Camera.EffectsEase))
else
warn("Camera: no Crosshair object was provided for the camera", debug.traceback())
end
end
end
return Camera

View File

@@ -0,0 +1,82 @@
--I couldn't get ContextActionService to work how i wanted it to
local BindLink = {}
BindLink.__index = BindLink
local UIS = game:GetService("UserInputService")
export type KeyBindMap = {
[string]: {
[Enum.KeyCode]: () -> ()
}
}
export type InputBegan = RBXScriptConnection
export type InputEnded = RBXScriptConnection
type CallbackFunction = () -> ()
function BindLink.constructor() --Allow multiple bindings of the same keys, no overwrites
type BindConstructor = {
BindMap: KeyBindMap,
InputBegan: InputBegan,
InputEnded: InputEnded
}
local self: BindConstructor = {}
self.BindMap = {
Began = {},
Ended = {}
}
--Return these for convenience
self.InputBegan = UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
local switch = self.BindMap.Began[input.KeyCode]
if switch then
switch()
else
--switch.default()
end
end
end)
self.InputEnded = UIS.InputEnded:Connect(function(input, gameProcessedEvent)
if not gameProcessedEvent then
local switch = self.BindMap.Ended[input.KeyCode]
if switch then
switch()
else
--switch.default()
end
end
end)
return setmetatable(self, BindLink)
end
function BindLink:AddInputBegan(Keys: {Enum.KeyCode}, Callback: CallbackFunction)
for i = 1, #Keys do
local Key = Keys[i]
if self.BindMap.Began[Key] then
warn(`Key >began< "{Key.Name}" is already binded on this KeyBind map`, debug.traceback())
end
self.BindMap.Began[Key] = Callback
end
end
function BindLink:AddInputEnded(Keys: {Enum.KeyCode}, Callback: CallbackFunction)
for i = 1, #Keys do
local Key = Keys[i]
if self.BindMap.Ended[Key] then
warn(`Key >ended< "{Key.Name}" is already binded on this KeyBind map`, debug.traceback())
end
self.BindMap.Ended[Key] = Callback
end
end
function BindLink:KeyHold(Key: Enum.KeyCode): boolean
return UIS:IsKeyDown(Key)
end
return BindLink

17
src/shared/Delta.lua Normal file
View File

@@ -0,0 +1,17 @@
local Delta = {
FPS = 60
}
Delta.__index = Delta
type dt = number
function Delta:time(): dt
local Frame = os.clock()
local function Frame_heap(): dt
Frame = os.clock()-Frame
return task.wait(Frame/Delta.FPS)
end
return Frame_heap()
end
return Delta

20
src/shared/String.lua Normal file
View File

@@ -0,0 +1,20 @@
local StringModule = {}
StringModule.__index = StringModule
function StringModule.new(String: string)
return setmetatable({
String = String
}, StringModule)
end
type ByteArray = {string}
function StringModule:bytes(): ByteArray
local cbytes = {self.String:byte(1,-1)}
for i = 1, #cbytes do
cbytes[i] = tostring(cbytes[i]):char()
end
return cbytes
end
return StringModule

13
src/shared/Tags.lua Normal file
View File

@@ -0,0 +1,13 @@
local CS = game:GetService("CollectionService")
local exports: {[string]: BasePart} = {}
local AllTags = CS:GetAllTags()
for i = 1, #AllTags do
local TagName = AllTags[i]
if TagName ~= "RopeMasterObject" then
exports[TagName] = CS:GetTagged(TagName)[1]
end
end
return exports

50
src/shared/Tween.lua Normal file
View File

@@ -0,0 +1,50 @@
local Tween = {}
Tween.__index = Tween
local TS = game:GetService("TweenService")
type TweenAnimation = {[string]: any}
function Tween.constructor(TweenSettings: TweenInfo?, Object: Instance?, PreProperties: TweenAnimation?)
return setmetatable({
TweenInfo = TweenSettings,
Instance = Object,
PreProperties = PreProperties
}, Tween)
end
function Tween:Start(PostInstance: Instance?, PostProperties: TweenAnimation?, PostTweenSettings: TweenInfo?): Tween
local Props = self.PreProperties
local Object = self.Instance
local TweenSettings = self.TweenInfo
if PostProperties then
if self.PreProperties then
for tween_prop, tween_value in PostProperties do
Props[tween_prop] = tween_value
end
print("Tween library: Combining PostProperties and PreProperties together", debug.traceback())
else
Props = PostProperties
end
end
if PostInstance then
if Object then
print("Tween library: Overwriting an already defined animating object old=", Object, "new=", PostInstance, debug.traceback())
end
Object = PostInstance
end
if PostTweenSettings then
if TweenSettings then
print("Tween library: Overwriting already defined Tween settings", debug.traceback())
end
TweenSettings = PostTweenSettings
end
local Animation = TS:Create(Object, TweenSettings, Props)
Animation:Play()
return Animation
end
return Tween

View File

@@ -0,0 +1,11 @@
-- type AccountImpl = {
-- __index: AccountImpl,
-- new: (name: string, balance: number) -> Account,
-- deposit: (self: Account, credit: number) -> (),
-- withdraw: (self: Account, debit: number) -> (),
-- }
-- type Account = typeof(setmetatable({} :: { name: string, balance: number }, {} :: AccountImpl))
type hself<T,U> = {__index: T} & U
export type constructor<T,U> = typeof(setmetatable({} :: T & hself<T,U>, {} :: U))