Exemplo n.º 1
0
 protected void SetPrioritizable(Prioritizable prioritizable)
 {
     if ((UnityEngine.Object)prioritizable != (UnityEngine.Object)null && prioritizable.IsPrioritizable())
     {
         this.prioritizable = prioritizable;
         masterPriority     = prioritizable.GetMasterPriority();
         prioritizable.onPriorityChanged = (Action <PrioritySetting>)Delegate.Combine(prioritizable.onPriorityChanged, new Action <PrioritySetting>(OnMasterPriorityChanged));
     }
 }
Exemplo n.º 2
0
    private void OnCopySettings(object data)
    {
        GameObject    gameObject = (GameObject)data;
        Prioritizable component  = gameObject.GetComponent <Prioritizable>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            SetMasterPriority(component.GetMasterPriority());
        }
    }
        public HandleVector <int> .Handle AddPickupable(Pickupable pickupable)
        {
            byte   foodQuality = 5;
            Edible component   = pickupable.GetComponent <Edible>();

            if ((Object)component != (Object)null)
            {
                foodQuality = (byte)component.GetQuality();
            }
            byte          masterPriority = 0;
            Prioritizable prioritizable  = null;

            if ((Object)pickupable.storage != (Object)null)
            {
                prioritizable = pickupable.storage.prioritizable;
                if ((Object)prioritizable != (Object)null)
                {
                    PrioritySetting masterPriority2 = prioritizable.GetMasterPriority();
                    masterPriority = (byte)masterPriority2.priority_value;
                }
            }
            Rottable.Instance sMI = pickupable.GetSMI <Rottable.Instance>();
            byte freshness        = 0;

            if (!sMI.IsNullOrStopped())
            {
                freshness = QuantizeRotValue(sMI.RotValue);
            }
            KPrefabID component2 = pickupable.GetComponent <KPrefabID>();
            TagBits   rhs        = new TagBits(ref disallowedTagMask);

            component2.AndTagBits(ref rhs);
            HandleVector <int> .Handle handle = fetchables.Allocate(new Fetchable
            {
                pickupable     = pickupable,
                foodQuality    = foodQuality,
                freshness      = freshness,
                masterPriority = masterPriority,
                tagBitsHash    = rhs.GetHashCode()
            });
            if (!sMI.IsNullOrStopped())
            {
                rotUpdaters[handle] = sMI;
            }
            return(handle);
        }
        public void UpdateStorage(HandleVector <int> .Handle fetchable_handle, Storage storage)
        {
            Fetchable     data           = fetchables.GetData(fetchable_handle);
            byte          masterPriority = 0;
            Prioritizable prioritizable  = null;
            Pickupable    pickupable     = data.pickupable;

            if ((Object)pickupable.storage != (Object)null)
            {
                prioritizable = pickupable.storage.prioritizable;
                if ((Object)prioritizable != (Object)null)
                {
                    PrioritySetting masterPriority2 = prioritizable.GetMasterPriority();
                    masterPriority = (byte)masterPriority2.priority_value;
                }
            }
            data.masterPriority = masterPriority;
            fetchables.SetData(fetchable_handle, data);
        }
Exemplo n.º 5
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);
             }
         }
     }
 }
Exemplo n.º 6
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        Subscribe(2127324410, OnCancelDelegate);
        if ((UnityEngine.Object)rotatable != (UnityEngine.Object)null)
        {
            MarkArea();
        }
        this.fetchList = new FetchList2(storage, Db.Get().ChoreTypes.BuildFetch);
        PrimaryElement component = GetComponent <PrimaryElement>();
        Element        element   = ElementLoader.GetElement(SelectedElementsTags[0]);

        Debug.Assert(element != null, "Missing primary element for Constructable");
        component.ElementID = element.id;
        float num3 = component.Temperature = (component.Temperature = 293.15f);

        Recipe.Ingredient[] allIngredients = Recipe.GetAllIngredients(selectedElementsTags);
        foreach (Recipe.Ingredient ingredient in allIngredients)
        {
            FetchList2 fetchList = this.fetchList;
            Tag        tag       = ingredient.tag;
            num3 = ingredient.amount;
            fetchList.Add(tag, null, null, num3, FetchOrder2.OperationalRequirement.None);
            MaterialNeeds.Instance.UpdateNeed(ingredient.tag, ingredient.amount);
        }
        if (!building.Def.IsTilePiece)
        {
            base.gameObject.layer = LayerMask.NameToLayer("Construction");
        }
        building.RunOnArea(delegate(int offset_cell)
        {
            if ((UnityEngine.Object)base.gameObject.GetComponent <ConduitBridge>() == (UnityEngine.Object)null)
            {
                GameObject gameObject2 = Grid.Objects[offset_cell, 7];
                if ((UnityEngine.Object)gameObject2 != (UnityEngine.Object)null)
                {
                    gameObject2.DeleteObject();
                }
            }
        });
        if (IsReplacementTile)
        {
            GameObject gameObject = null;
            if (building.Def.ReplacementLayer != ObjectLayer.NumLayers)
            {
                int cell = Grid.PosToCell(base.transform.GetPosition());
                gameObject = Grid.Objects[cell, (int)building.Def.ReplacementLayer];
                if ((UnityEngine.Object)gameObject == (UnityEngine.Object)null || (UnityEngine.Object)gameObject == (UnityEngine.Object)base.gameObject)
                {
                    Grid.Objects[cell, (int)building.Def.ReplacementLayer] = base.gameObject;
                    if ((UnityEngine.Object)base.gameObject.GetComponent <SimCellOccupier>() != (UnityEngine.Object)null)
                    {
                        int renderLayer = LayerMask.NameToLayer("Overlay");
                        World.Instance.blockTileRenderer.AddBlock(renderLayer, building.Def, IsReplacementTile, SimHashes.Void, cell);
                    }
                    TileVisualizer.RefreshCell(cell, building.Def.TileLayer, building.Def.ReplacementLayer);
                }
                else
                {
                    Debug.LogError("multiple replacement tiles on the same cell!");
                    Util.KDestroyGameObject(base.gameObject);
                }
            }
        }
        bool flag = building.Def.BuildingComplete.GetComponent <Ladder>();

        waitForFetchesBeforeDigging = (flag || (bool)building.Def.BuildingComplete.GetComponent <SimCellOccupier>() || (bool)building.Def.BuildingComplete.GetComponent <Door>() || (bool)building.Def.BuildingComplete.GetComponent <LiquidPumpingStation>());
        if (flag)
        {
            int x     = 0;
            int y     = 0;
            int cell2 = Grid.PosToCell(this);
            Grid.CellToXY(cell2, out x, out y);
            int y2 = y - 3;
            ladderDetectionExtents = new Extents(x, y2, 1, 5);
            ladderParititonerEntry = GameScenePartitioner.Instance.Add("Constructable.OnNearbyBuildingLayerChanged", base.gameObject, ladderDetectionExtents, GameScenePartitioner.Instance.objectLayers[1], OnNearbyBuildingLayerChanged);
            OnNearbyBuildingLayerChanged(null);
        }
        this.fetchList.Submit(OnFetchListComplete, true);
        PlaceDiggables();
        ReachabilityMonitor.Instance instance = new ReachabilityMonitor.Instance(this);
        instance.StartSM();
        Subscribe(493375141, OnRefreshUserMenuDelegate);
        Prioritizable component2 = GetComponent <Prioritizable>();
        Prioritizable obj        = component2;

        obj.onPriorityChanged = (Action <PrioritySetting>)Delegate.Combine(obj.onPriorityChanged, new Action <PrioritySetting>(OnPriorityChanged));
        OnPriorityChanged(component2.GetMasterPriority());
    }