Exemplo n.º 1
0
        public BuildingVisual(BuildingConfig buildingConfig, int cell)
        {
            Offset = buildingConfig.Offset;
            this.buildingConfig = buildingConfig;
            this.cell           = cell;

            Vector3 positionCBC = Grid.CellToPosCBC(cell, Grid.SceneLayer.Building);

            Visualizer = GameUtil.KInstantiate(buildingConfig.BuildingDef.BuildingPreview, positionCBC, Grid.SceneLayer.Ore, "BlueprintModBuildingVisualizer", LayerMask.NameToLayer("Place"));
            Visualizer.transform.SetPosition(positionCBC);
            Visualizer.SetActive(true);

            if (Visualizer.GetComponent <Rotatable>() != null)
            {
                Visualizer.GetComponent <Rotatable>().SetOrientation(buildingConfig.Orientation);
            }

            KBatchedAnimController batchedAnimController = Visualizer.GetComponent <KBatchedAnimController>();

            if (batchedAnimController != null)
            {
                batchedAnimController.visibilityType = KAnimControllerBase.VisibilityType.OffscreenUpdate;
                batchedAnimController.isMovable      = true;
                batchedAnimController.Offset         = buildingConfig.BuildingDef.GetVisualizerOffset() + buildingConfig.BuildingDef.placementPivot;
                batchedAnimController.TintColour     = GetVisualizerColor(cell);

                batchedAnimController.SetLayer(LayerMask.NameToLayer("Place"));
            }

            else
            {
                Visualizer.SetLayerRecursively(LayerMask.NameToLayer("Place"));
            }
        }
    protected override void OnActivateTool()
    {
        active = true;
        base.OnActivateTool();
        GameObject prefab = Assets.GetPrefab(previewTag);

        Grid.SceneLayer sceneLayer = Grid.SceneLayer.Front;
        int             gameLayer  = LayerMask.NameToLayer("Place");

        visualizer = GameUtil.KInstantiate(prefab, sceneLayer, null, gameLayer);
        KBatchedAnimController component = visualizer.GetComponent <KBatchedAnimController>();

        if ((Object)component != (Object)null)
        {
            component.visibilityType = KAnimControllerBase.VisibilityType.Always;
            component.isMovable      = true;
        }
        visualizer.SetActive(true);
        ShowToolTip();
        BuildToolHoverTextCard component2 = GetComponent <BuildToolHoverTextCard>();

        component2.currentDef = null;
        ResourceRemainingDisplayScreen.instance.ActivateDisplay(visualizer);
        if ((Object)component == (Object)null)
        {
            visualizer.SetLayerRecursively(LayerMask.NameToLayer("Place"));
        }
        else
        {
            component.SetLayer(LayerMask.NameToLayer("Place"));
        }
        GridCompositor.Instance.ToggleMajor(true);
    }
Exemplo n.º 3
0
 public void ForceToFront()
 {
     effect.SetLayer((int)Grid.SceneLayer.BuildingFront);
     effect.SetSceneLayer(Grid.SceneLayer.BuildingFront);/*
                                                          * var pos = effect.transform.localPosition;
                                                          * pos.z = -0.5f;
                                                          * effect.transform.SetLocalPosition(pos);*/
 }
 public void Update()
 {
     if (active)
     {
         KBatchedAnimController component = visualizer.GetComponent <KBatchedAnimController>();
         if ((Object)component != (Object)null)
         {
             component.SetLayer(LayerMask.NameToLayer("Place"));
         }
     }
 }
Exemplo n.º 5
0
        public UtilityVisual(BuildingConfig buildingConfig, int cell)
        {
            Offset = buildingConfig.Offset;
            this.buildingConfig = buildingConfig;
            this.cell           = cell;

            Vector3 positionCBC = Grid.CellToPosCBC(cell, buildingConfig.BuildingDef.SceneLayer);

            Visualizer = GameUtil.KInstantiate(buildingConfig.BuildingDef.BuildingPreview, positionCBC, Grid.SceneLayer.Ore, "BlueprintModUtilityVisualizer", LayerMask.NameToLayer("Place"));
            Visualizer.transform.SetPosition(positionCBC);
            Visualizer.SetActive(true);

            if (Visualizer.GetComponent <Rotatable>() != null)
            {
                Visualizer.GetComponent <Rotatable>().SetOrientation(buildingConfig.Orientation);
            }

            KBatchedAnimController batchedAnimController = Visualizer.GetComponent <KBatchedAnimController>();

            if (batchedAnimController != null)
            {
                IUtilityNetworkMgr utilityNetworkManager = buildingConfig.BuildingDef.BuildingComplete.GetComponent <IHaveUtilityNetworkMgr>().GetNetworkManager();

                if (utilityNetworkManager != null)
                {
                    string animation = utilityNetworkManager.GetVisualizerString((UtilityConnections)buildingConfig.Flags) + "_place";

                    if (batchedAnimController.HasAnimation(animation))
                    {
                        batchedAnimController.Play(animation);
                    }
                }

                batchedAnimController.visibilityType = KAnimControllerBase.VisibilityType.Always;
                batchedAnimController.isMovable      = true;
                batchedAnimController.Offset         = buildingConfig.BuildingDef.GetVisualizerOffset() + buildingConfig.BuildingDef.placementPivot;
                batchedAnimController.TintColour     = GetVisualizerColor(cell);

                batchedAnimController.SetLayer(LayerMask.NameToLayer("Place"));
            }

            else
            {
                Visualizer.SetLayerRecursively(LayerMask.NameToLayer("Place"));
            }

            VisualsUtilities.SetVisualizerColor(cell, GetVisualizerColor(cell), Visualizer, buildingConfig);
        }
    protected override void OnActivateTool()
    {
        lastDragCell = -1;
        if ((Object)visualizer != (Object)null)
        {
            ClearTilePreview();
            Object.Destroy(visualizer);
        }
        active = true;
        base.OnActivateTool();
        buildingOrientation = Orientation.Neutral;
        placementPivot      = def.placementPivot;
        Vector3    cursorPos       = PlayerController.GetCursorPos(KInputManager.GetMousePos());
        GameObject buildingPreview = def.BuildingPreview;
        Vector3    position        = cursorPos;

        Grid.SceneLayer sceneLayer = Grid.SceneLayer.Ore;
        int             gameLayer  = LayerMask.NameToLayer("Place");

        visualizer = GameUtil.KInstantiate(buildingPreview, position, sceneLayer, null, gameLayer);
        KBatchedAnimController component = visualizer.GetComponent <KBatchedAnimController>();

        if ((Object)component != (Object)null)
        {
            component.visibilityType = KAnimControllerBase.VisibilityType.Always;
            component.isMovable      = true;
            component.Offset         = def.GetVisualizerOffset();
            component.Offset        += def.placementPivot;
            component.name           = component.GetComponent <KPrefabID>().GetDebugName() + "_visualizer";
        }
        visualizer.SetActive(true);
        UpdateVis(cursorPos);
        BuildToolHoverTextCard component2 = GetComponent <BuildToolHoverTextCard>();

        component2.currentDef = def;
        ResourceRemainingDisplayScreen.instance.ActivateDisplay(visualizer);
        if ((Object)component == (Object)null)
        {
            visualizer.SetLayerRecursively(LayerMask.NameToLayer("Place"));
        }
        else
        {
            component.SetLayer(LayerMask.NameToLayer("Place"));
        }
        GridCompositor.Instance.ToggleMajor(true);
    }
Exemplo n.º 7
0
 private void OnLayerChanged(int layer)
 {
     myAnim.SetLayer(layer);
 }