2.2 5-Phase Customer Generation Pipeline & Debug Priority Insertion
This section examines the decompiled IL execution flow of PlayerStore.OnShutterOpened and StoreClientManager.GenerateClient in Assembly-CSharp.dll, the 7-step eligibility filter in HandleGenerationPhase, and how ForceInsertClientAtFront guarantees top-of-queue placement.
1. Decompiled Morning Shutter & GenerateClient() Execution Flow
text
StoreShutterButton.OpenShutter()
├── 1. PlayerStore.Instance.OnShutterOpened()
│ ├── CheckCrime() / SoldItem.HandleSoldItem()
│ ├── this.storeClientManager.GenerateClient()
│ │ ├── ModHook.FireOnGenerateCustomerVeryEarly(this)
│ │ ├── [Vanilla fixed-day story customer generation]
│ │ ├── ModHook.FireOnGenerateCustomerEarly(this)
│ │ ├── [Vanilla regular customer pool sampling]
│ │ ├── ModHook.FireOnGenerateCustomerNormal(this)
│ │ ├── [Vanilla specialist & showcase customer generation]
│ │ ├── ModHook.FireOnGenerateCustomerLate(this)
│ │ ├── this.ClientGenCheck()
│ │ ├── this.HandleJohnSmithVandalVisit() // <-- Calls AddNextClient, inserting at index 0!
│ │ ├── LouBombHelper.QueueVisit(this) // <-- Calls AddNextClient, inserting at index 0!
│ │ └── ModHook.FireOnGenerateCustomerVeryLate(this)
│ ├── this.HandleFutureClientQueue() // Appends scheduled future clients to clientStack
│ ├── this.storeClientManager.clientStack.RemoveAll(c => c == null)
│ └── this.LogQueuedClient() // Logs today's queued client list to F8 console
│
├── 2. PlayerStore.Instance.OpenShutter()
│ └── this.storeState = PlayerStore.StoreState.OPEN (value 1)
│
├── 3. StoreShutterButton.OnShutterDoorOpenMorning()
│ ├── ModHook.FireOnShutterOpenedEarly()
│ ├── [Spawns morning newspaper, tutorial book, gun license, dividends]
│ └── ModHook.FireOnShutterOpenedLate() // <-- Framework verifies index 0 & auto-calls door!
│
└── 4. PlayerStore.Instance.OnLateShutterOpen()
└── [Checks SetupWaitingClient for morning door events]2. ForceInsertClientAtFront Bypassing Vanilla Blacklist Guards
Decompiling StoreClientManager.AddNextClient(StoreClient) reveals two silent guards (IsClientBlockedByKnownSnitch and IsClientBlockedByBannedCommissary) that can silently drop a summoned customer. ForceInsertClientAtFront deduplicates any earlier natural spawn of the same NPC, inserts directly into mgr.clientStack.Insert(0, client), registers tracking via mgr.TrackClient(client), and schedules TryCallNextClient() once the shutter opens:
csharp
internal static bool ForceInsertClientAtFront(StoreClientManager mgr, NpcRegistrationEntry entry, bool autoCallIfDoorEmpty, bool delayedCall)
{
if (mgr == null || entry == null) return false;
var client = BuildSafeClient(entry);
if (client == null) return false;
if (mgr.clientStack == null)
mgr.clientStack = new List<StoreClient>();
string targetId = client.identifier ?? entry.Id;
mgr.clientStack.RemoveAll(c => c != null && string.Equals(c.identifier, targetId, StringComparison.OrdinalIgnoreCase));
mgr.clientStack.Insert(0, client);
mgr.TrackClient(client);
int day = StoreStation.Instance != null ? StoreStation.Instance.dayCounter : 1;
RecordSpawn(entry, day);
entry.OnSpawned?.Invoke();
if (autoCallIfDoorEmpty)
ScheduleAutoCallFirstClient(delayedCall);
return true;
}