public override async Task Execute() { var trigger = Entity.Get <PhysicsComponent>(); trigger.ProcessCollisions = true; // Start state machine while (Game.IsRunning) { var firstCollision = await trigger.NewCollision(); var oneContact = firstCollision.Contacts.First(); var shockNormal = oneContact.Normal; if (oneContact.ColliderA.Entity != Entity) { shockNormal *= -1; } var _2dnormal = shockNormal; _2dnormal.Z = 0.0f; var shock = new Shock { Entity = Entity, Normal = _2dnormal }; BrickHit.Broadcast(shock); } }
private void TreatShock(Shock shock) { foreach (var c in Callbacks) { c(shock); } SceneSystem.SceneInstance.RootScene.Entities.Remove(shock.Entity); SceneSystem.SceneInstance.RootScene.Entities.First(e => e.Name == "global script holder") .Components.Get <Level1>().SignalDeletedBrick(shock.Entity); ShockTreatedEK.Broadcast(); }