bool CallActions(HookEventInfo info) { for (var i = EventActions.Count; i-->0;) { if (EventActions[i].Event != info.type) continue; if (EventActions[i].NeedsTag & EventActions[i].RequiredTag.Equals(info.tag, StringComparison.OrdinalIgnoreCase)) continue; EventActions[i].CachedEventInfo = info; EventActions[i].OnInitialize(this, Time.realtimeSinceStartup); return true; } return false; }
void OnResourceGained() { if (EventActions.Count == 0) return; var he = new HookEventInfo() { type = TutorialEventType.ResourceGained }; if (CallActions(he)) { FungusResources.OnResourceGain -= OnResourceGained; } }
void OnSpawnerSpawned(Entity e, EntitySpawner spawner, string tutorialtag) { if (EventActions.Count == 0) return; var he = new HookEventInfo() {LinkedEntity = e, LinkedSpawner = spawner, tag = tutorialtag, type = TutorialEventType.SpawnerSpawned}; if (CallActions(he)) { EntitySpawner.OnSpawn -= OnSpawnerSpawned; } }
bool OnPoliceAlarmed(Entity e) { if (EventActions.Count == 0) return false; var he = new HookEventInfo() { LinkedEntity = e, type = TutorialEventType.PoliceAlarmed }; return CallActions(he); }
void OnNodeDestroyed(Entity e) { if (EventActions.Count == 0) return; var he = new HookEventInfo() { LinkedEntity = e, type = TutorialEventType.NodeDestroyed }; if (CallActions(he)) { GameWorld.OnNodeDestroyed -= OnNodeDestroyed; } }
void OnEntityDamaged(Entity e) { if (EventActions.Count == 0) return; if (!(e is Human)) return; var he = new HookEventInfo() {LinkedEntity = e, type = TutorialEventType.HumanDamaged}; if (CallActions(he)) { Entity.OnDamaged -= OnEntityDamaged; } }
bool OnCitizenPanic(Entity e) { if (EventActions.Count == 0) return false; var he = new HookEventInfo() { LinkedEntity = e, type = TutorialEventType.CitizenPanic }; return CallActions(he); }
void OnAbilityGained(NodeAbility ability) { if (EventActions.Count == 0) return; var he = new HookEventInfo() { LinkedAbility = ability, type = TutorialEventType.AbilityGained }; if (CallActions(he)) { AbilityBuilding.OnAbilityGained -= OnAbilityGained; } }