public void OnTouchEnd(int fingerId, Vector2 touchPosWorld) { if (Build.HoldingPart.isNull(this.holdingParts[fingerId])) { return; } Vector2 vector = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset); Vector2 autoCorrect = this.GetAutoCorrect(vector, fingerId); Vector2 a = Vector3.Lerp(vector, autoCorrect, 1f - this.roundStrength); Vector2 v = a + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : (this.holdingParts[fingerId].part.partData.centerOfRotation * this.holdingParts[fingerId].part.orientation)); bool flag = Utility.IsInsideRange(v.x - this.buildGrid.transform.position.x, -0.5f, this.buildGrid.width + 0.5f, true) && Utility.IsInsideRange(v.y - this.buildGrid.transform.position.y, -0.5f, this.buildGrid.height + 0.5f, true); bool flag2 = this.pickGrid.IsInsideDropArea(Utility.ToDepth(v, this.pickMenuDistance)); if (flag && !flag2) { PlacedPart newPart = new PlacedPart(null, (Vector3)autoCorrect - this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData); MyPartCreatedHook hook = new MyPartCreatedHook(newPart); hook = MyHookSystem.executeHook <MyPartCreatedHook>(hook); if (hook.isCanceled()) { return; } this.dragAndDropInstruction.InvokeEvenets(); this.buildGrid.PlacePart(hook.target); } if (this.holdingParts[fingerId].part.partIcon != null) { UnityEngine.Object.Destroy(this.holdingParts[fingerId].part.partIcon.gameObject); } this.holdingParts[fingerId] = null; }
public void OnTouchEnd(int fingerId, Vector2 touchPosWorld) { if (Build.HoldingPart.isNull(this.holdingParts[fingerId])) { return; } Vector2 vector = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset); Vector2 vector2 = this.GetAutoCorrect(vector, fingerId); Vector2 a = Vector3.Lerp(vector, vector2, 1f - this.roundStrength); Vector2 v = a + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : (this.holdingParts[fingerId].part.partData.centerOfRotation * this.holdingParts[fingerId].part.orientation)); bool flag = Utility.IsInsideRange(v.x - this.buildGrid.transform.position.x, -0.5f, this.buildGrid.width + 0.5f, true) && Utility.IsInsideRange(v.y - this.buildGrid.transform.position.y, -0.5f, this.buildGrid.height + 0.5f, true); bool flag2 = this.pickGrid.IsInsideDropArea(Utility.ToDepth(v, this.pickMenuDistance)); if (flag && !flag2) { PlacedPart targetPart = new PlacedPart(null, vector2 - (Vector2)this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData); MyPartCreatedHook myPartCreatedHook = new MyPartCreatedHook(targetPart); myPartCreatedHook = MyHookSystem.executeHook <MyPartCreatedHook>(myPartCreatedHook); bool flag5 = myPartCreatedHook.isCanceled(); if (flag5) { return; } if (this.holdingParts[fingerId].part.partData.flip2stickX && this.ConnectedSurface(vector2, fingerId) == 0f) { this.FlipX(); Vector2 vector3 = vector2; vector = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset); vector2 = this.GetAutoCorrect(vector, fingerId); if (this.ConnectedSurface(vector2, fingerId) == 0f) { this.FlipX(); vector2 = vector3; } } bool placeActive = !this.holdingParts[fingerId].part.partData.inFull || Ref.hasPartsExpansion; this.buildGrid.PlacePart(new PlacedPart(null, vector2 - (Vector2)this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData), placeActive); } if (this.holdingParts[fingerId].part.partIcon != null) { UnityEngine.Object.Destroy(this.holdingParts[fingerId].part.partIcon.gameObject); } this.holdingParts[fingerId] = null; }