mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Floors module
This commit is contained in:
@@ -30,12 +30,14 @@ 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)
|
||||
task.spawn(function()
|
||||
while Spine.Running do
|
||||
local IsFirstPerson = Player.CameraMode == Enum.CameraMode.LockFirstPerson
|
||||
self.Remote:FireServer(self.CurrentCamera.CFrame, IsFirstPerson)
|
||||
|
||||
Delta:time()
|
||||
end
|
||||
Delta:time()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Spine:Disable()
|
||||
|
||||
@@ -42,22 +42,32 @@ local CameraConsturctor = CameraModule.constructor(CurrentCamera, HumanoidRootPa
|
||||
local HumanoidSettings = HumanoidModule.constructor(Humanoid)
|
||||
local SpineMovement = SpineModule.constructor(CurrentCamera)
|
||||
|
||||
local function CrouchFeature()
|
||||
local Walking = 10/2 --10 is default
|
||||
|
||||
local function ClientCharacterBinds()
|
||||
local CrouchConstructor = CrouchModule.constructor(Humanoid)
|
||||
local CourchBindMap = BindModule.constructor()
|
||||
local BindMap = BindModule.constructor()
|
||||
|
||||
CourchBindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
|
||||
--Crouch
|
||||
BindMap:AddInputBegan({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
|
||||
CrouchConstructor:Crouch(10)
|
||||
end)
|
||||
CourchBindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
|
||||
BindMap:AddInputEnded({Enum.KeyCode.RightControl, Enum.KeyCode.LeftControl}, function()
|
||||
CrouchConstructor:Stand(5)
|
||||
end)
|
||||
--Walk
|
||||
BindMap:AddInputBegan({Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}, function()
|
||||
HumanoidSettings:SetWalkSpeed(Walking)
|
||||
end)
|
||||
BindMap:AddInputEnded({Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift}, function()
|
||||
HumanoidSettings:SetWalkSpeed(10)
|
||||
end)
|
||||
end
|
||||
|
||||
HumanoidSettings:SetWalkSpeed()
|
||||
HumanoidSettings:SetJumpHeight()
|
||||
HRPSettings:DisableRobloxSounds()
|
||||
-- CameraConsturctor:EnableBobbing()
|
||||
CameraConsturctor:EnableBobbing()
|
||||
SpineMovement:Enable()
|
||||
|
||||
CrouchFeature()
|
||||
ClientCharacterBinds()
|
||||
@@ -44,7 +44,7 @@ local function CameraBinds()
|
||||
end
|
||||
|
||||
CoreGuis:Off()
|
||||
-- Camera:FirstPerson()
|
||||
Camera:FirstPerson()
|
||||
Mouse:DisablePointer()
|
||||
Crosshair:Enable()
|
||||
|
||||
|
||||
18
src/server/Elevators/Floors.lua
Normal file
18
src/server/Elevators/Floors.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
local Floors = {}
|
||||
Floors.__index = Floors
|
||||
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
local Tags = require(Storage:WaitForChild("Tags"))
|
||||
|
||||
function Floors.constructor(NumberOfFloors: number)
|
||||
return setmetatable({NumberOfFloors = NumberOfFloors}, Floors)
|
||||
end
|
||||
|
||||
--NumberOfFloors syntax: ElevatorDoor_(year)_Floor(floors amount)_1/2
|
||||
function Floors:GetFloors(Year: string)
|
||||
for i: number = 1, self.NumberOfFloors do
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return Floors
|
||||
@@ -1,6 +1,11 @@
|
||||
local Doors = {
|
||||
Closed = true,
|
||||
DontLeakMemory = nil
|
||||
Sensors = true,
|
||||
Door1Stopped_X = Vector3.xAxis*2.9,
|
||||
Door2Stopped_X = Vector3.xAxis*5.8,
|
||||
ElevatorDoorTime = 5,
|
||||
ElevatorDoorStyle = Enum.EasingStyle.Quad,
|
||||
__DontLeakMemory = nil
|
||||
}
|
||||
Doors.__index = Doors
|
||||
|
||||
@@ -10,59 +15,123 @@ local Storage = game:GetService("ReplicatedStorage")
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
local Tags = require(Storage:WaitForChild("Tags"))
|
||||
|
||||
local Door1Stopped_X = Vector3.xAxis*2.9
|
||||
local Door2Stopped_X = Vector3.xAxis*6
|
||||
local Floor10_Door1 = Tags.ElevatorDoor_1960_Floor10_1
|
||||
local Floor10_Door2 = Tags.ElevatorDoor_1960_Floor10_2
|
||||
|
||||
function Doors.constructor(ElevatorBox: BasePart, ElevatorDoor1: BasePart, ElevatorDoor2: BasePart, ElevatorDoorSensor: Folder)
|
||||
type DoorSensors = {
|
||||
[string]: BasePart
|
||||
}
|
||||
|
||||
local DoorTween1 = Tween.constructor(nil, ElevatorDoor1)
|
||||
local DoorTween2 = Tween.constructor(nil, ElevatorDoor2)
|
||||
local DoorSensor: {[string]: BasePart} = {
|
||||
local DoorSensor: DoorSensors = {
|
||||
Start = ElevatorDoorSensor:WaitForChild("Start"),
|
||||
End = ElevatorDoorSensor:WaitForChild("End")
|
||||
}
|
||||
|
||||
local DoorClosingClick = Instance.new("Sound")
|
||||
DoorClosingClick.SoundId = "rbxassetid://16357740945"
|
||||
DoorClosingClick.Volume = .1
|
||||
DoorClosingClick.Parent = ElevatorDoor2
|
||||
|
||||
return setmetatable({
|
||||
DoorTween1 = DoorTween1,
|
||||
DoorTween2 = DoorTween2,
|
||||
DoorSensor = DoorSensor,
|
||||
ElevatorBox = ElevatorBox,
|
||||
ElevatorDoor1 = ElevatorDoor1,
|
||||
ElevatorDoor2 = ElevatorDoor2
|
||||
ElevatorDoor2 = ElevatorDoor2,
|
||||
DoorClosingClick = DoorClosingClick
|
||||
}, Doors)
|
||||
end
|
||||
|
||||
local function DoorsAnimation(self, opening: boolean?)
|
||||
--speed
|
||||
local init_opened_door1: Vector3?,
|
||||
init_opened_door2: Vector3?,
|
||||
init_closed_door1: Vector3?,
|
||||
init_closed_door2: Vector3?
|
||||
--Solve[5/x==3.5,x]
|
||||
--Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.
|
||||
local opening_speed = Doors.ElevatorDoorTime/1.4285714285714286
|
||||
local sensor_opening_speed = Doors.ElevatorDoorTime/2.5
|
||||
|
||||
local function DoorsAnimationFloor(floor: number, opening: boolean?, activated_via_censor: boolean?, TweenTime: number): (Tween, Tween)
|
||||
local DoorTween1 = Tween.constructor(nil, Floor10_Door1)
|
||||
local DoorTween2 = Tween.constructor(nil, Floor10_Door2)
|
||||
|
||||
local Door1Tween_Floor: Tween = Floor10_Door1:Start(nil, {
|
||||
Position = opening and init_closed_door1 or init_opened_door1
|
||||
}, TweenInfo.new(
|
||||
TweenTime,
|
||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||
Enum.EasingDirection.InOut
|
||||
))
|
||||
local Door2Tween_Floor: Tween = Floor10_Door2:Start(nil, {
|
||||
Position = opening and init_closed_door1 or init_opened_door1
|
||||
}, TweenInfo.new(
|
||||
TweenTime,
|
||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||
Enum.EasingDirection.InOut
|
||||
))
|
||||
|
||||
return Door1Tween_Floor, Door2Tween_Floor
|
||||
end
|
||||
|
||||
local function DoorsAnimation(self, opening: boolean?, activated_via_censor: boolean?)
|
||||
self.ElevatorBox.Anchored = true
|
||||
|
||||
local ElevatorDoor1_P = self.ElevatorDoor1.Position
|
||||
local ElevatorDoor2_P = self.ElevatorDoor2.Position
|
||||
|
||||
local TweenTime = opening and 3.5 or 5
|
||||
|
||||
local Door1Tween = self.DoorTween1:Start(nil, {
|
||||
Position = opening and ElevatorDoor1_P+Vector3.xAxis*math.max((ElevatorDoor1_P-Door1Stopped_X).X, Door1Stopped_X.X) or ElevatorDoor1_P-Door1Stopped_X
|
||||
}, TweenInfo.new(
|
||||
TweenTime,
|
||||
Enum.EasingStyle.Quad,
|
||||
Enum.EasingDirection.InOut
|
||||
))
|
||||
local Door2Tween = self.DoorTween2:Start(nil, {
|
||||
Position = opening and ElevatorDoor2_P+Vector3.xAxis*math.max((ElevatorDoor2_P-Door2Stopped_X).X, Door2Stopped_X.X) or ElevatorDoor2_P-Door1Stopped_X
|
||||
}, TweenInfo.new(
|
||||
TweenTime,
|
||||
Enum.EasingStyle.Quad,
|
||||
Enum.EasingDirection.InOut
|
||||
))
|
||||
|
||||
if Doors.DontLeakMemory then
|
||||
Doors.DontLeakMemory:Disconnect()
|
||||
local TweenTime = activated_via_censor and sensor_opening_speed or opening and opening_speed or Doors.ElevatorDoorTime
|
||||
|
||||
if opening then
|
||||
if not init_closed_door1 and not init_closed_door2 then
|
||||
init_closed_door1 = ElevatorDoor1_P+Doors.Door1Stopped_X
|
||||
init_closed_door2 = ElevatorDoor2_P+Doors.Door2Stopped_X
|
||||
end
|
||||
else
|
||||
if not init_opened_door1 and not init_opened_door2 then
|
||||
init_opened_door1 = ElevatorDoor1_P-Doors.Door1Stopped_X
|
||||
init_opened_door2 = ElevatorDoor2_P-Doors.Door2Stopped_X
|
||||
end
|
||||
end
|
||||
Doors.DontLeakMemory = self:DetectSensorHit(Door1Tween, Door2Tween)
|
||||
|
||||
local Door1Tween: Tween = self.DoorTween1:Start(nil, {
|
||||
Position = opening and init_closed_door1 or init_opened_door1
|
||||
}, TweenInfo.new(
|
||||
TweenTime,
|
||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||
Enum.EasingDirection.InOut
|
||||
))
|
||||
local Door2Tween: Tween = self.DoorTween2:Start(nil, {
|
||||
Position = opening and init_closed_door2 or init_opened_door2
|
||||
}, TweenInfo.new(
|
||||
TweenTime,
|
||||
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
|
||||
Enum.EasingDirection.InOut
|
||||
))
|
||||
|
||||
if not opening then
|
||||
--Door clicking noise
|
||||
task.delay(Doors.ElevatorDoorTime-.90, function()
|
||||
--is the door close enough to closing?
|
||||
if init_closed_door2.X-self.ElevatorDoor2.Position.X>5 then
|
||||
self.DoorClosingClick:Play()
|
||||
end
|
||||
end)
|
||||
end
|
||||
if Doors.__DontLeakMemory then
|
||||
Doors.__DontLeakMemory:Disconnect()
|
||||
end
|
||||
Doors.__DontLeakMemory = self:DetectSensorHit(Door1Tween, Door2Tween)
|
||||
|
||||
return Door1Tween, Door2Tween
|
||||
end
|
||||
|
||||
local raycastParams = RaycastParams.new()
|
||||
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
|
||||
raycastParams.IgnoreWater = true --sure ig
|
||||
|
||||
--heh..
|
||||
local RayIgnoring = {}
|
||||
@@ -73,20 +142,20 @@ for n: number = 1, #workspace_items do
|
||||
end
|
||||
end
|
||||
|
||||
function Doors:DetectSensorHit(DoorTween1, DoorTween2): nil | RBXScriptSignal
|
||||
function Doors:DetectSensorHit(DoorTween1, DoorTween2): RBXScriptSignal?
|
||||
local Step = nil
|
||||
if Doors.Closed then
|
||||
if Doors.Sensors and 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 my work has this similar delay lol
|
||||
DoorsAnimation(self, true)
|
||||
task.wait(1) --elevators irl have this delay
|
||||
DoorsAnimation(self, true, true)
|
||||
-- DoorTween1:Destroy()
|
||||
-- DoorTween2:Destroy()
|
||||
end
|
||||
@@ -112,14 +181,12 @@ function Doors:Opening(opening: boolean?)
|
||||
return
|
||||
end
|
||||
end
|
||||
self.ElevatorBox.Anchored = true
|
||||
|
||||
local Door1Tween, Door2Tween = DoorsAnimation(self, opening)
|
||||
Door2Tween.Completed:Wait()
|
||||
if Doors.DontLeakMemory then
|
||||
Doors.DontLeakMemory:Disconnect()
|
||||
if Doors.__DontLeakMemory then
|
||||
Doors.__DontLeakMemory:Disconnect()
|
||||
end
|
||||
self.ElevatorBox.Anchored = false
|
||||
end
|
||||
|
||||
return Doors
|
||||
@@ -1,5 +1,6 @@
|
||||
local Elevator = script.Parent
|
||||
local Elevators = Elevator.Parent
|
||||
|
||||
local RS = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Tags = require(RS:WaitForChild("Tags"))
|
||||
@@ -32,12 +33,9 @@ local function GoTo_Level(requested_level: number)
|
||||
end
|
||||
end
|
||||
|
||||
--"it will solve the issue of exploiters messing with the elevator"
|
||||
ElevatorBox_1960:SetNetworkOwner(nil)
|
||||
|
||||
print(Tags)
|
||||
|
||||
task.wait(2)
|
||||
ElevatorDoors:Opening(true)
|
||||
task.wait(2)
|
||||
ElevatorDoors:Opening(false)
|
||||
while true do
|
||||
task.wait(2)
|
||||
ElevatorDoors:Opening(true)
|
||||
task.wait(2)
|
||||
ElevatorDoors:Opening(false)
|
||||
end
|
||||
@@ -1,11 +1,12 @@
|
||||
--All debugging objects such as light source indicating objects will be turned invisible
|
||||
|
||||
local Players = game:GetService("Players")
|
||||
local CS = game:GetService("CollectionService")
|
||||
|
||||
export type Entities = {
|
||||
IndexedEntities: {Instance}
|
||||
}
|
||||
local StudioEntities: Entities = {
|
||||
local StudioEntities = {
|
||||
IndexedEntities = {}
|
||||
}
|
||||
|
||||
@@ -54,21 +55,36 @@ function StudioEntities.indexAll(enabled: boolean): Entities
|
||||
Case(Item, enabled)
|
||||
end
|
||||
|
||||
if Item:IsA("BasePart") then --Do micro optimizations
|
||||
Item.CanTouch = false
|
||||
if Item:IsA("BasePart") then
|
||||
Item.CanTouch = false --Do micro optimizations
|
||||
|
||||
--Security from exploiters
|
||||
if not Item.Anchored and table.find(CS:GetTags(Item), "ServerGuard_Physics") then
|
||||
local succ, err = pcall(Item.SetNetworkOwner, Item, nil)
|
||||
if succ then
|
||||
CS:RemoveTag(Item, "ServerGuard_Physics")
|
||||
print(`[Server Physics Guard]: "{Item}" Networking -> "{Item:GetNetworkOwner()}", {Item:GetFullName()}`)
|
||||
else
|
||||
warn(err)
|
||||
end
|
||||
end
|
||||
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)
|
||||
warn(`Script: "{Item.Name}" ({Item.ClassName}) was removed because it was outside of the rhpid-framework boundries,`, Item:GetFullName())
|
||||
end
|
||||
end
|
||||
|
||||
if table.find(CS:GetTags(Item), "ServerGuard_Physics") then
|
||||
warn(`[Server Physics Guard]: present on a non BasePart, "{Item}", {Item:GetFullName()}`)
|
||||
CS:RemoveTag(Item, "ServerGuard_Physics")
|
||||
end
|
||||
end
|
||||
else
|
||||
for i = 1, #StudioEntities.IndexedEntities do
|
||||
|
||||
@@ -5,7 +5,7 @@ local exports: {[string]: BasePart} = {}
|
||||
local AllTags = CS:GetAllTags()
|
||||
for i = 1, #AllTags do
|
||||
local TagName = AllTags[i]
|
||||
if TagName ~= "RopeMasterObject" then
|
||||
if TagName ~= "RopeMasterObject" and TagName ~= "ServerGuard_Physics" then
|
||||
local Tagged = CS:GetTagged(TagName)
|
||||
exports[TagName] = #Tagged>1 and Tagged or Tagged[1]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user