/// <summary> /// Don call this every tick, update /// </summary> /// <returns></returns> sealed public override bool IsAttatchable() { FlowBlockConnector.ConnectorType expectedConnectorTypeFlag = FlowBlockConnector.ConnectorType.None; if (IsPreviousBlockEditorUnitAssignable == true && PreviousFlowBlockEditorUnit == null) { expectedConnectorTypeFlag = expectedConnectorTypeFlag | FlowBlockConnector.ConnectorType.DownBump; } if (IsNextBlockEditorUnitAssignable == true && NextFlowBlockEditorUnit == null) { expectedConnectorTypeFlag = expectedConnectorTypeFlag | FlowBlockConnector.ConnectorType.UpNotch; } FlowBlockConnector flowBlockConnector = this.GetTopFlowBlockConnector(transform.position, expectedConnectorTypeFlag); if (flowBlockConnector == null && this.NextFlowBlockEditorUnit != null) {//if Fail to find flowblockconnector //Find Top Block Connector at LowestDescendantBlock Postion FlowBlockEditorUnit lowestDescendantBlockUnit = this.LowestDescendantBlockUnit; flowBlockConnector = this.GetTopFlowBlockConnector(lowestDescendantBlockUnit.transform.position, FlowBlockConnector.ConnectorType.UpNotch); } if (flowBlockConnector == null || flowBlockConnector.OwnerFlowBlockEditorUnit == this || flowBlockConnector.OwnerBlockEditorUnit._BlockEditorUnitFlag.HasFlag(BlockEditorUnitFlag.IsAttachable) == false) { base.AttachableEditorElement = null; return(false); } else { if (flowBlockConnector._ConnectorType == FlowBlockConnector.ConnectorType.UpNotch) {//if hit connector is up notch type if (this.IsNextBlockEditorUnitAssignable) { base.AttachableEditorElement = flowBlockConnector; return(true); } else { base.AttachableEditorElement = null; return(false); } } else {//if hit connector is down bump type if (this.IsPreviousBlockEditorUnitAssignable) { base.AttachableEditorElement = flowBlockConnector; return(true); } else { base.AttachableEditorElement = null; return(false); } } } }
sealed public override bool AttachBlock() { if (this.AttachableEditorElement != null) { FlowBlockConnector flowBlockConnector = this.AttachableEditorElement as FlowBlockConnector; if (flowBlockConnector._ConnectorType == FlowBlockConnector.ConnectorType.UpNotch) {//if hit connector is up notch type ConnectFlowBlockEditorUnit(flowBlockConnector.OwnerFlowBlockEditorUnit.PreviousFlowBlockEditorUnit, this); ConnectFlowBlockEditorUnit(this.LowestDescendantBlockUnit ?? this, flowBlockConnector.OwnerFlowBlockEditorUnit); } else { FlowBlockEditorUnit originalNextBlock = flowBlockConnector.OwnerFlowBlockEditorUnit.NextFlowBlockEditorUnit; ConnectFlowBlockEditorUnit(flowBlockConnector.OwnerFlowBlockEditorUnit, this); ConnectFlowBlockEditorUnit(this.LowestDescendantBlockUnit ?? this, originalNextBlock); } return(true); } else { return(false); } }