Skip to content

Game.UI.ImageSystem

Assembly: Assembly-CSharp
Namespace: Game.UI

Type: class

Base: GameSystemBase

Summary:
ImageSystem is a game ECS system that resolves icon and thumbnail URLs for prefabs and instances. It queries PrefabSystem and the EntityManager to find UIObject icons, group icons, thumbnails and falls back to special-case icons for citizens, tourists, commuters, animals, pets and various service vehicles (ambulance, police, fire, delivery, post, hearse, garbage). If thumbnails are disabled in game configuration, it falls back to a placeholder SVG. The system is created and initialized via OnCreate (it caches a PrefabSystem reference).


Fields

  • private const string kPlaceholderIcon = "Media/Placeholder.svg"
    Path to the default placeholder icon used when no icon/thumbnail is available.

  • private const string kCitizenIcon = "Media/Game/Icons/Citizen.svg"
    Icon path used for generic citizens.

  • private const string kTouristIcon = "Media/Game/Icons/Tourist.svg"
    Icon path used for tourists.

  • private const string kCommuterIcon = "Media/Game/Icons/Commuter.svg"
    Icon path used for commuters.

  • private const string kAnimalIcon = "Media/Game/Icons/Animal.svg"
    Icon path used for animals.

  • private const string kPetIcon = "Media/Game/Icons/Pet.svg"
    Icon path used for household pets.

  • private const string kHealthcareIcon = "Media/Game/Icons/Healthcare.svg"
    Icon path used for healthcare service vehicles (ambulance).

  • private const string kDeathcareIcon = "Media/Game/Icons/Deathcare.svg"
    Icon path used for deathcare vehicles (hearse).

  • private const string kPoliceIcon = "Media/Game/Icons/Police.svg"
    Icon path used for police vehicles.

  • private const string kGarbageIcon = "Media/Game/Icons/Garbage.svg"
    Icon path used for garbage trucks.

  • private const string kFireIcon = "Media/Game/Icons/FireSafety.svg"
    Icon path used for fire engines.

  • private const string kPostIcon = "Media/Game/Icons/PostService.svg"
    Icon path used for post vans.

  • private const string kDeliveryIcon = "Media/Game/Icons/DeliveryVan.svg"
    Icon path used for delivery trucks.

  • private PrefabSystem m_PrefabSystem
    Cached reference to the PrefabSystem obtained in OnCreate. Used to resolve prefab entities to PrefabBase and get thumbnail/icon data.

Properties

  • public string placeholderIcon { get; }
    Returns the placeholder icon path ("Media/Placeholder.svg"). Exposed as a convenience read-only property.

Constructors

  • public ImageSystem()
    Default constructor. The system initializes its PrefabSystem reference in OnCreate.

Methods

  • protected override void OnCreate()
    Called when the system is created. Caches a reference to PrefabSystem via World.GetOrCreateSystemManaged(). Marked with [Preserve] to avoid stripping.

  • protected override void OnUpdate()
    Empty OnUpdate override. This system is primarily a utility resolver and does not perform per-frame work here.

  • public static string GetIcon(PrefabBase prefab)
    If the PrefabBase exposes a UIObject component with a non-empty m_Icon, returns that icon path; otherwise returns null. Nullable return (marked [CanBeNull]).

  • public string GetGroupIcon(Entity prefabEntity)
    If the given prefab entity has UIObjectData with a m_Group reference, attempts to resolve that group to a PrefabBase and returns its icon (via GetIcon). Returns null if not found. Uses EntityManager and PrefabSystem.

  • public string GetIconOrGroupIcon(Entity prefabEntity)
    Tries to resolve an icon directly for the prefab entity (via PrefabSystem -> PrefabBase -> GetIcon). If none, falls back to group icon (GetGroupIcon). Returns null when no icon is available.

  • public string GetThumbnail(Entity prefabEntity)
    Resolves the PrefabBase for the given prefab entity and returns a thumbnail URL using GetThumbnail(PrefabBase). Returns null if the prefab can't be resolved.

  • public static string GetThumbnail(PrefabBase prefab)
    If a prefab has an explicit icon (GetIcon), returns that. Otherwise, if GameManager.instance.configuration.noThumbnails is true, returns the placeholder icon. Otherwise builds and returns a thumbnail URL from prefab.thumbnailUrl with width and height (format: "{thumbnailUrl}?width=128&height=128") and logs the URL to the COSystemBase.baseLog.

  • public string GetInstanceIcon(Entity instanceEntity)
    Convenience overload: gets the PrefabRef component from the instance entity and calls GetInstanceIcon(instanceEntity, prefabEntity) using that prefab reference.

  • public string GetInstanceIcon(Entity instanceEntity, Entity prefabEntity)
    Main resolver for instance icons. Logic summary:

  • If the prefab has SpawnableBuildingData, attempts to use the zone prefab's icon/group icon first.
  • Tries icon/group icon for the prefab entity itself.
  • Handles citizens: if instance has Citizen and a HouseholdMember, returns commuter/tourist/citizen icons depending on household data.
  • Handles Animal and HouseholdPet instance components.
  • Recognizes service vehicle prefabs via components: AmbulanceData, PoliceCarData, FireEngineData, DeliveryTruckData, PostVanData, HearseData, GarbageTruckData and returns corresponding icons.
  • If the instance is a ServiceUpgrade, resolves the owner and switches instance/prefab to the owner before further checks.
  • For ServiceObjectData, tries the service prefab's icon/group icon.
  • Checks AggregateElement buffer on the instance to inspect edge prefab references and use their prefab icons if present.
  • For owned properties/renters, resolves the property or zone prefab and returns its icon/group icon if available.
  • Returns null if no icon could be determined. This method uses the EntityManager heavily and relies on PrefabSystem resolution of prefab entities to PrefabBase where needed.

Notes and attributes: - Several methods and the constructor are decorated with [Preserve] in the original code to prevent stripping. - Methods that can return null are marked [CanBeNull] in the source.

Usage Example

// Get the ImageSystem and use it to resolve icons/thumbnails.
var imageSystem = World.GetOrCreateSystemManaged<ImageSystem>();

// For a known prefab entity:
string thumbnail = imageSystem.GetThumbnail(prefabEntity);
if (thumbnail == null) {
    thumbnail = imageSystem.placeholderIcon; // fallback
}

// For an instance entity (entity that has a PrefabRef component):
string icon = imageSystem.GetInstanceIcon(instanceEntity);

// You can also resolve directly from a PrefabBase (if you have one):
string prefabThumb = ImageSystem.GetThumbnail(prefabBase);