Line data Source code
1 : import './entity.dart'; 2 : 3 : abstract class Component { 4 1 : Component(); 5 : 6 : /// A reference to the entity containing this component. 7 : late Entity ref; 8 : 9 0 : T getComponent<T extends Component>() { 10 0 : return ref.get<T>(); 11 : } 12 : 13 : // Called when the component is added. 14 1 : void onAdded() {} 15 : 16 : // Called when the component is removed. 17 0 : void onRemoved() {} 18 : 19 0 : factory Component.fromJson(Map<String, dynamic> json) => 20 0 : throw UnimplementedError(); 21 : }