Пример #1
0
        public override void DoPostConfigureUnderConstruction(GameObject go)
        {
            KAnimGraphTileVisualizer kAnimGraphTileVisualizer = go.AddComponent <KAnimGraphTileVisualizer>();

            kAnimGraphTileVisualizer.connectionSource   = KAnimGraphTileVisualizer.ConnectionSource.Gas;
            kAnimGraphTileVisualizer.isPhysicalBuilding = false;
        }
Пример #2
0
 /// <summary>
 /// Applied before Refresh runs.
 /// </summary>
 internal static void Prefix(KAnimGraphTileVisualizer __instance)
 {
     if (__instance != null && __instance.TryGetComponent(
             out UpdateGraphIfEntombed updater))
     {
         updater.CheckVisible();
     }
 }
Пример #3
0
    public override void DoPostConfigureComplete(GameObject go)
    {
        go.GetComponent <Building>().Def.BuildingUnderConstruction.GetComponent <Constructable>().isDiggingRequired = false;
        KAnimGraphTileVisualizer kAnimGraphTileVisualizer = go.AddComponent <KAnimGraphTileVisualizer>();

        kAnimGraphTileVisualizer.connectionSource   = KAnimGraphTileVisualizer.ConnectionSource.Solid;
        kAnimGraphTileVisualizer.isPhysicalBuilding = true;
        LiquidConduitConfig.CommonConduitPostConfigureComplete(go);
    }
Пример #4
0
        public override void DoPostConfigureUnderConstruction(GameObject go)
        {
            base.DoPostConfigureUnderConstruction(go);
            go.GetComponent <Constructable>().isDiggingRequired = false;
            KAnimGraphTileVisualizer graphTileVisualizer = go.AddOrGet <KAnimGraphTileVisualizer>();

            graphTileVisualizer.connectionSource   = CONNECTION_SOURCE;
            graphTileVisualizer.isPhysicalBuilding = false;
        }
Пример #5
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            GeneratedBuildings.MakeBuildingAlwaysOperational(go);
            BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation), prefab_tag);
            KAnimGraphTileVisualizer graphTileVisualizer = go.AddOrGet <KAnimGraphTileVisualizer>();

            graphTileVisualizer.connectionSource   = CONNECTION_SOURCE;
            graphTileVisualizer.isPhysicalBuilding = true;
        }
Пример #6
0
    public override void DoPostConfigureUnderConstruction(GameObject go)
    {
        KAnimGraphTileVisualizer kAnimGraphTileVisualizer = go.AddComponent <KAnimGraphTileVisualizer>();

        kAnimGraphTileVisualizer.connectionSource   = KAnimGraphTileVisualizer.ConnectionSource.Solid;
        kAnimGraphTileVisualizer.isPhysicalBuilding = false;
        Constructable component = go.GetComponent <Constructable>();

        component.requiredSkillPerk = Db.Get().SkillPerks.ConveyorBuild.Id;
    }
Пример #7
0
 /// <summary>
 /// Applied after OnSpawn runs.
 /// </summary>
 internal static void Postfix(KAnimGraphTileVisualizer __instance)
 {
     if (__instance.TryGetComponent(out BuildingComplete building))
     {
         // Only apply to completed buildings, buildings under construction should be
         // visible even inside any wall
         __instance.gameObject.AddOrGet <UpdateGraphIfEntombed>().layer = building.Def.
                                                                          TileLayer;
     }
 }
Пример #8
0
    public override void DoPostConfigureComplete(GameObject go)
    {
        go.GetComponent <Building>().Def.BuildingUnderConstruction.GetComponent <Constructable>().isDiggingRequired = false;
        go.AddComponent <EmptyConduitWorkable>();
        KAnimGraphTileVisualizer kAnimGraphTileVisualizer = go.AddComponent <KAnimGraphTileVisualizer>();

        kAnimGraphTileVisualizer.connectionSource   = KAnimGraphTileVisualizer.ConnectionSource.Liquid;
        kAnimGraphTileVisualizer.isPhysicalBuilding = true;
        go.GetComponent <KPrefabID>().AddTag(GameTags.Pipes, false);
        CommonConduitPostConfigureComplete(go);
    }
    public override void DoPostConfigureUnderConstruction(GameObject go)
    {
        base.DoPostConfigureUnderConstruction(go);
        Constructable component = go.GetComponent <Constructable>();

        component.isDiggingRequired = false;
        KAnimGraphTileVisualizer kAnimGraphTileVisualizer = go.AddOrGet <KAnimGraphTileVisualizer>();

        kAnimGraphTileVisualizer.connectionSource   = KAnimGraphTileVisualizer.ConnectionSource.Logic;
        kAnimGraphTileVisualizer.isPhysicalBuilding = false;
    }
Пример #10
0
    private void FinishConstruction(UtilityConnections connections)
    {
        Rotatable   component   = GetComponent <Rotatable>();
        Orientation orientation = ((UnityEngine.Object)component != (UnityEngine.Object)null) ? component.GetOrientation() : Orientation.Neutral;
        int         num         = Grid.PosToCell(base.transform.GetLocalPosition());

        UnmarkArea();
        BuildingDef def              = building.Def;
        int         cell             = num;
        Orientation orientation2     = orientation;
        Storage     resource_storage = storage;

        Tag[]      selected_elements = selectedElementsTags;
        float      temperature       = initialTemperature;
        float      time       = GameClock.Instance.GetTime();
        GameObject gameObject = def.Build(cell, orientation2, resource_storage, selected_elements, temperature, true, time);

        gameObject.transform.rotation = base.transform.rotation;
        Rotatable component2 = gameObject.GetComponent <Rotatable>();

        if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
        {
            component2.SetOrientation(orientation);
        }
        KAnimGraphTileVisualizer component3 = GetComponent <KAnimGraphTileVisualizer>();

        if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
        {
            KAnimGraphTileVisualizer component4 = gameObject.GetComponent <KAnimGraphTileVisualizer>();
            component4.Connections = connections;
            component3.skipCleanup = true;
        }
        KSelectable component5 = GetComponent <KSelectable>();

        if ((UnityEngine.Object)component5 != (UnityEngine.Object)null && component5.IsSelected && (UnityEngine.Object)gameObject.GetComponent <KSelectable>() != (UnityEngine.Object)null)
        {
            component5.Unselect();
            if (PlayerController.Instance.ActiveTool.name == "SelectTool")
            {
                ((SelectTool)PlayerController.Instance.ActiveTool).SelectNextFrame(gameObject.GetComponent <KSelectable>(), false);
            }
        }
        storage.ConsumeAllIgnoringDisease();
        finished = true;
        this.DeleteObject();
    }
Пример #11
0
    public GameObject CreateBuildingPreview(BuildingDef def)
    {
        GameObject gameObject = CreateBuilding(def, previewTemplate, null);

        Object.DontDestroyOnLoad(gameObject);
        int num = LayerMask.NameToLayer("Place");

        gameObject.transform.SetPosition(new Vector3(0f, 0f, Grid.GetLayerZ(def.SceneLayer)));
        Add2DComponents(def, gameObject, "place", true, num);
        KAnimControllerBase component = gameObject.GetComponent <KAnimControllerBase>();

        if ((Object)component != (Object)null)
        {
            component.fgLayer = Grid.SceneLayer.NoLayer;
        }
        Rotatable rotatable = UpdateComponentRequirement <Rotatable>(gameObject, def.PermittedRotations != PermittedRotations.Unrotatable);

        if ((bool)rotatable)
        {
            rotatable.permittedRotations = def.PermittedRotations;
        }
        KPrefabID kPrefabID = AddID(gameObject, def.PrefabID + "Preview");

        kPrefabID.defaultLayer = num;
        KSelectable component2 = gameObject.GetComponent <KSelectable>();

        component2.SetName(def.Name);
        UpdateComponentRequirement <BuildingCellVisualizer>(gameObject, def.CheckRequiresBuildingCellVisualizer());
        KAnimGraphTileVisualizer component3 = gameObject.GetComponent <KAnimGraphTileVisualizer>();

        if ((Object)component3 != (Object)null)
        {
            Object.DestroyImmediate(component3);
        }
        if (def.RequiresPowerInput)
        {
            GeneratedBuildings.RegisterLogicPorts(gameObject, LogicOperationalController.INPUT_PORTS_0_0);
        }
        gameObject.PreInit();
        Assets.AddPrefab(gameObject.GetComponent <KPrefabID>());
        return(gameObject);
    }
    public KAnimGraphTileVisualizer GetNeighbour(Direction d)
    {
        KAnimGraphTileVisualizer result = null;

        Grid.PosToXY(base.transform.GetPosition(), out Vector2I xy);
        int num = -1;

        switch (d)
        {
        case Direction.Up:
            if (xy.y < Grid.HeightInCells - 1)
            {
                num = Grid.XYToCell(xy.x, xy.y + 1);
            }
            break;

        case Direction.Down:
            if (xy.y > 0)
            {
                num = Grid.XYToCell(xy.x, xy.y - 1);
            }
            break;

        case Direction.Left:
            if (xy.x > 0)
            {
                num = Grid.XYToCell(xy.x - 1, xy.y);
            }
            break;

        case Direction.Right:
            if (xy.x < Grid.WidthInCells - 1)
            {
                num = Grid.XYToCell(xy.x + 1, xy.y);
            }
            break;
        }
        if (num != -1)
        {
            ObjectLayer layer;
            switch (connectionSource)
            {
            case ConnectionSource.Gas:
                layer = ObjectLayer.GasConduitTile;
                break;

            case ConnectionSource.Liquid:
                layer = ObjectLayer.LiquidConduitTile;
                break;

            case ConnectionSource.Electrical:
                layer = ObjectLayer.WireTile;
                break;

            case ConnectionSource.Logic:
                layer = ObjectLayer.LogicWiresTiling;
                break;

            case ConnectionSource.Tube:
                layer = ObjectLayer.TravelTubeTile;
                break;

            case ConnectionSource.Solid:
                layer = ObjectLayer.SolidConduitTile;
                break;

            default:
                throw new ArgumentNullException("wtf");
            }
            GameObject gameObject = Grid.Objects[num, (int)layer];
            if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null)
            {
                result = gameObject.GetComponent <KAnimGraphTileVisualizer>();
            }
        }
        return(result);
    }
Пример #13
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);
        }
    }