using UnityEngine; namespace IdleSpectator; /// Unit-owned emits for deferred Phase 2 libraries (spells/items/decisions/etc.). public static class DeferredInterestFeed { public static void EmitSpell(string spellId, Actor caster) { EmitFromCatalog( "spell", spellId, caster, EventCatalog.Spell.GetOrFallback, related: null, locationOnly: false); } public static void EmitItem(string itemId, Actor craftsman) { EmitFromCatalog( "item", itemId, craftsman, EventCatalog.Item.GetOrFallback, related: null, locationOnly: false); } public static void EmitDecision(string decisionId, Actor actor) { EmitFromCatalog( "decision", decisionId, actor, EventCatalog.Decision.GetOrFallback, related: null, locationOnly: false); } public static void EmitPower(string powerId, Vector3 position, Actor nearUnit) { DiscreteEventEntry entry = EventCatalog.Power.GetOrFallback(powerId); if (!AgentHarness.LiveFeedsAllowed) { InterestDropLog.Record("busy", "power"); return; } if (!EventCatalog.IsCameraWorthy(entry)) { InterestDropLog.Record("createsInterest=false", "power:" + (powerId ?? "")); return; } if (nearUnit != null && nearUnit.isAlive()) { EmitFromCatalog("power", powerId, nearUnit, EventCatalog.Power.GetOrFallback, null, false); return; } if (position == Vector3.zero) { return; } EventFeedUtil.Register( "power:" + entry.Id, "power", entry.Category, EventReason.Library(null, "power", entry.Id), entry.Id, entry.EventStrength, position, follow: null, locationOnly: true); } public static void EmitSubspeciesTrait(string traitId, Actor anchor) { EmitFromCatalog( "subspecies_trait", traitId, anchor, EventCatalog.SubspeciesTrait.GetOrFallback, related: null, locationOnly: false); } public static void EmitGene(string geneId, Actor actor) { EmitFromCatalog( "gene", geneId, actor, EventCatalog.Gene.GetOrFallback, related: null, locationOnly: false); } public static void EmitPhenotype(string phenotypeId, Actor actor) { EmitFromCatalog( "phenotype", phenotypeId, actor, EventCatalog.Phenotype.GetOrFallback, related: null, locationOnly: false); } public static void EmitWorldLaw(string lawId, Vector3 position) { if (!AgentHarness.LiveFeedsAllowed || position == Vector3.zero) { return; } DiscreteEventEntry entry = EventCatalog.WorldLaw.GetOrFallback(lawId); if (!EventCatalog.IsCameraWorthy(entry)) { InterestDropLog.Record("createsInterest=false", entry.Id ?? ""); return; } EventFeedUtil.Register( "worldlaw:" + entry.Id, "worldlaw", entry.Category, EventReason.Library(null, "worldlaw", entry.Id), entry.Id, entry.EventStrength, position, follow: null, locationOnly: true); } public static void EmitCultureTrait(string traitId, Actor anchor) { EmitFromCatalog( "culture_trait", traitId, anchor, EventCatalog.CultureTrait.GetOrFallback, related: null, locationOnly: false); } public static void EmitReligionTrait(string traitId, Actor anchor) { EmitFromCatalog( "religion_trait", traitId, anchor, EventCatalog.ReligionTrait.GetOrFallback, related: null, locationOnly: false); } public static void EmitClanTrait(string traitId, Actor anchor) { EmitFromCatalog( "clan_trait", traitId, anchor, EventCatalog.ClanTrait.GetOrFallback, related: null, locationOnly: false); } public static void EmitLanguageTrait(string traitId, Actor anchor) { EmitFromCatalog( "language_trait", traitId, anchor, EventCatalog.LanguageTrait.GetOrFallback, related: null, locationOnly: false); } public static void EmitBiome(string biomeId, Vector3 position) { if (!AgentHarness.LiveFeedsAllowed || position == Vector3.zero) { return; } DiscreteEventEntry entry = EventCatalog.Biome.GetOrFallback(biomeId); if (!EventCatalog.IsCameraWorthy(entry)) { InterestDropLog.Record("createsInterest=false", entry.Id ?? ""); return; } EventFeedUtil.Register( "biome:" + entry.Id, "biome", entry.Category, EventReason.Library(null, "biome", entry.Id), entry.Id, entry.EventStrength, position, follow: null, locationOnly: true); } private static void EmitFromCatalog( string source, string assetId, Actor subject, System.Func lookup, Actor related, bool locationOnly) { if (!AgentHarness.LiveFeedsAllowed || lookup == null) { return; } DiscreteEventEntry entry = lookup(assetId); if (!EventCatalog.IsCameraWorthy(entry)) { InterestDropLog.Record("createsInterest=false", entry.Id ?? ""); return; } Actor follow = subject != null && subject.isAlive() ? subject : null; if (!locationOnly && follow == null) { return; } string label = EventReason.Library(follow, source, entry.Id); if (follow == null) { label = EventReason.HumanizeId(entry.Id); } string key = source + ":" + entry.Id + ":" + EventFeedUtil.SafeId(follow); EventFeedUtil.Register( key, source, entry.Category, label, entry.Id, entry.EventStrength, follow != null ? follow.current_position : Vector3.zero, follow, related: related, locationOnly: locationOnly); } }