-
Notifications
You must be signed in to change notification settings - Fork 2
Customer Interaction
This component allows the player to interact with customer entities within the game. It utilizes CustomerSensorComponent to detect whether a customer is within a certain range of the player. When the player is close enough, it triggers events for customer-related interactions.
The create() method initialises the CustomerSensorComponent and sets up event listeners for customer interactions. The component listens for collisions that signal the player is near a customer.
@Override
public void create() {
entity.getEvents().addListener("collisionStart", this::onCollisionStart);
entity.getEvents().addListener("collisionEnd", this::onCollisionEnd);
this.interactionComponent = entity.getComponent(InteractionComponent.class);
super.create();
}
This method is triggered when the player's sensor collides with a customer entity. It checks if the interaction is valid (for example, the player is within range of a customer) and adds the customer to the list of colliding fixtures if they are close enough.
public void onCollisionStart(Fixture me, Fixture other) {
if (interactionComponent.getFixture() != me) {
return;
}
if (!PhysicsLayer.contains(targetLayer, other.getFilterData().categoryBits)) {
return;
}
if (isWithinDistance(other, sensorDistance)) {
collidingFixtures.add(other);
}
updateFixtures();
}
This method updates the list of colliding fixtures (customers). It removes any customer entities that are no longer within range and updates the closestFixture and closestDistance variables to point to the nearest customer.
private void updateFixtures() {
Set<Fixture> toRemove = new HashSet<>();
for (Fixture fixture : collidingFixtures) {
float dist = getFixtureDistance(fixture);
if (dist > sensorDistance) {
toRemove.add(fixture);
} else if (closestDistance < sensorDistance || dist < closestDistance) {
closestDistance = dist;
closestFixture = fixture;
}
}
collidingFixtures.removeAll(toRemove);
}
Inventory System
Scoring System
Food Recipes
Level System
Player Actions
Ordering System
Stations
Items
Map Design
Customers
Pause Menu
Upgrades
End of Day Display
Day Night Cycle
Moral System
Debug Terminal
Game Interactions Tutorial
Backstory Cutscenes
Entities and Components
Input Handling
Game Screens and Areas
Fire Extinguisher Handler Component
MainGameActions Create Docket Triggers
Main Game Order Button Display
BackstoryCutsceneDisplay Test Plan
Test Plan for MainGameOrderTicketDisplay
Test Plan for MainGameOrderBtnDisplay
Test Plan for DocketLineDisplay
Test plan for RandomComboService
Test plan for SpeedBoostUpgrade
Test plan for DancePartyUpgrade