Esempio n. 1
0
 private Vector3 GetFollowPos()
 {
     if ((UnityEngine.Object)followTarget != (UnityEngine.Object)null)
     {
         Vector3             result    = followTarget.transform.GetPosition();
         KAnimControllerBase component = followTarget.GetComponent <KAnimControllerBase>();
         if ((UnityEngine.Object)component != (UnityEngine.Object)null)
         {
             result = component.GetWorldPivot();
         }
         return(result);
     }
     return(Vector3.zero);
 }
    public void Refresh(AmountInstance value_src)
    {
        GameObject gameObject = value_src.gameObject;

        if (!((Object)gameObject == (Object)null))
        {
            KAnimControllerBase component = gameObject.GetComponent <KAnimControllerBase>();
            Vector3             a         = (!((Object)component != (Object)null)) ? (gameObject.transform.GetPosition() + Vector3.down) : component.GetWorldPivot();
            base.transform.SetPosition(a + offset);
            if (value_src != null)
            {
                progressFill.transform.parent.gameObject.SetActive(true);
                float   num        = value_src.value / value_src.GetMax();
                Vector3 localScale = progressFill.rectTransform.localScale;
                localScale.y = num;
                progressFill.rectTransform.localScale = localScale;
                progressToolTip.toolTip = DUPLICANTS.ATTRIBUTES.IMMUNITY.NAME + " " + GameUtil.GetFormattedPercent(num * 100f, GameUtil.TimeSlice.None);
            }
            else
            {
                progressFill.transform.parent.gameObject.SetActive(false);
            }
            int     num2    = 0;
            Amounts amounts = gameObject.GetComponent <Modifiers>().GetAmounts();
            foreach (Disease resource in Db.Get().Diseases.resources)
            {
                float value = amounts.Get(resource.amount).value;
                if (value > 0f)
                {
                    Image image = null;
                    if (num2 < displayedDiseases.Count)
                    {
                        image = displayedDiseases[num2];
                    }
                    else
                    {
                        GameObject gameObject2 = Util.KInstantiateUI(germsImage.gameObject, germsImage.transform.parent.gameObject, true);
                        image = gameObject2.GetComponent <Image>();
                        displayedDiseases.Add(image);
                    }
                    image.color = resource.overlayColour;
                    ToolTip component2 = image.GetComponent <ToolTip>();
                    component2.toolTip = resource.Name + " " + GameUtil.GetFormattedDiseaseAmount((int)value);
                    num2++;
                }
            }
            for (int num3 = displayedDiseases.Count - 1; num3 >= num2; num3--)
            {
                Util.KDestroyGameObject(displayedDiseases[num3].gameObject);
                displayedDiseases.RemoveAt(num3);
            }
            diseasedImage.enabled = false;
            progressFill.transform.parent.gameObject.SetActive(displayedDiseases.Count > 0);
            germsImage.transform.parent.gameObject.SetActive(displayedDiseases.Count > 0);
        }
    }
Esempio n. 3
0
 public void RenderEveryTick()
 {
     using (new KProfiler.Region("PrioritizableRenderer", null))
     {
         if (!((Object)GameScreenManager.Instance == (Object)null) && !((Object)SimDebugView.Instance == (Object)null) && !(SimDebugView.Instance.GetMode() != OverlayModes.Priorities.ID))
         {
             prioritizables.Clear();
             Grid.GetVisibleExtents(out Vector2I min, out Vector2I max);
             int     height  = max.y - min.y;
             int     width   = max.x - min.x;
             Extents extents = new Extents(min.x, min.y, width, height);
             List <ScenePartitionerEntry> list = new List <ScenePartitionerEntry>();
             GameScenePartitioner.Instance.GatherEntries(extents, GameScenePartitioner.Instance.prioritizableObjects, list);
             foreach (ScenePartitionerEntry item in list)
             {
                 Prioritizable prioritizable = (Prioritizable)item.obj;
                 if ((Object)prioritizable != (Object)null && prioritizable.showIcon && prioritizable.IsPrioritizable() && tool.IsActiveLayer(tool.GetFilterLayerFromGameObject(prioritizable.gameObject)))
                 {
                     prioritizables.Add(prioritizable);
                 }
             }
             if (prioritizableCount != prioritizables.Count)
             {
                 prioritizableCount = prioritizables.Count;
                 vertices           = new Vector3[4 * prioritizableCount];
                 uvs       = new Vector2[4 * prioritizableCount];
                 triangles = new int[6 * prioritizableCount];
             }
             if (prioritizableCount != 0)
             {
                 for (int i = 0; i < prioritizables.Count; i++)
                 {
                     Prioritizable       prioritizable2 = prioritizables[i];
                     Vector3             vector         = Vector3.zero;
                     KAnimControllerBase component      = prioritizable2.GetComponent <KAnimControllerBase>();
                     vector    = ((!((Object)component != (Object)null)) ? prioritizable2.transform.GetPosition() : component.GetWorldPivot());
                     vector.x += prioritizable2.iconOffset.x;
                     vector.y += prioritizable2.iconOffset.y;
                     Vector2 vector2 = new Vector2(0.2f, 0.3f) * prioritizable2.iconScale;
                     float   z       = -5f;
                     int     num     = 4 * i;
                     vertices[num]     = new Vector3(vector.x - vector2.x, vector.y - vector2.y, z);
                     vertices[1 + num] = new Vector3(vector.x - vector2.x, vector.y + vector2.y, z);
                     vertices[2 + num] = new Vector3(vector.x + vector2.x, vector.y - vector2.y, z);
                     vertices[3 + num] = new Vector3(vector.x + vector2.x, vector.y + vector2.y, z);
                     float           num2           = 0.1f;
                     PrioritySetting masterPriority = prioritizable2.GetMasterPriority();
                     float           num3           = -1f;
                     if (masterPriority.priority_class >= PriorityScreen.PriorityClass.high)
                     {
                         num3 += 9f;
                     }
                     if (masterPriority.priority_class >= PriorityScreen.PriorityClass.topPriority)
                     {
                         num3 = num3;
                     }
                     num3 += (float)masterPriority.priority_value;
                     float num4 = num2 * num3;
                     float num5 = 0f;
                     float num6 = num2;
                     float num7 = 1f;
                     uvs[num]     = new Vector2(num4, num5);
                     uvs[1 + num] = new Vector2(num4, num5 + num7);
                     uvs[2 + num] = new Vector2(num4 + num6, num5);
                     uvs[3 + num] = new Vector2(num4 + num6, num5 + num7);
                     int num8 = 6 * i;
                     triangles[num8]     = num;
                     triangles[1 + num8] = num + 1;
                     triangles[2 + num8] = num + 2;
                     triangles[3 + num8] = num + 2;
                     triangles[4 + num8] = num + 1;
                     triangles[5 + num8] = num + 3;
                 }
                 mesh.Clear();
                 mesh.vertices = vertices;
                 mesh.uv       = uvs;
                 mesh.SetTriangles(triangles, 0);
                 mesh.RecalculateBounds();
                 Graphics.DrawMesh(mesh, Vector3.zero, Quaternion.identity, material, layer, GameScreenManager.Instance.worldSpaceCanvas.GetComponent <Canvas>().worldCamera, 0, null, false, false);
             }
         }
     }
 }
Esempio n. 4
0
 private void LateUpdate()
 {
     if (!App.isLoading && !App.IsExiting)
     {
         HashedString x = OverlayModes.None.ID;
         if ((UnityEngine.Object)OverlayScreen.Instance != (UnityEngine.Object)null)
         {
             x = OverlayScreen.Instance.GetMode();
         }
         bool flag = !((UnityEngine.Object)Camera.main == (UnityEngine.Object)null) && Camera.main.orthographicSize < HideDistance && x == OverlayModes.None.ID;
         int  num  = entries.Count;
         int  num2 = 0;
         while (num2 < num)
         {
             if ((UnityEngine.Object)entries[num2].world_go != (UnityEngine.Object)null)
             {
                 Vector3 vector = entries[num2].world_go.transform.GetPosition();
                 if (flag && CameraController.Instance.IsVisiblePos(vector))
                 {
                     RectTransform component = entries[num2].display_go.GetComponent <RectTransform>();
                     if ((UnityEngine.Object)CameraController.Instance != (UnityEngine.Object)null && (UnityEngine.Object)CameraController.Instance.followTarget == (UnityEngine.Object)entries[num2].world_go.transform)
                     {
                         vector = CameraController.Instance.followTargetPos;
                     }
                     else
                     {
                         KAnimControllerBase component2 = entries[num2].world_go.GetComponent <KAnimControllerBase>();
                         if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                         {
                             vector = component2.GetWorldPivot();
                         }
                     }
                     component.anchoredPosition = ((!worldSpace) ? WorldToScreen(vector) : vector);
                     entries[num2].display_go.SetActive(true);
                 }
                 else if (entries[num2].display_go.activeSelf)
                 {
                     entries[num2].display_go.SetActive(false);
                 }
                 if (entries[num2].world_go.HasTag(GameTags.Dead))
                 {
                     entries[num2].bars_go.SetActive(false);
                 }
                 if ((UnityEngine.Object)entries[num2].bars_go != (UnityEngine.Object)null)
                 {
                     GameObject bars_go = entries[num2].bars_go;
                     bars_go.GetComponentsInChildren(false, workingList);
                     foreach (KCollider2D working in workingList)
                     {
                         working.MarkDirty(false);
                     }
                 }
                 num2++;
             }
             else
             {
                 UnityEngine.Object.Destroy(entries[num2].display_go);
                 num--;
                 entries[num2] = entries[num];
             }
         }
         entries.RemoveRange(num, entries.Count - num);
     }
 }