0.2.0-ts.3 • Published 5 months ago
@rbxts/gorp v0.2.0-ts.3
Fork of gorp for Roblox-ts.
Notice
It is preferred that you use jabby / ebba for new work.
Differences to Luau version
- This package is versioned with <gorp version>-ts.<x>where x is incremented for any changes to the TS version in particular.
Code sample with ecr
The following requires the gorp-ecr package
Server
import ecr from "@rbxts/ecr";
import gorp from "@rbxts/gorp";
import gorp_ecr from "@rbxts/gorp-ecr";
// Required, sets up the ecs layer for ecr
gorp_ecr.init({ ecr, gorp });Client
import ecr from "@rbxts/ecr";
import gorp from "@rbxts/gorp";
import gorp_ecr from "@rbxts/gorp-ecr";
// Required, sets up the ecs layer for ecr
gorp_ecr.init({ ecr, gorp });
// Create components
const Position = ecr.component(() => Vector3.zero);
const Velocity = ecr.component<Vector3>();
// Assign names to components
gorp.names({ pos: Position, vel: Velocity });
// Create world and assign name
const world = ecr.registry();
gorp.hook_world(world, "main_world");
// Get the client and mount the selector interface
const client = gorp.get_client();
client.gorp_selector();
// Create entity, assign components
const ent = world.create();
world.add(ent, Position);
world.set(ent, Velocity, Vector3.xAxis);
// Create scheduler
const scheduler = gorp.scheduler("main_scheduler");
function position_system(dt: number) {
	for (const [id, pos, vel] of world.view(Position, Velocity)) {
		world.set(id, Position, pos.add(vel.mul(dt)));
	}
}
// Run the system every frame in the scheduler
game.GetService("RunService").RenderStepped.Connect((dt) => {
	scheduler.system("position_system", position_system, dt);
	scheduler.finish();
});
// Connect F keybind to toggle the interface
game.GetService("UserInputService").InputBegan.Connect((input) => {
	if (input.KeyCode === Enum.KeyCode.F) {
		client.enabled(!client.enabled());
	}
});0.2.0-ts.1
12 months ago
0.2.0-ts.2
5 months ago
0.2.0-ts.3
5 months ago
0.2.0-ts.0
1 year ago
0.1.1-ts.0
2 years ago
0.1.0-ts.0
2 years ago