Esempio n. 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);
        }
    }
Esempio n. 2
0
	protected override void OnSpawn()
	{
		base.OnSpawn();
		int cell = Grid.PosToCell(this);
		if (!Grid.IsValidCell(cell))
		{
			base.gameObject.DeleteObject();
		}
		else
		{
			UpdateCachedCell(cell);
			ReachabilityMonitor.Instance instance = new ReachabilityMonitor.Instance(this);
			instance.StartSM();
			FetchableMonitor.Instance instance2 = new FetchableMonitor.Instance(this);
			instance2.StartSM();
			SetWorkTime(1.5f);
			faceTargetWhenWorking = true;
			KSelectable component = GetComponent<KSelectable>();
			if ((UnityEngine.Object)component != (UnityEngine.Object)null)
			{
				component.SetStatusIndicatorOffset(new Vector3(0f, -0.65f, 0f));
			}
			OnTagsChanged(null);
			TryToOffsetIfBuried();
			DecorProvider component2 = GetComponent<DecorProvider>();
			if ((UnityEngine.Object)component2 != (UnityEngine.Object)null && string.IsNullOrEmpty(component2.overrideName))
			{
				component2.overrideName = UI.OVERLAYS.DECOR.CLUTTER;
			}
			UpdateEntombedVisualizer();
			Subscribe(-1582839653, OnTagsChangedDelegate);
		}
	}
Esempio n. 3
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);
                                }
                            }
                        }
                    }
                }
            }
        }
    }