コード例 #1
0
    private void RefreshCharts()
    {
        float time = GameClock.Instance.GetTime();
        float num  = 3000f;

        foreach (KeyValuePair <Tag, GameObject> categoryRow in categoryRows)
        {
            HierarchyReferences component         = categoryRow.Value.GetComponent <HierarchyReferences>();
            ResourceTracker     resourceStatistic = TrackerTool.Instance.GetResourceStatistic(ClusterManager.Instance.activeWorldId, categoryRow.Key);
            if (resourceStatistic != null)
            {
                SparkLayer             reference = component.GetReference <SparkLayer>("Chart");
                Tuple <float, float>[] array     = resourceStatistic.ChartableData(num);
                if (array.Length != 0)
                {
                    reference.graph.axis_x.max_value = array[array.Length - 1].first;
                }
                else
                {
                    reference.graph.axis_x.max_value = 0f;
                }
                reference.graph.axis_x.min_value = time - num;
                reference.RefreshLine(array, "resourceAmount");
            }
            else
            {
                DebugUtil.DevLogError("DevError: No tracker found for resource category " + categoryRow.Key);
            }
        }
        foreach (KeyValuePair <Tag, GameObject> resourceRow in resourceRows)
        {
            HierarchyReferences component          = resourceRow.Value.GetComponent <HierarchyReferences>();
            ResourceTracker     resourceStatistic2 = TrackerTool.Instance.GetResourceStatistic(ClusterManager.Instance.activeWorldId, resourceRow.Key);
            if (resourceStatistic2 != null)
            {
                SparkLayer             reference2 = component.GetReference <SparkLayer>("Chart");
                Tuple <float, float>[] array2     = resourceStatistic2.ChartableData(num);
                if (array2.Length != 0)
                {
                    reference2.graph.axis_x.max_value = array2[array2.Length - 1].first;
                }
                else
                {
                    reference2.graph.axis_x.max_value = 0f;
                }
                reference2.graph.axis_x.min_value = time - num;
                reference2.RefreshLine(array2, "resourceAmount");
            }
            else
            {
                DebugUtil.DevLogError("DevError: No tracker found for resource " + resourceRow.Key);
            }
        }
    }
コード例 #2
0
    private void OnDeserialized()
    {
        if (ElementID == (SimHashes)351109216)
        {
            ElementID = SimHashes.Creature;
        }
        SanitizeMassAndTemperature();
        float temperature = _Temperature;

        if (float.IsNaN(temperature) || float.IsInfinity(temperature) || temperature < 0f || 10000f < temperature)
        {
            DeserializeWarnings.Instance.PrimaryElementTemperatureIsNan.Warn($"{base.name} has invalid temperature of {Temperature}. Resetting temperature.", null);
            temperature = Element.defaultValues.temperature;
        }
        _Temperature = temperature;
        Temperature  = temperature;
        if (Element == null)
        {
            DeserializeWarnings.Instance.PrimaryElementHasNoElement.Warn(base.name + "Primary element has no element.", null);
        }
        if (Mass < 0f)
        {
            DebugUtil.DevLogError(base.gameObject, "deserialized ore with less than 0 mass. Error! Destroying");
            Util.KDestroyGameObject(base.gameObject);
        }
        else
        {
            if (onDataChanged != null)
            {
                onDataChanged(this);
            }
            byte index = Db.Get().Diseases.GetIndex(diseaseID);
            if (index == 255 || diseaseCount <= 0)
            {
                if (diseaseHandle.IsValid())
                {
                    GameComps.DiseaseContainers.Remove(base.gameObject);
                    diseaseHandle.Clear();
                }
            }
            else if (diseaseHandle.IsValid())
            {
                DiseaseHeader header = GameComps.DiseaseContainers.GetHeader(diseaseHandle);
                header.diseaseIdx   = index;
                header.diseaseCount = diseaseCount;
                GameComps.DiseaseContainers.SetHeader(diseaseHandle, header);
            }
            else
            {
                diseaseHandle = GameComps.DiseaseContainers.Add(base.gameObject, index, diseaseCount);
            }
        }
    }