This commit is contained in:
lx
2026-07-06 14:01:11 -04:00
commit c4f97d729d
16468 changed files with 935321 additions and 0 deletions
@@ -0,0 +1,218 @@
local runService = game:GetService("RunService")
local Zones = workspace:FindFirstChild("Zones")
local City = Zones and Zones:FindFirstChild("City")
local CFramer = {}; do
function CFramer.GetAllParts(model, list)
list = list or {}
if model:IsA("BasePart") then
list[#list + 1] = model
end
local children = model:GetChildren()
for i = 1, #children do
CFramer.GetAllParts(children[i], list)
end
return list
end
function CFramer.GetAllPartOffsets(parts, cframeBase)
-- The offset is a part's cframe relative to cframeBase
local offsets = {}
local cframeBase_inv = cframeBase:inverse()
for i = 1, #parts do
offsets[i] = cframeBase_inv * parts[i].CFrame
end
return offsets
end
function CFramer.newCFramer(parts, offsets)
return function(cf)
for i = 1, #parts do
parts[i].CFrame = cf * offsets[i]
end
end
end
function CFramer.newCFramerFromModel(model, cframeBase)
local parts = CFramer.GetAllParts(model)
local offsets = CFramer.GetAllPartOffsets(parts, cframeBase)
return CFramer.newCFramer(parts, offsets)
end
end
local renderTrains;
spawn(function()
while not runService:IsRunning() do wait(0.1) end
if not City then
City = workspace:WaitForChild("Zones"):WaitForChild("City")
end
local exampleTrain = City.Train:Clone()
local function newTrain()
local train = exampleTrain:Clone()
train.Parent = workspace
return CFramer.newCFramerFromModel(train.Parts, train.Track.CFrame)
end
local function newTrack(part, direction)
if not direction then
direction = math.random(0, 1) * 2 - 1
end
local length = part.Size.Y
local cf = part.CFrame * CFrame.Angles(math.pi / 2 * (direction + 1), 0, 0)
local cf0 = cf * CFrame.new(0, -length/2, 0)
return function(train, time)
local distance = time * 48
if distance >= 0 and distance <= length then
train(cf0 * CFrame.new(0, distance, 0))
end
end, part.Size.Y
end
local train0 = newTrain()
local train1 = newTrain()
local train2 = newTrain()
local train3 = newTrain()
local train4 = newTrain()
local train5 = newTrain()
local train6 = newTrain()
local tracks = City.Tracks
local track0 = newTrack(tracks.TrackA1)--, 1)
local track1 = newTrack(tracks.TrackA2)--, -1)
local track2 = newTrack(tracks.TrackA3)--, 1)
local track3 = newTrack(tracks.TrackB1)--, 1)
local track4 = newTrack(tracks.TrackB2)--, -1)
local track5 = newTrack(tracks.TrackC1)--, -1)
local track6 = newTrack(tracks.TrackC2)--, 1)
local track7 = newTrack(tracks.TrackC3)--, 1)
function renderTrains(timestamp)
track0(train0, timestamp % 15)
track1(train1, (timestamp - 3) % 20)
track2(train2, (timestamp - 5.5) % 18)
track3(train3, (timestamp - 5.5) % 25)
track6(train4, (timestamp - 2.5) % 30)
end
end)
local renderFlows;
spawn(function()
if not City then
City = workspace:WaitForChild("Zones"):WaitForChild("City")
end
local function newFlow(model, flowLength)
local parts = {}
local partParts = {}
local partPartOffsets = {}
local cframes = {}
for j, part in pairs(model:GetChildren()) do
local i = tonumber(part.Name)
parts[i] = part
cframes[i] = part.CFrame
local pParts = {}
local pPartOffsets = {}
for i, pPart in pairs(part:GetChildren()) do
if pPart:IsA("BasePart") then
pParts[#pParts + 1] = pPart
pPartOffsets[#pPartOffsets + 1] = part.CFrame:inverse() * pPart.CFrame
end
end
partParts[i] = pParts
partPartOffsets[i] = pPartOffsets
end
local partCycle = 0
local unitOffset = 0
local timestamp0 = 0
return function(timestamp1)
if timestamp1 < timestamp0 then
timestamp0 = timestamp1
end
local unit = (timestamp1 - timestamp0) / flowLength + unitOffset
if unit >= 1 then
partCycle = (partCycle + math.floor(unit)) % #parts
unit = unit % 1
unitOffset = unit
timestamp0 = timestamp1 -- - deltaTime * flowLength
end
for x = 0, #parts - 2 do
local i = (x - partCycle) % #cframes + 1
local cf = cframes[x + 1]:lerp(cframes[x + 2], unit)
parts[i].CFrame = cf
local pParts = partParts[i]
local pPartOffsets = partPartOffsets[i]
for n = 1, #pParts do
pParts[n].CFrame = cf * pPartOffsets[n]
end
end
end
end
local flow1 = newFlow(City.Pipe1.Flow, 0.5)
local flow2 = newFlow(City.Pipe2.Flow, 0.65)
function renderFlows(t)
flow1(t)
flow2(t)
end
end)
local connection;
local self = {}
function self:SetEnabled(enabled)
if enabled and connection then
return
end
if connection then
connection:disconnect()
connection = nil
end
if not enabled then
return
end
local timestamp0 = tick()
connection = game:GetService("RunService").RenderStepped:connect(function()
local t = tick() - timestamp0
if renderFlows then
renderFlows(t)
end
if renderTrains then
renderTrains(t)
end
end)
end
return self
@@ -0,0 +1,145 @@
local runService = game:GetService("RunService")
local CFrameOffsetter = {};
do
function CFrameOffsetter.GetAllParts(model, list)
list = list or {}
if model:IsA("BasePart") then
list[#list + 1] = model
end
local children = model:GetChildren()
for i = 1, #children do
CFrameOffsetter.GetAllParts(children[i], list)
end
return list
end
function CFrameOffsetter.GetAllPartOffsets(parts, cframeBase)
-- The offset is a part's cframe relative to cframeBase
local offsets = {}
local cframeBase_inv = cframeBase:inverse()
for i = 1, #parts do
offsets[i] = cframeBase_inv * parts[i].CFrame
end
return offsets
end
function CFrameOffsetter.newOffsetter(parts, offsets, cframeBase)
return function(offset)
local cf = cframeBase * offset
for i = 1, #parts do
parts[i].CFrame = cf * offsets[i]
end
end
end
function CFrameOffsetter.newOffsetterFromModel(model, cframeBase)
local parts = CFrameOffsetter.GetAllParts(model)
local offsets = CFrameOffsetter.GetAllPartOffsets(parts, cframeBase)
return CFrameOffsetter.newOffsetter(parts, offsets, cframeBase)
end
end
local newOffsetterFromModel = CFrameOffsetter.newOffsetterFromModel
local renderStation;
spawn(function()
while not runService:IsRunning() do wait(0.1) end
local Space = workspace:WaitForChild("Zones"):WaitForChild("Space")
local model = Space.Station
local cframeBase = model.rings.center.CFrame
local ring1 = newOffsetterFromModel(model.rings.Ring1, cframeBase)
local ring2 = newOffsetterFromModel(model.rings.Ring2, cframeBase)
local ring3 = newOffsetterFromModel(model.rings.Ring3, cframeBase)
local station = newOffsetterFromModel(model.station, cframeBase)
function renderStation(t)
ring1(
CFrame.Angles(0, (t / 6 % (math.pi * 2)), 0)
* CFrame.new(0, math.sin(t / 4 % (math.pi * 2)) * 1, 0)
)
ring2(
CFrame.Angles(0, -(t / 4 % (math.pi * 2)), 0)
* CFrame.new(0, math.sin(2 + t / 2 % (math.pi * 2)) * 1, 0)
)
ring3(
CFrame.Angles(0, (t / 3.5 % (math.pi * 2)), 0)
* CFrame.new(0, math.sin(1 + t / 2 % (math.pi * 2)) * 1, 0)
)
station(
CFrame.Angles(0, (t / -32 % (math.pi * 2)), 0)
* CFrame.new(0, math.sin(t / 4 % (math.pi * 2)) * 3 - 2, 0)
)
end
end)
local renderOrbit;
spawn(function()
while not runService:IsRunning() do wait(0.1) end
local Space = workspace:WaitForChild("Zones"):WaitForChild("Space")
local model = Space.Orbit
local cframeBase = model.center.CFrame
local cuteMoonThings = newOffsetterFromModel(model, cframeBase)
local ringParts = {Space.Disk, Space.Disk2, Space.Disk3}
local rings = {}
for i = 1, #ringParts do
rings[i] = newOffsetterFromModel(ringParts[i], ringParts[i].CFrame)
end
function renderOrbit(t)
cuteMoonThings(
CFrame.Angles((t / 80 % (math.pi * 2)), (t / 60 % (math.pi * 2)), (t / 40 % (math.pi * 2)))
)
for i = 1, #rings do
rings[i](
CFrame.Angles(0, 1 / 4 + (t / 60 % (math.pi * 2)), 0)
)
end
end
end)
local connection;
local self = {}
function self:SetEnabled(enabled)
if enabled and connection then
return
end
if connection then
connection:disconnect()
connection = nil
end
if not enabled then
return
end
local timestamp0 = tick()
connection = game:GetService("RunService").RenderStepped:connect(function()
local t = (tick() - timestamp0)
if renderStation then
renderStation(t)
end
if renderOrbit then
renderOrbit(t)
end
end)
end
return self
@@ -0,0 +1,70 @@
local runService = game:GetService("RunService")
local Volcano;
local lightning;
spawn(function()
while not runService:IsRunning() do wait(0.1) end
Volcano = workspace:WaitForChild("Zones"):WaitForChild("Volcano")
lightning = Volcano.Lightning:GetChildren()
for i = 1, #lightning do
lightning[i].Parent = nil
end
end)
local function playLighting(model)
if not (model and Volcano) then
return
end
model.Parent = Volcano.Lightning
wait(0.125)
model.Parent = nil
end
local connection;
local handle;
local self = {}
function self:SetEnabled(enabled)
if enabled and connection then
return
end
if connection then
connection:disconnect()
connection = nil
end
handle = nil
if not enabled then
return
end
local h = {} -- our handle
handle = h -- Stops a previous loop
coroutine.wrap(function()
while handle == h do
wait(math.random() * 16 + 1)
if lightning then
playLighting(lightning[math.random(1, #lightning)])
end
end
end)()
--[[
local timestamp0 = tick()
connection = game:GetService("RunService").RenderStepped:connect(function()
local t = (tick() - timestamp0)
--renderStation(t)
--renderOrbit(t)
end)
--]]
end
return self