public override void DoPostConfigureComplete(GameObject go)
 {
     BuildingTemplates.DoPostConfigure(go);
     go.GetComponent <KPrefabID>().prefabSpawnFn += (KPrefabID.PrefabFn)(game_object =>
     {
         HandleVector <int> .Handle handle = GameComps.StructureTemperatures.GetHandle(game_object);
         StructureTemperatureData data     = GameComps.StructureTemperatures.GetData(handle);
         int cell = Grid.PosToCell(game_object);
         data.OverrideExtents(new Extents(cell, RadiumFuelConfig.overrideOffsets));
         GameComps.StructureTemperatures.SetData(handle, data);
     });
 }
Esempio n. 2
0
            private static void Postfix(StructureTemperatureComponents __instance)
            {
                var operatingEnergyStatusItem = Traverse.Create((object)__instance).Field("operatingEnergyStatusItem").GetValue <StatusItem>();
                var handleInstanceMap         = Traverse.Create((object)__instance).Field("handleInstanceMap").GetValue <Dictionary <int, HandleVector <int> .Handle> >();

                if (operatingEnergyStatusItem == null || handleInstanceMap == null)
                {
                    return;
                }

                operatingEnergyStatusItem.resolveStringCallback = (Func <string, object, string>)((str, ev_data) =>
                {
                    int index = (int)ev_data;
                    StructureTemperatureData data = __instance.GetData(handleInstanceMap[index]);
                    if (str != (string)BUILDING.STATUSITEMS.OPERATINGENERGY.TOOLTIP)
                    {
                        try
                        {
                            str = string.Format(str, GameUtil.GetFormattedWattage((float)(data.TotalEnergyProducedKW * 1000.0 * 0.00499999988824129)));
                        }
                        catch (Exception ex)
                        {
                            Debug.LogWarning(ex, null);
                            Debug.LogWarning(BUILDING.STATUSITEMS.OPERATINGENERGY.TOOLTIP, null);
                            Debug.LogWarning(str, null);
                        }
                    }
                    else
                    {
                        string empty = string.Empty;
                        foreach (StructureTemperatureData.EnergySource energySource in data.energySourcesKW)
                        {
                            empty += string.Format(BUILDING.STATUSITEMS.OPERATINGENERGY.LINEITEM, energySource.source, GameUtil.GetFormattedWattage((float)(energySource.value * 1000.0 * 0.00499999988824129)));
                        }
                        str = string.Format((LocString)"This building is producing {0} of energy\n\nSources:\n{1}", GameUtil.GetFormattedWattage((float)(data.TotalEnergyProducedKW * 1000.0 * 0.00499999988824129)), empty);
                    }
                    return(str);
                });
            }