void OnSelectionChange(System.Collections.Generic.List <HexCellPlaceable> selectedPlacables)
    {
        PartGenerator selectedGenerator = null;

        foreach (HexCellPlaceable placable in selectedPlacables)
        {
            if (placable is PartGenerator)
            {
                if (selectedGenerator != null)
                {
                    selectedGenerator = null;
                    break;
                }
                selectedGenerator = placable as PartGenerator;
            }
        }

        SetPreviewedConstruction(
            selectedGenerator == null ? null : selectedGenerator.toGenerateConstruction,
            (construction) =>
        {
            Debug.LogWarning("encoding " + construction.name, this);
            ObjectPoolManager.DestroyObject(selectedGenerator.toGenerateConstruction);
            selectedGenerator.toGenerateConstruction = Construction.DecodeCopy(construction);
            selectedGenerator.toGenerateConstruction.ignoreCollisions = true;
        });

        _previewWindow.gameObject.SetActive(selectedGenerator != null);

        if (PreviewedConstruction == null)
        {
            ConstructionMaker.instance.CloseMaker();
        }
    }
 void SetPreviewedConstructionInternal(Construction construction)
 {
     if (construction == null)
     {
         PreviewedConstruction = null;
     }
     else
     {
         PreviewedConstruction = Construction.DecodeCopy(construction);
     }
 }
Ejemplo n.º 3
0
    public void SetTarget(Construction targetConstruction)
    {
        if (target != null)
        {
            Debug.Log("Destroying pooled " + target.name);
            target.DestroySelf();
            target = null;
        }
        Debug.Log("Setting Target " + Encoding.Encode(targetConstruction));
        target = Construction.DecodeCopy(targetConstruction);
        Debug.Log("Set Target " + Encoding.Encode(target));
        target.ignoreCollisions = true;
//		GrabbablePart targetPart = target.GenerateConnectedParts();
        target.transform.parent        = _targetHolder.transform;
        target.transform.localPosition = Vector3.zero;

        OnGridChangedEvent();
    }
    public void OpenMaker(Construction construction)
    {
//		string constructionCode = CharSerializer.Encode(construction);
//		this.transform.localScale = Vector3.one;
        this.gameObject.SetActive(true);

//		_dragButtons.ForEach((obj) => obj.SetCamera(_makerCamera));

        BackgroundInputCatcher.Catcher.RequestInputOverride(HandleBackgroundScreenPoint);

        targetConstructions = new List <Construction>();
        //Construction.Decode(constructionCode)

        targetConstructions.Add(Construction.DecodeCopy(construction));
        targetConstructions[0].transform.parent        = _constructionHolder.transform;
        targetConstructions[0].transform.localPosition = Vector3.zero;
//		construction.gameObject.SetLayerRecursively(gameObject.layer);

        _defaultControlModeButton.SetState(0);
        ChangeControlMode(ControlMode.DragAndRotate);
        MarkConstructionChange();
    }