|
|
|
@ -1,14 +1,14 @@
|
|
|
|
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
class ContactCallbacksNotifer implements ContactCallbacks {
|
|
|
|
|
final List<ContactCallbacks> _callbacks = [];
|
|
|
|
|
class ContactCallbacksGroup implements ContactCallbacks {
|
|
|
|
|
final List<ContactCallbacks> _contactCallbacks = [];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@mustCallSuper
|
|
|
|
|
void beginContact(Object other, Contact contact) {
|
|
|
|
|
onBeginContact?.call(other, contact);
|
|
|
|
|
for (final callback in _callbacks) {
|
|
|
|
|
for (final callback in _contactCallbacks) {
|
|
|
|
|
callback.beginContact(other, contact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -17,7 +17,7 @@ class ContactCallbacksNotifer implements ContactCallbacks {
|
|
|
|
|
@mustCallSuper
|
|
|
|
|
void endContact(Object other, Contact contact) {
|
|
|
|
|
onEndContact?.call(other, contact);
|
|
|
|
|
for (final callback in _callbacks) {
|
|
|
|
|
for (final callback in _contactCallbacks) {
|
|
|
|
|
callback.endContact(other, contact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -26,7 +26,7 @@ class ContactCallbacksNotifer implements ContactCallbacks {
|
|
|
|
|
@mustCallSuper
|
|
|
|
|
void preSolve(Object other, Contact contact, Manifold oldManifold) {
|
|
|
|
|
onPreSolve?.call(other, contact, oldManifold);
|
|
|
|
|
for (final callback in _callbacks) {
|
|
|
|
|
for (final callback in _contactCallbacks) {
|
|
|
|
|
callback.preSolve(other, contact, oldManifold);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -35,13 +35,13 @@ class ContactCallbacksNotifer implements ContactCallbacks {
|
|
|
|
|
@mustCallSuper
|
|
|
|
|
void postSolve(Object other, Contact contact, ContactImpulse impulse) {
|
|
|
|
|
onPostSolve?.call(other, contact, impulse);
|
|
|
|
|
for (final callback in _callbacks) {
|
|
|
|
|
for (final callback in _contactCallbacks) {
|
|
|
|
|
callback.postSolve(other, contact, impulse);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addCallback(ContactCallbacks callback) {
|
|
|
|
|
_callbacks.add(callback);
|
|
|
|
|
void addContactCallbacks(ContactCallbacks callback) {
|
|
|
|
|
_contactCallbacks.add(callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|