This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jabby from "@rbxts/jabby"; | |
import { component, Entity, meta, Name, pair, tag, World } from "@rbxts/jecs"; | |
import { ContextActionService, RunService } from "@rbxts/services"; | |
import { SystemFunction } from "./definitions/types"; | |
jabby.set_check_function(() => true); | |
const scheduler = jabby.scheduler.create(); | |
const System = component<{ | |
fn: (dt: number) => void; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
local clientstore = require(ReplicatedStorage.client.clientstore) | |
local types = require(ReplicatedStorage.common.definitions.types) | |
local c = require(ReplicatedStorage.common.components) | |
local jecs = require(ReplicatedStorage.pkg.jecs) | |
return function(world: types.World) | |
local pair = jecs.pair | |
local sources = clientstore.Sources |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PlantEntries = { types.PlantConfig } | |
type PlantList = deque.Deque<{ | |
plant: enums.Plant, | |
weight: number, | |
}> | |
local spawn_plants = {} :: { types.Tag } | |
local list = deque.new() :: PlantList | |
local spawner_folder, ENTRIES, spawner_part = setup_spawner(world) | |
local despawner_id = setup_despawner(world) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function roll_a_die<T>(items: { Item<T> }, random: Random): T | |
if #items == 0 then | |
error("Items cannot be empty. This is a serious bug") | |
end | |
local weight_maps: { [number]: { types.Tag } } = {} | |
local sorted = table.clone(items) | |
table.sort(sorted, function(a, b) | |
return a.rarity < b.rarity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return function(world: types.World) | |
local pair = jecs.pair | |
local sources = clientstore.Sources | |
return function() | |
local hrp = world:get(c.Client, c.BasePart) | |
if not hrp then | |
return | |
end | |
local interactable = sources.interactable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function get_players_who_has_not_setup_houses() | |
local players_who_have_not_setup_house = {} :: { Player } | |
for i, player in Players:GetPlayers() do | |
local player_config = playersetupconfig[player] | |
local playerdata = playerdatastore[player] | |
if not player_config or not playerdata then | |
-- This means that player's data hasn't fully loaded yet. In this case, we simply ignore | |
-- and skip them until their data is ready | |
continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity, World } from "@rbxts/jecs"; | |
type System = { | |
callback: (world: World) => void; | |
id: number; | |
}; | |
type Systems = Array<System>; | |
type Events = { | |
RenderStepped: Systems; | |
Heartbeat: Systems; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type VoidCallback<T extends unknown[]> = (...args: T) => void; | |
type UnknownCallback<T extends unknown[]> = (...args: T) => unknown; | |
type SystemFn<T extends unknown[]> = VoidCallback<T> | UnknownCallback<T>; | |
type SystemTable<T extends unknown[]> = { | |
system: SystemFn<T>; | |
phase: unknown; | |
}; | |
type System<T extends unknown[]> = SystemFn<T> | SystemTable<T>; | |
type EventLike = |