Example #1
0
 public static void Postfix(Deconstructable __instance)
 {
     ResetCell(__instance.GetCell());
 }
 static void Postfix(Deconstructable __instance) => Update(__instance.gameObject);
Example #3
0
 private static float[] InjectMass(float[] mass, Deconstructable deconstructable)
 {
     return(deconstructable.GetComponent <BuildedGeneShuffler>()?.constructionMass ?? mass);
 }
Example #4
0
 private static void Postfix(Deconstructable __instance, ref bool ___shouldShowSkillPerkStatusItem, bool ___isMarkedForDeconstruction)
 {
     ___shouldShowSkillPerkStatusItem = ___isMarkedForDeconstruction;
     UpdateStatusItem.Invoke(__instance, null);
 }
Example #5
0
 /// <summary>
 /// Applied before OnCompleteWork runs.
 /// </summary>
 internal static void Prefix(Deconstructable __instance, Worker worker)
 {
     MarkDirection(__instance, worker);
 }
        public static bool StopExecutionIfInstanceIsNull(Deconstructable __instance)
        {
            var shouldContinue = __instance != null;

            return(shouldContinue);
        }
Example #7
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        KBatchedAnimController component = GetComponent <KBatchedAnimController>();
        Rotatable component2             = GetComponent <Rotatable>();

        if ((Object)component != (Object)null && (Object)component2 == (Object)null)
        {
            component.Offset = Def.GetVisualizerOffset() + Def.placementPivot;
        }
        KBoxCollider2D component3 = GetComponent <KBoxCollider2D>();

        if ((Object)component3 != (Object)null)
        {
            Vector3 visualizerOffset = Def.GetVisualizerOffset();
            component3.offset += new Vector2(visualizerOffset.x, visualizerOffset.y);
        }
        int cell = Grid.PosToCell(base.transform.GetPosition());

        if (Def.IsFoundation)
        {
            int[] placementCells = base.PlacementCells;
            foreach (int num in placementCells)
            {
                Grid.Foundation[num] = true;
                Game.Instance.roomProber.SolidChangedEvent(num, false);
            }
        }
        Vector3 position = Grid.CellToPosCBC(cell, Def.SceneLayer);

        base.transform.SetPosition(position);
        PrimaryElement component4 = GetComponent <PrimaryElement>();

        if ((Object)component4 != (Object)null && component4.Mass == 0f)
        {
            component4.Mass = Def.Mass[0];
        }
        Def.MarkArea(cell, base.Orientation, Def.ObjectLayer, base.gameObject);
        if (Def.IsTilePiece)
        {
            Def.MarkArea(cell, base.Orientation, Def.TileLayer, base.gameObject);
            Def.RunOnArea(cell, base.Orientation, delegate(int c)
            {
                TileVisualizer.RefreshCell(c, Def.TileLayer, Def.ReplacementLayer);
            });
        }
        RegisterBlockTileRenderer();
        if (Def.PreventIdleTraversalPastBuilding)
        {
            for (int j = 0; j < base.PlacementCells.Length; j++)
            {
                Grid.PreventIdleTraversal[base.PlacementCells[j]] = true;
            }
        }
        KSelectable component5 = GetComponent <KSelectable>();

        if ((Object)component5 != (Object)null)
        {
            component5.SetStatusIndicatorOffset(Def.placementPivot);
        }
        Components.BuildingCompletes.Add(this);
        BuildingConfigManager.Instance.AddBuildingCompleteKComponents(base.gameObject, Def.Tag);
        hasSpawnedKComponents = true;
        scenePartitionerEntry = GameScenePartitioner.Instance.Add(base.name, this, GetExtents(), GameScenePartitioner.Instance.completeBuildings, null);
        Attributes attributes = this.GetAttributes();

        if (attributes != null)
        {
            Deconstructable component6 = GetComponent <Deconstructable>();
            if ((Object)component6 != (Object)null)
            {
                for (int k = 1; k < component6.constructionElements.Length; k++)
                {
                    Tag     tag     = component6.constructionElements[k];
                    Element element = ElementLoader.GetElement(tag);
                    if (element != null)
                    {
                        foreach (AttributeModifier attributeModifier in element.attributeModifiers)
                        {
                            attributes.Add(attributeModifier);
                        }
                    }
                    else
                    {
                        GameObject gameObject = Assets.TryGetPrefab(tag);
                        if ((Object)gameObject != (Object)null)
                        {
                            PrefabAttributeModifiers component7 = gameObject.GetComponent <PrefabAttributeModifiers>();
                            if ((Object)component7 != (Object)null)
                            {
                                foreach (AttributeModifier descriptor in component7.descriptors)
                                {
                                    attributes.Add(descriptor);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Example #8
0
    protected override void OnCompleteWork(Worker worker)
    {
        float num  = 0f;
        float num2 = 0f;
        bool  flag = true;

        foreach (GameObject item in storage.items)
        {
            if (!((UnityEngine.Object)item == (UnityEngine.Object)null))
            {
                PrimaryElement component = item.GetComponent <PrimaryElement>();
                if (!((UnityEngine.Object)component == (UnityEngine.Object)null))
                {
                    num  += component.Mass;
                    num2 += component.Temperature * component.Mass;
                    flag  = (flag && component.HasTag(GameTags.Liquifiable));
                }
            }
        }
        if (num <= 0f)
        {
            DebugUtil.LogWarningArgs(base.gameObject, "uhhh this constructable is about to generate a nan", "Item Count: ", storage.items.Count);
        }
        else
        {
            if (flag)
            {
                initialTemperature = Mathf.Min(num2 / num, 318.15f);
            }
            else
            {
                initialTemperature = Mathf.Clamp(num2 / num, 288.15f, 318.15f);
            }
            KAnimGraphTileVisualizer component2  = GetComponent <KAnimGraphTileVisualizer>();
            UtilityConnections       connections = (!((UnityEngine.Object)component2 == (UnityEngine.Object)null)) ? component2.Connections : ((UtilityConnections)0);
            if (IsReplacementTile)
            {
                int        cell = Grid.PosToCell(base.transform.GetLocalPosition());
                GameObject replacementCandidate = building.Def.GetReplacementCandidate(cell);
                if ((UnityEngine.Object)replacementCandidate != (UnityEngine.Object)null)
                {
                    SimCellOccupier component3 = replacementCandidate.GetComponent <SimCellOccupier>();
                    if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
                    {
                        component3.DestroySelf(delegate
                        {
                            if ((UnityEngine.Object) this != (UnityEngine.Object)null && (UnityEngine.Object)base.gameObject != (UnityEngine.Object)null)
                            {
                                FinishConstruction(connections);
                            }
                        });
                    }
                    else
                    {
                        Conduit component4 = replacementCandidate.GetComponent <Conduit>();
                        if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
                        {
                            ConduitFlow flowManager = component4.GetFlowManager();
                            flowManager.MarkForReplacement(cell);
                        }
                        BuildingComplete component5 = replacementCandidate.GetComponent <BuildingComplete>();
                        if ((UnityEngine.Object)component5 != (UnityEngine.Object)null)
                        {
                            component5.Subscribe(-21016276, delegate
                            {
                                FinishConstruction(connections);
                            });
                        }
                        else
                        {
                            Debug.LogWarning("Why am I trying to replace a: " + replacementCandidate.name);
                            FinishConstruction(connections);
                        }
                    }
                    KAnimGraphTileVisualizer component6 = replacementCandidate.GetComponent <KAnimGraphTileVisualizer>();
                    if ((UnityEngine.Object)component6 != (UnityEngine.Object)null)
                    {
                        component6.skipCleanup = true;
                    }
                    PrimaryElement component7   = replacementCandidate.GetComponent <PrimaryElement>();
                    float          mass         = component7.Mass;
                    float          temperature  = component7.Temperature;
                    byte           diseaseIdx   = component7.DiseaseIdx;
                    int            diseaseCount = component7.DiseaseCount;
                    Debug.Assert(component7.Element != null && component7.Element.tag != (Tag)null);
                    Deconstructable.SpawnItem(component7.transform.GetPosition(), component7.GetComponent <Building>().Def, component7.Element.tag, mass, temperature, diseaseIdx, diseaseCount);
                    replacementCandidate.Trigger(1606648047, building.Def.TileLayer);
                    replacementCandidate.DeleteObject();
                }
            }
            else
            {
                FinishConstruction(connections);
            }
            PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Building, GetComponent <KSelectable>().GetName(), base.transform, 1.5f, false);
        }
    }