Skip to content

Commit aa4d2c7

Browse files
committed
add method OnExit
1 parent f1a0c1a commit aa4d2c7

File tree

3 files changed

+162
-53
lines changed

3 files changed

+162
-53
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ local world = ECS.CreateWorld(
205205
- Get entity compoment data
206206
- _`world.`_**`Set`** _(`entity`, `component`, `...args`)_
207207
- Defines the value of a component for an entity
208+
- _`world.`_**`Dirty`** _(`entity`)_
209+
- It allows informing that this component has undergone some change outside the common flow of systems
210+
```lua
211+
local data = world.Get(entity, Component)
212+
data.Value = 2
213+
world.Dirty(entity)
214+
```
208215
- _`world.`_**`Call`** _(`entity`, `component`, `method`, `...args`)_
209216
- Invokes a utility method from a component's API
210217
- _`world.`_**`Remove`** _(`entity`, `component`)_
@@ -330,7 +337,7 @@ Represents the logic that transforms component data of an entity from its curren
330337

331338
In **Roblox-ECS**, a system has a strong connection with component types. You must define which components this system works on in the `System` registry.
332339

333-
If the `update` method is implemented, it will be invoked respecting the order parameter within the configured step. Whenever an entity with the characteristics expected by this system is added on world, the system is informed via the `onEnter` method.
340+
If the `Update` method is implemented, it will be invoked respecting the order parameter within the configured step. Whenever an entity with the characteristics expected by this system is added on world, the system is informed via the `OnEnter` method. When these characteristics are lost, the `OnExit` method is invoked
334341

335342
```lua
336343
local ECS = require(game.ReplicatedStorage:WaitForChild("ECS"))
@@ -369,6 +376,12 @@ return ECS.RegisterSystem({
369376
return false
370377
end,
371378

379+
-- [Optional] Invoked when an entity loses these characteristics
380+
OnExit = function(time, world, entity, index, weapons)
381+
print('Entity loses these characteristics ', entity)
382+
return false
383+
end,
384+
372385
-- [Optional] Invoked when an entity with these characteristics is removed
373386
OnRemove = function(time, world, entity, index, weapons)
374387
-- on new entity

0 commit comments

Comments
 (0)