Skip to content

Commit

Permalink
push changes
Browse files Browse the repository at this point in the history
  • Loading branch information
2jammers committed Nov 21, 2024
1 parent 55795e1 commit f63609d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 59 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ jobs:
tag: ${{ github.ref_name }}
changelogPath: "docs/changelog.md"

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Commit and push
uses: EndBug/add-and-commit@v9
with:
message: Bump version to ${{ github.ref_name }}
default_author: github_actions
run: |
git add docs/changelog.md
git commit --message "Bump version to ${{ github.ref_name }}"
publish-build:
name: Publish Assets
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fixes an issue with start being in the incorrect order ([#29](https://github.com/luminlabsdev/framework/issues/29))

### Removed

- Removes default lifecycle types

## [9.0.1] - 2024-11-19

### Fixed
Expand Down
9 changes: 1 addition & 8 deletions docs/guides/lifecycle-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,4 @@ end

## Default Lifecycles

For ease of use, a few default lifecycle types are automatically provided. No extra configuration needed, all you have to do is create a new lifecycle with the specific name. Here's a list of the available lifecycles:

- **PostSimulation**
- **PreSimulation**
- **PreRender** Client only!
- **PreAnimation** Client only!
- **PlayerAdded**
- **PlayerRemoving**
There are no default lifecycles and they must be created on your own. Some common lifecycle types are things such as `PlayerAdded`, `Heartbeat` and more. Default lifecycles were removed in 9.1.0 as they affected game performance.
8 changes: 0 additions & 8 deletions src/Types.luau
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,4 @@ export type Lifecycle<T...> = {
Listeners: { (...any) -> () },
}

export type LifecycleType =
"PlayerAdded" |
"PlayerRemoving" |
"PreSimulation" |
"PreAnimation" |
"PreRender" |
"PostSimulation"

return {}
49 changes: 11 additions & 38 deletions src/init.luau
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
-- Variables

local RunService = game:GetService("RunService")
local PlayerService = game:GetService("Players")

local Packages = script.Parent

local Types = require(script.Types)
local Logs = require(script.Logs)

local Debugger = require(Packages.debugger)

local Started = false

local Controllers: { Types.Controller<any> } = {}
local Lifecycles: { Types.Lifecycle<...any> } = {}
local DefaultLifecycles: { [string]: RBXScriptSignal } = {
PostSimulation = RunService.PostSimulation,
PreSimulation = RunService.PreSimulation,
PreRender = RunService.PreRender,
PreAnimation = RunService.PreAnimation,
PlayerAdded = PlayerService.PlayerAdded,
PlayerRemoving = PlayerService.PlayerRemoving,
}

-- Functions

Expand Down Expand Up @@ -50,7 +37,7 @@ end
[Learn More](https://luminlabsdev.github.io/framework/api/#lifecycle)
]=]
local function Lifecycle(
name: Types.LifecycleType | string,
name: string,
callback: ((self: Types.Lifecycle<...any>, ...any) -> ())?
): Types.Lifecycle<...any>
Debugger.Assert(not Started, "AlreadyStarted")
Expand All @@ -77,26 +64,17 @@ local function New<T>(members: Types.Controller<T>, order: number?): T
return members
end

-- Loads a default lifecycle
local function LoadDefaultLifecycle(lifecycle: Types.Lifecycle<...any>)
local Event = DefaultLifecycles[lifecycle.Name]
if RunService:IsServer() and (lifecycle.Name == "PreAnimation" or lifecycle.Name == "PreRender") then
Debugger.Fatal("IncorrectContext", "PreAnimation or PreRender")
end
Event:Connect(function(...)
lifecycle:Fire(...)
end)
end

-- Starts/inits a list of controllers internally, and starts lifecycles within those
local function LoadControllersAsync(controllers: { Types.Controller<any> })
local InitiatedControllers = {}
Started = true

-- Init process
for _, controller in controllers do
-- Check if the controller uses any dependencies
if controller.Uses and type(controller.Uses) == "table" then
table.freeze(controller.Uses)
-- Call init on used dependencies
-- Call init on used dependencies of the controller
for _, usedController in controller.Uses do
if usedController["Init"] and not table.find(InitiatedControllers, usedController) then
LoadController(usedController.Init, "Init")
Expand All @@ -105,13 +83,16 @@ local function LoadControllersAsync(controllers: { Types.Controller<any> })
end
end

-- Call init on non-used dependencies
-- Call init on controller
if controller.Init and not table.find(InitiatedControllers, controller) then
LoadController(controller.Init, "Init")
table.insert(InitiatedControllers, controller)
end
end

-- Call start on all dependencies
-- Start process
for _, controller in Controllers do
-- Call start on all dependencies
if controller.Start then
LoadController(controller.Start, "Start")
end
Expand All @@ -122,14 +103,7 @@ local function LoadControllersAsync(controllers: { Types.Controller<any> })
table.insert(lifecycle.Listeners, (controller :: any)[lifecycle.Name])
end
end
end

-- Connect default lifecycles
for _, lifecycle in Lifecycles do
if DefaultLifecycles[lifecycle.Name] then
LoadDefaultLifecycle(lifecycle)
end
end
end
end

-- Loads all of the provided directories
Expand All @@ -154,7 +128,6 @@ end
local function Start(directories: { Instance }, filter: ((ModuleScript) -> boolean)?, callback: (() -> ())?)
Debugger.Assert(not Started, "AlreadyStarted")
LoadControllersAsync(Import(directories, filter))
Started = true

if callback then
callback()
Expand Down Expand Up @@ -182,7 +155,7 @@ export type Controller<T> = Types.Controller<T>

return table.freeze({
-- Version
version = "9.0.1",
version = "9.1.0",

-- Starter
Start = Start,
Expand Down
2 changes: 1 addition & 1 deletion wally.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lumin/framework"
description = "A lightning fast & amazing game framework for Roblox"
version = "9.0.1"
version = "9.1.0"
license = "MIT"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
Expand Down

0 comments on commit f63609d

Please sign in to comment.