Skip to main content
Version: 0.15.0

Service Points

A service point is a place where staff come to serve whoever is waiting: a shop counter, a bar, a market stall. When someone stands at it, a member of staff stops what they are doing, walks to their side of the counter, serves, and goes back to the task they left.

The customer can be an agent or the player.

Service points are built on Interrupts. Read that page first for interrupt kinds, marks and how reactions are authored.

The short version​

  1. Create an Interrupt Kind, such as ServeCustomer, with a weight above the work weight, which is 0.7 by default. See Weight.
  2. In the staff's job, add a duty with its Event Kind set to that kind. Beneath it, add a Go to Interrupt Target action with an endpoint behaviour for the serve. See In a job or a need.
  3. Add a Mark Group with a mark where the staff should stand.
  4. Add a child object to the counter with a Box Collider covering where customers stand, and add the ServicePoint component to it.
  5. Set Serve Kind and Staff Marks.

The Service Point component​

The component's collider is the customer side. Anyone standing inside it is a customer. It needs to be a trigger with a kinematic Rigidbody, and adding the component sets both up for you.

FieldWhat it does
Serve KindThe interrupt kind offered to staff. Their job needs a duty with this as its Event Kind
Staff MarksWhere a serving member of staff stands. Required
Staff BuildingOptional. The building whose workers are the staff. Leave empty to use the building that lists the item this point is on
Staff Role Id FilterOptional. Only staff in a position with this role id are asked
Explicit StaffA list of agents to ask. Used only when no building is found
Reoffer Interval SecondsSeconds between attempts to find someone to serve a waiting customer
Serve Once Per VisitOn, each customer is served once until they walk away. Off, they are served again after the cooldown below
Reserve Cooldown SecondsWith Serve Once Per Visit off, how long after a serve before the same customer is served again
Staff Refresh SecondsHow often the list of staff is worked out again
warning

With no Staff Marks assigned, nobody can be sent to serve. The Console warns about this when the scene starts.

Who the staff are​

Staff are the agents with a position at the service point's building.

The building is found from the item. Put the service point on the counter item or on a child of it, and make sure the counter is in its building's item list. See Buildings. To use a different building, assign Staff Building.

Use Staff Role Id Filter when only some of the building's workers should serve, such as the barkeeper and not the cook.

If no building is found, the agents in Explicit Staff are used instead.

How a customer is served​

While a customer is waiting, the service point asks its staff, nearest first, until one accepts.

  • Each customer gets one member of staff, and each member of staff serves one customer at a time.
  • A second customer is served when someone is free.
  • A serve that fails is tried again on the next round.
  • A customer who walks away before being served sends their server back to work.

Staff are asked at the Firm tier, so a shopkeeper part way through tidying a shelf stops and comes over. A seated member of staff is not interrupted.

Staff are only asked while they are at work. A shopkeeper who has gone to lunch during their shift still comes back to serve, as long as the kind's weight beats the need that sent them. One whose shift has ended does not.

Customers already standing at the counter when the scene starts, or after a game is loaded, are picked up as well.

The player as a customer​

The player counts as a customer when the player object has an agent service on it, such as PlayerAgentService, and a collider that enters the service point.

Reacting when a customer is served​

CustomerServed is raised once each time a serve finishes. Use it to open a shop window or start a conversation.

csharp
servicePoint.CustomerServed += (customer, staff) =>
{
// open the shop for this customer
};

Sending agents to the counter​

A service point serves whoever arrives. It does not bring anyone to it.

To have agents visit, add a Solo Interest Spot to the counter with its own kind, and give that kind a reaction that waits at the counter for long enough to be served. The Interrupt Scene does this with its VisitShop kind.

Common problems​

SymptomCause
Nobody comes to serveStaff Marks is empty, the counter is not in its building's item list, or Staff Role Id Filter matches nobody
Staff decline with NoHandlerForKindTheir job has no duty with its Event Kind set to the Serve Kind
Staff decline with HostUnavailableThey are off shift
Staff decline with AbandonRefusedThey are seated, or picking up or dropping off an item. They are asked again on the next round
Staff accept but carry on with their workThe kind's weight does not beat the work weight, 0.7 by default. See Weight
The player is never servedThe player has no agent service, or its collider does not reach the service point's collider
The same customer is never served a second timeServe Once Per Visit is on. They are served again after leaving and coming back
The serve duty runs as part of the normal jobIts Event Kind is empty
Staff walk to the counter and leave at onceThe serve action has no endpoint behaviour

Next step​

Open the Interrupt Scene from Example Scenes and walk up to the counter. For the event itself and offering interrupts from code, see the Interrupt Service.