示例#1
0
    protected override void OnSpawn()
    {
        if ((UnityEngine.Object)Def == (UnityEngine.Object)null)
        {
            Debug.LogError("Missing building definition on object " + base.name);
        }
        KSelectable component = GetComponent <KSelectable>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            component.SetName(Def.Name);
            component.SetStatusIndicatorOffset(new Vector3(0f, -0.35f, 0f));
        }
        Prioritizable component2 = GetComponent <Prioritizable>();

        if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
        {
            component2.iconOffset.y = 0.3f;
        }
        KPrefabID component3 = GetComponent <KPrefabID>();

        if (component3.HasTag(RoomConstraints.ConstraintTags.IndustrialMachinery))
        {
            scenePartitionerEntry = GameScenePartitioner.Instance.Add(base.name, base.gameObject, GetExtents(), GameScenePartitioner.Instance.industrialBuildings, null);
        }
        if (Def.Deprecated && (UnityEngine.Object)GetComponent <KSelectable>() != (UnityEngine.Object)null)
        {
            KSelectable component4 = GetComponent <KSelectable>();
            deprecatedBuildingStatusItem = new StatusItem("BUILDING_DEPRECATED", "BUILDING", string.Empty, StatusItem.IconType.Info, NotificationType.BadMinor, false, OverlayModes.None.ID, true, 129022);
            component4.AddStatusItem(deprecatedBuildingStatusItem, null);
        }
    }
示例#2
0
    public virtual void SetStage(string stage_id, bool skip_effect)
    {
        Stage stage = null;

        for (int i = 0; i < stages.Count; i++)
        {
            if (stages[i].id == stage_id)
            {
                stage = stages[i];
                break;
            }
        }
        if (stage == null)
        {
            Debug.LogError("Missing stage: " + stage_id);
        }
        else
        {
            currentStage = stage.id;
            GetComponent <KAnimControllerBase>().Play(stage.anim, KAnim.PlayMode.Once, 1f, 0f);
            if (stage.decor != 0)
            {
                AttributeModifier modifier = new AttributeModifier(Db.Get().BuildingAttributes.Decor.Id, (float)stage.decor, "Art Quality", false, false, true);
                this.GetAttributes().Add(modifier);
            }
            KSelectable component = GetComponent <KSelectable>();
            component.SetName(stage.name);
            component.SetStatusItem(Db.Get().StatusItemCategories.Main, statuses[stage.statusItem], this);
            shouldShowSkillPerkStatusItem = false;
            UpdateStatusItem(null);
        }
    }
示例#3
0
        private void setGameObjectName(string newName)
        {
            KSelectable selectable = GetComponent <KSelectable>();

            name = newName;
            selectable?.SetName(newName);
            gameObject.name = newName;
        }
示例#4
0
 public void SetName(string name)
 {
     this.name = name;
     if ((UnityEngine.Object)selectable != (UnityEngine.Object)null)
     {
         selectable.SetName(name);
     }
     base.gameObject.name = name;
     NameDisplayScreen.Instance.UpdateName(base.gameObject);
 }
示例#5
0
        public void SetName(string name)
        {
            KSelectable component = GetComponent <KSelectable>();

            base.name = name;
            if (component != null)
            {
                component.SetName(name);
            }
            base.gameObject.name = name;
            NameDisplayScreen.Instance.UpdateName(base.gameObject);
        }
示例#6
0
    private static void ConfigEntity(GameObject template, string id, string name, bool is_selectable = true)
    {
        template.name = id;
        KPrefabID kPrefabID = template.AddOrGet <KPrefabID>();

        kPrefabID.PrefabTag = TagManager.Create(id, name);
        if (is_selectable)
        {
            KSelectable kSelectable = template.AddOrGet <KSelectable>();
            kSelectable.SetName(name);
        }
    }
示例#7
0
        public void SetName(string name)
        {
            KSelectable component = this.GetComponent <KSelectable>();

            this.name       = name;
            this.lockerName = name;
            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
            {
                component.SetName(name);
            }
            this.gameObject.name = name;
            NameDisplayScreen.Instance.UpdateName(this.gameObject);
        }
示例#8
0
    public static GameObject CreateOreEntity(SimHashes elementID, CollisionShape shape, float width, float height, List <Tag> additionalTags = null, float default_temperature = 293f)
    {
        Element    element    = ElementLoader.FindElementByHash(elementID);
        GameObject gameObject = Object.Instantiate(baseOreTemplate);

        gameObject.name = element.name;
        Object.DontDestroyOnLoad(gameObject);
        KPrefabID kPrefabID = gameObject.AddOrGet <KPrefabID>();

        kPrefabID.PrefabTag = element.tag;
        if (additionalTags != null)
        {
            foreach (Tag additionalTag in additionalTags)
            {
                kPrefabID.AddTag(additionalTag, false);
            }
        }
        if (element.lowTemp < 296.15f && element.highTemp > 296.15f)
        {
            kPrefabID.AddTag(GameTags.PedestalDisplayable, false);
        }
        PrimaryElement primaryElement = gameObject.AddOrGet <PrimaryElement>();

        primaryElement.SetElement(elementID);
        primaryElement.Mass        = 1f;
        primaryElement.Temperature = default_temperature;
        Pickupable pickupable = gameObject.AddOrGet <Pickupable>();

        pickupable.SetWorkTime(5f);
        pickupable.sortOrder = element.buildMenuSort;
        KSelectable kSelectable = gameObject.AddOrGet <KSelectable>();

        kSelectable.SetName(element.name);
        KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>();

        kBatchedAnimController.AnimFiles = new KAnimFile[1]
        {
            element.substance.anim
        };
        kBatchedAnimController.sceneLayer  = Grid.SceneLayer.Front;
        kBatchedAnimController.initialAnim = "idle1";
        kBatchedAnimController.isMovable   = true;
        return(AddCollision(gameObject, shape, width, height));
    }
示例#9
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);
    }
示例#10
0
    public GameObject CreateBuildingUnderConstruction(BuildingDef def)
    {
        GameObject gameObject = CreateBuilding(def, constructionTemplate, null);

        Object.DontDestroyOnLoad(gameObject);
        KSelectable component = gameObject.GetComponent <KSelectable>();

        component.SetName(def.Name);
        for (int i = 0; i < def.Mass.Length; i++)
        {
            gameObject.GetComponent <PrimaryElement>().MassPerUnit += def.Mass[i];
        }
        KPrefabID kPrefabID = AddID(gameObject, def.PrefabID + "UnderConstruction");

        UpdateComponentRequirement <BuildingCellVisualizer>(gameObject, def.CheckRequiresBuildingCellVisualizer());
        Constructable component2 = gameObject.GetComponent <Constructable>();

        component2.SetWorkTime(def.ConstructionTime);
        Rotatable rotatable = UpdateComponentRequirement <Rotatable>(gameObject, def.PermittedRotations != PermittedRotations.Unrotatable);

        if ((bool)rotatable)
        {
            rotatable.permittedRotations = def.PermittedRotations;
        }
        Add2DComponents(def, gameObject, "place", false, kPrefabID.defaultLayer = LayerMask.NameToLayer("Construction"));
        UpdateComponentRequirement <Vent>(gameObject, false);
        bool required = (Object)def.BuildingComplete.GetComponent <AnimTileable>() != (Object)null;

        UpdateComponentRequirement <AnimTileable>(gameObject, required);
        if (def.RequiresPowerInput)
        {
            GeneratedBuildings.RegisterLogicPorts(gameObject, LogicOperationalController.INPUT_PORTS_0_0);
        }
        Assets.AddPrefab(kPrefabID);
        gameObject.PreInit();
        return(gameObject);
    }
示例#11
0
    public GameObject CreateBuildingComplete(GameObject go, BuildingDef def)
    {
        go.name = def.PrefabID + "Complete";
        go.transform.SetPosition(new Vector3(0f, 0f, Grid.GetLayerZ(def.SceneLayer)));
        KSelectable component = go.GetComponent <KSelectable>();

        component.SetName(def.Name);
        PrimaryElement component2 = go.GetComponent <PrimaryElement>();

        component2.MassPerUnit = 0f;
        for (int i = 0; i < def.Mass.Length; i++)
        {
            component2.MassPerUnit += def.Mass[i];
        }
        component2.Temperature = 273.15f;
        BuildingHP buildingHP = go.AddOrGet <BuildingHP>();

        if (def.Invincible)
        {
            buildingHP.invincible = true;
        }
        buildingHP.SetHitPoints(def.HitPoints);
        if (def.Repairable)
        {
            UpdateComponentRequirement <Repairable>(go, true);
        }
        int      defaultLayer = go.layer = LayerMask.NameToLayer("Default");
        Building component3   = go.GetComponent <BuildingComplete>();

        component3.Def = def;
        if (def.InputConduitType != 0 || def.OutputConduitType != 0)
        {
            go.AddComponent <BuildingConduitEndpoints>();
        }
        if (!Add2DComponents(def, go, null, false, -1))
        {
            Debug.Log(def.Name + " is not yet a 2d building!");
        }
        UpdateComponentRequirement <EnergyConsumer>(go, def.RequiresPowerInput);
        Rotatable rotatable = UpdateComponentRequirement <Rotatable>(go, def.PermittedRotations != PermittedRotations.Unrotatable);

        if ((bool)rotatable)
        {
            rotatable.permittedRotations = def.PermittedRotations;
        }
        if (def.Breakable)
        {
            go.AddComponent <Breakable>();
        }
        ConduitConsumer conduitConsumer = UpdateComponentRequirement <ConduitConsumer>(go, def.InputConduitType == ConduitType.Gas || def.InputConduitType == ConduitType.Liquid);

        if ((Object)conduitConsumer != (Object)null)
        {
            conduitConsumer.SetConduitData(def.InputConduitType);
        }
        bool          required      = def.RequiresPowerInput || def.InputConduitType == ConduitType.Gas || def.InputConduitType == ConduitType.Liquid;
        RequireInputs requireInputs = UpdateComponentRequirement <RequireInputs>(go, required);

        if ((Object)requireInputs != (Object)null)
        {
            requireInputs.SetRequirements(def.RequiresPowerInput, def.InputConduitType == ConduitType.Gas || def.InputConduitType == ConduitType.Liquid);
        }
        UpdateComponentRequirement <RequireOutputs>(go, def.OutputConduitType != ConduitType.None);
        UpdateComponentRequirement <Operational>(go, !def.isUtility);
        if (def.Floodable)
        {
            go.AddComponent <Floodable>();
        }
        if (def.Disinfectable)
        {
            go.AddOrGet <AutoDisinfectable>();
            go.AddOrGet <Disinfectable>();
        }
        if (def.Overheatable)
        {
            Overheatable overheatable = go.AddComponent <Overheatable>();
            overheatable.baseOverheatTemp = def.OverheatTemperature;
            overheatable.baseFatalTemp    = def.FatalHot;
        }
        if (def.Entombable)
        {
            go.AddComponent <Structure>();
        }
        if (def.RequiresPowerInput)
        {
            GeneratedBuildings.RegisterLogicPorts(go, LogicOperationalController.INPUT_PORTS_0_0);
            go.AddOrGet <LogicOperationalController>();
        }
        UpdateComponentRequirement <BuildingCellVisualizer>(go, def.CheckRequiresBuildingCellVisualizer());
        if (def.BaseDecor != 0f)
        {
            DecorProvider decorProvider = UpdateComponentRequirement <DecorProvider>(go, true);
            decorProvider.baseDecor  = def.BaseDecor;
            decorProvider.baseRadius = def.BaseDecorRadius;
        }
        if (def.AttachmentSlotTag != Tag.Invalid)
        {
            AttachableBuilding attachableBuilding = UpdateComponentRequirement <AttachableBuilding>(go, true);
            attachableBuilding.attachableToTag = def.AttachmentSlotTag;
        }
        KPrefabID kPrefabID = AddID(go, def.PrefabID);

        kPrefabID.defaultLayer = defaultLayer;
        Assets.AddPrefab(kPrefabID);
        go.PreInit();
        return(go);
    }
示例#12
0
 private void Update()
 {
     if (isAppFocused && !((UnityEngine.Object)SelectTool.Instance == (UnityEngine.Object)null) && !((UnityEngine.Object)Game.Instance == (UnityEngine.Object)null) && Game.Instance.GameStarted())
     {
         SelectedDisplaySprite.SetActive(PlayerController.Instance.IsUsingDefaultTool() && !DebugHandler.HideUI);
         if ((UnityEngine.Object)SelectTool.Instance.selected != (UnityEngine.Object)mSelectable)
         {
             mouseCell = Grid.PosToCell(CameraController.Instance.baseCamera.ScreenToWorldPoint(KInputManager.GetMousePos()));
             if (Grid.IsValidCell(mouseCell) && Grid.IsVisible(mouseCell))
             {
                 bool flag = true;
                 foreach (KeyValuePair <HashedString, Func <bool> > item in overlayFilterMap)
                 {
                     if (item.Value == null)
                     {
                         Debug.LogWarning("Filter value is null");
                     }
                     else if ((UnityEngine.Object)OverlayScreen.Instance == (UnityEngine.Object)null)
                     {
                         Debug.LogWarning("Overlay screen Instance is null");
                     }
                     else if (OverlayScreen.Instance.GetMode() == item.Key)
                     {
                         flag = false;
                         if (base.gameObject.layer != LayerMask.NameToLayer("MaskedOverlay"))
                         {
                             base.gameObject.layer = LayerMask.NameToLayer("MaskedOverlay");
                         }
                         if (item.Value())
                         {
                             break;
                         }
                         SelectedDisplaySprite.SetActive(false);
                         return;
                     }
                 }
                 if (flag && base.gameObject.layer != LayerMask.NameToLayer("Default"))
                 {
                     base.gameObject.layer = LayerMask.NameToLayer("Default");
                 }
                 Vector3 position = Grid.CellToPos(mouseCell, 0f, 0f, 0f) + offset;
                 position.z = zDepth;
                 base.transform.SetPosition(position);
                 mSelectable.SetName(Grid.Element[mouseCell].name);
             }
             if ((UnityEngine.Object)SelectTool.Instance.hover != (UnityEngine.Object)mSelectable)
             {
                 SelectedDisplaySprite.SetActive(false);
             }
         }
         updateTimer += Time.deltaTime;
         if (updateTimer >= 0.5f)
         {
             updateTimer = 0f;
             if ((UnityEngine.Object)SelectTool.Instance.selected == (UnityEngine.Object)mSelectable)
             {
                 UpdateValues();
             }
         }
     }
 }