74 lines
1.8 KiB
Dart
74 lines
1.8 KiB
Dart
import 'package:flame/components.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:shitman/attributes/resetable.dart';
|
|
import 'package:shitman/game/shitman_game.dart';
|
|
import 'package:shitman/services/log_service.dart';
|
|
|
|
/// Base class for all components in the Shitman game.
|
|
/// This class can be extended to create specific game components.
|
|
abstract class ShitComponent extends PositionComponent
|
|
with Resetable, HasGameReference<ShitmanGame>, AppLogging {
|
|
bool get isStationary => false;
|
|
|
|
ShitComponent({
|
|
super.position,
|
|
super.size,
|
|
super.scale,
|
|
super.angle,
|
|
super.nativeAngle = 0,
|
|
super.anchor,
|
|
super.children,
|
|
super.priority,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
await super.onLoad();
|
|
// Additional initialization logic can go here
|
|
}
|
|
}
|
|
|
|
abstract class DecorativeShit extends ShitComponent {}
|
|
|
|
abstract class InteractiveShit extends ShitComponent {}
|
|
|
|
mixin Stationary on ShitComponent {
|
|
/// Whether the item is stationary
|
|
@override
|
|
final bool isStationary = true;
|
|
}
|
|
|
|
mixin Ambulatory on ShitComponent {
|
|
/// Whether the item is stationary
|
|
@override
|
|
final bool isStationary = false;
|
|
|
|
/// Method to handle ambulatory behavior
|
|
void handleAmbulatory() {
|
|
// Logic for ambulatory items, e.g., moving around
|
|
}
|
|
}
|
|
|
|
mixin Collectible on InteractiveShit {
|
|
bool _isCollected = false;
|
|
bool _isCollectible = true;
|
|
|
|
/// Whether the item is collected
|
|
bool get isCollected => _isCollected;
|
|
|
|
/// Whether the item can be collected
|
|
bool get isCollectible => _isCollectible;
|
|
|
|
/// Set the item as collectible
|
|
void setCollectible(bool value) {
|
|
_isCollectible = value;
|
|
}
|
|
|
|
/// Method to collect the item
|
|
@mustCallSuper
|
|
void collect() {
|
|
_isCollected = true;
|
|
// Additional logic for collecting the item
|
|
}
|
|
}
|