Skip to content

Commit

Permalink
update signal example
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Jan 14, 2025
1 parent 828d70e commit 8cb0194
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Tests/ECS/Examples/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,17 @@ public static void AddSignalHandler()
var store = new EntityStore();
var player = store.CreateEntity(1);
player.AddSignalHandler<CollisionSignal>(signal => {
Console.WriteLine($"player collision with entity: {signal.Event.other.Id}");
// > player collision with entity: 2
Console.WriteLine($"collision signal - entity: {signal.Entity.Id} other: {signal.Event.other.Id}");
});
var npc = store.CreateEntity(2);
// ... detect collision. e.g. with a collision system. In case of collision:
player.EmitSignal(new CollisionSignal{ other = npc });
}

/* Output
collision signal - entity: 1 other: 2
*/

}

}

0 comments on commit 8cb0194

Please sign in to comment.