Tag removal and new serverside structure

This commit is contained in:
2024-03-03 02:34:59 -05:00
parent a3a8720c91
commit 1af1c6919e
15 changed files with 72 additions and 88 deletions

View File

@@ -0,0 +1,114 @@
--!optimize 2
--!native
--!strict
--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 = {
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") :: BasePart
local Start = Folder:WaitForChild("Start") :: BasePart
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 function HideLadderContact(Part: BasePart, enabled: boolean)
Part.Transparency = enabled and 1 or .9
Part.CanCollide = true
Part.CastShadow = false
end
local EditorEntities = {
["LightSource"] = HidePart,
["PulleyRopeContact"] = HidePart,
["BarrierCollision"] = HideBarrierCollision,
["StairSource"] = HideBarrierCollision,
["RaycastContainer"] = HideRaycastContainers,
["LadderContact"] = HideLadderContact
}
type HideEditor = (a1: BasePart | Folder, a2: boolean) -> ()
type LuaChangeableContainer = Script | LocalScript
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: HideEditor = EditorEntities[Item.Name]
if Case then
table.insert(StudioEntities.IndexedEntities, Item)
Case(Item, enabled)
end
if Item:IsA("BasePart") then
Item.CanTouch = false --Do micro optimizations
Item.Locked = true
--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
pcall(function()
(Item :: LuaChangeableContainer).Enabled = false
end)
Item:Destroy()
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
local Entity: Instance = EditorEntities[i]
EditorEntities[Entity.Name](Entity, enabled)
end
end
return StudioEntities.IndexedEntities
end
return StudioEntities

View File

@@ -0,0 +1,36 @@
--!optimize 2
--!native
--!strict
local Floors = {}
Floors.__index = Floors
local Storage = game:GetService("ReplicatedStorage")
local CS = game:GetService("CollectionService")
local Tags = require(Storage:WaitForChild("Tags"))
function Floors.constructor(NumberOfFloors: number, Year: string)
local Floors = {}
for i: number = 1, NumberOfFloors do
local FloorTag_1 = CS:GetTagged(`ElevatorDoor_{Year}_Floor{tostring(i)}_1`)
local FloorTag_2 = CS:GetTagged(`ElevatorDoor_{Year}_Floor{tostring(i)}_2`)
if FloorTag_1 then
table.insert(Floors, FloorTag_1)
end
if FloorTag_2 then
table.insert(Floors, FloorTag_2)
end
end
return setmetatable({
NumberOfFloors = NumberOfFloors,
Floors = Floors
}, Floors)
end
function Floors:GetFloor(Floor: number): Instance?
end
return Floors

View File

@@ -0,0 +1,10 @@
--!optimize 2
--!native
--!strict
local Leveling: {[number]: number} = {
[1] = 13.205,
[10] = 239.216
}
return Leveling

View File

@@ -0,0 +1,28 @@
--!optimize 2
--!native
--!strict
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,198 @@
--!optimize 2
--!native
--!strict
local Doors = {
Closed = true,
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
local RS = game:GetService("RunService")
local Storage = game:GetService("ReplicatedStorage")
local Tween = require(Storage:WaitForChild("Tween"))
local Tags = require(Storage:WaitForChild("Tags"))
local Floor10_Door1 = Tags.ElevatorDoor_1960_Floor10_1
local Floor10_Door2 = Tags.ElevatorDoor_1960_Floor10_2
type DoorSensors = {
[string]: Instance
}
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: DoorSensors = {
Start = ElevatorDoorSensor:WaitForChild("Start"),
End = ElevatorDoorSensor:WaitForChild("End")
}
local DoorClosingClick = Instance.new("Sound") :: 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,
DoorClosingClick = DoorClosingClick
}, Doors)
end
--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(TweenInfo.new(
TweenTime,
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
Enum.EasingDirection.InOut
), Floor10_Door1)
local DoorTween2 = Tween.constructor(TweenInfo.new(
TweenTime,
activated_via_censor and Enum.EasingStyle.Linear or Doors.ElevatorDoorStyle,
Enum.EasingDirection.InOut
), Floor10_Door2)
local Door1Tween_Floor: Tween = DoorTween1:Start(nil, {
Position = opening and init_closed_door1 or init_opened_door1
})
local Door2Tween_Floor: Tween = DoorTween2:Start(nil, {
Position = opening and init_closed_door1 or init_opened_door1
})
return Door1Tween_Floor, Door2Tween_Floor
end
local function DoorsAnimation(self, opening: boolean?, activated_via_censor: boolean?)
self.ElevatorBox.Anchored = true
local ElevatorDoor1_P: Vector3 = self.ElevatorDoor1.Position
local ElevatorDoor2_P: Vector3 = self.ElevatorDoor2.Position
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
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 :: Vector3).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
--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
type this = any --yeah,
type PossibleStepConnection = any
function Doors:DetectSensorHit(DoorTween1, DoorTween2): RBXScriptSignal
local Step: PossibleStepConnection = nil
if Doors.Sensors and Doors.Closed then
raycastParams.FilterDescendantsInstances = {self.ElevatorBox, table.unpack(RayIgnoring)}
Step = (RS :: RunService).Stepped:Connect(function(_delta, _dt)
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()
DoorTween1:Pause()
DoorTween2:Pause()
task.wait(1) --elevators irl have this delay
DoorsAnimation((self :: this), 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
local Door1Tween, Door2Tween = DoorsAnimation(self, opening)
Door2Tween.Completed:Wait()
if Doors.__DontLeakMemory then
Doors.__DontLeakMemory:Disconnect()
end
end
return Doors

View File

@@ -0,0 +1,54 @@
--!optimize 2
--!native
--!strict
local Otis1960_main = {}
Otis1960_main.__index = Otis1960_main
local Elevator = script.Parent
local Elevators = Elevator.Parent
local RS = game:GetService("ReplicatedStorage")
local TagsModule = require(RS:WaitForChild("Tags"))
local Leveling = require(Elevators:WaitForChild("Leveling"))
local Doors = require(Elevator:WaitForChild("Doors"))
local ElevatorMover = require(Elevators:WaitForChild("Mover"))
local Tags = TagsModule.constructor().Exports
local ElevatorBox_1960 = Tags.ElevatorMover_1960
local ElevatorBox = Tags.ElevatorMover_1960 :: BasePart
local ElevatorDoor1 = Tags.ElevatorDoor_1960_1 :: BasePart
local ElevatorDoor2 = Tags.ElevatorDoor_1960_2 :: BasePart
local ElevatorDoorSensor = Tags.ElevatorDoor_Sensor_1960 :: Folder
local ElevatorBoxStartPos = ElevatorBox_1960.Position
local _BoxAttachment, BoxAlignPosition, _BoxAlignOrientation = ElevatorMover(ElevatorBox_1960, ElevatorBoxStartPos)
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
print("[DEBUG]: Tags:",Tags)
-- while true do
-- task.wait(2)
-- ElevatorDoors:Opening(true)
-- task.wait(2)
-- ElevatorDoors:Opening(false)
-- end
return Otis1960_main

View File

@@ -0,0 +1,49 @@
--!optimize 2
--!native
--!strict
local Lighting = game:GetService("Lighting")
type LightingProps = { [string]: Color3 | number | boolean | string }
local Lighting_PropsTree: LightingProps = {
["Ambient"] = Color3.fromRGB(40,40,40),
["Brightness"] = 1,
["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
--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
return {
ColorCorrection = ColorCorrection
}
end

View File

@@ -0,0 +1,10 @@
--!optimize 2
--!native
--!strict
local StarterPlayer = game:GetService("StarterPlayer")
return function()
StarterPlayer.CharacterWalkSpeed = 0
StarterPlayer.CharacterJumpHeight = 0
end

View File

@@ -0,0 +1,7 @@
--!optimize 2
--!native
--!strict
return function()
workspace.Gravity = 150
end

View File

@@ -0,0 +1,36 @@
--!optimize 2
--!native
--!strict
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 TagsModule = require(Storage:WaitForChild("Tags"))
local TagsConstructor = TagsModule.constructor()
local Tags = TagsConstructor.Exports
print("[DEBUG] Tags=", Tags)
local Elevators = script:WaitForChild("Elevators")
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
TagsConstructor:Nuke()