Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query budgets (debugger) #107

Merged
merged 16 commits into from
Aug 13, 2024
Merged

Conversation

Nidoxs
Copy link
Contributor

@Nidoxs Nidoxs commented Aug 11, 2024

Closes #106 (once PR is ready for review)

@Nidoxs Nidoxs marked this pull request as draft August 11, 2024 16:10
@Nidoxs Nidoxs changed the title First draft for query budgets in debugger Query budgets (debugger) Aug 11, 2024
@Ukendio Ukendio marked this pull request as ready for review August 11, 2024 21:45
Ukendio
Ukendio previously approved these changes Aug 11, 2024
@jackTabsCode
Copy link
Contributor

Can I get a few screenshots of this in action on a system, and the code that's in the system?

@Nidoxs
Copy link
Contributor Author

Nidoxs commented Aug 13, 2024

@jackTabsCode

Can I get a few screenshots of this in action on a system, and the code that's in the system?

https://i.gyazo.com/d82555ce5afdb2dbcdd500e0d9f998d1.gif

mothershipsSpawnRoombas.luau

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Components = require(ReplicatedStorage.Shared.components)
local Matter = require(ReplicatedStorage.Lib.Matter)

local function mothershipsSpawnRoombas(world)
	for id, model, lasering, transform in
		world:query(Components.Model, Components.Lasering, Components.Transform, Components.Mothership)
	do
		model.model.Beam.Transparency = 1 - lasering.remainingTime

		lasering = lasering:patch({
			remainingTime = lasering.remainingTime - Matter.useDeltaTime(),
		})

		if not lasering.spawned then
			local spawnPosition = Vector3.new(transform.cframe.p.X, 11, transform.cframe.p.Z)

			world:spawn(
				Components.Roomba(),
				Components.Charge({
					charge = 100,
				}),
				Components.Transform({
					cframe = CFrame.new(spawnPosition),
				})
			)

			lasering = lasering:patch({ spawned = true })
		end

		if lasering.remainingTime <= 0 then
			world:remove(id, Components.Lasering)
		else
			world:insert(id, lasering)
		end
	end
end

return mothershipsSpawnRoombas

playersAreTargets.luau

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Components = require(ReplicatedStorage.Shared.components)
local Matter = require(ReplicatedStorage.Lib.Matter)

local function playersAreTargets(world)
	for _, player in ipairs(Players:GetPlayers()) do
		for _, character in Matter.useEvent(player, "CharacterAdded") do
			world:spawn(
				Components.Target(),
				Components.Model({
					model = character,
				})
			)
		end
	end

	-- players can die
	for id in world:query(Components.Target):without(Components.Model) do
		world:despawn(id)
	end
end

return playersAreTargets

@Nidoxs
Copy link
Contributor Author

Nidoxs commented Aug 13, 2024

image

@Nidoxs
Copy link
Contributor Author

Nidoxs commented Aug 13, 2024

image
Added semantic colouring for resource usage

@Nidoxs
Copy link
Contributor Author

Nidoxs commented Aug 13, 2024

image

Copy link
Contributor

@metrowaii metrowaii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Ukendio Ukendio merged commit 88b9a64 into matter-ecs:main Aug 13, 2024
6 checks passed
@Nidoxs Nidoxs deleted the debugger-query-budgets branch August 14, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debugger - Query Budgets
4 participants