public bool CanCustomConnectTo(BasePart.Direction direction) { switch (this.GetCustomJointConnectionDirection()) { case BasePart.JointConnectionDirection.Any: return(true); case BasePart.JointConnectionDirection.Right: return(direction == BasePart.Direction.Right); case BasePart.JointConnectionDirection.Up: return(direction == BasePart.Direction.Up); case BasePart.JointConnectionDirection.Left: return(direction == BasePart.Direction.Left); case BasePart.JointConnectionDirection.Down: return(direction == BasePart.Direction.Down); case BasePart.JointConnectionDirection.LeftAndRight: return(direction == BasePart.Direction.Left || direction == BasePart.Direction.Right); case BasePart.JointConnectionDirection.UpAndDown: return(direction == BasePart.Direction.Up || direction == BasePart.Direction.Down); case BasePart.JointConnectionDirection.None: return(false); default: return(false); } }
public static Direction OppositeGlueDir(BasePart.Direction dir) { if (dir == BasePart.Direction.Left || dir == BasePart.Direction.Right) { return((dir != BasePart.Direction.Left) ? Glue.Direction.Left : Glue.Direction.Right); } return((dir != BasePart.Direction.Up) ? Glue.Direction.Up : Glue.Direction.Down); }
public override void Initialize() { this.m_GrapplingHook = UnityEngine.Object.Instantiate <GameObject>(this.m_GrapplingHookPrefab, base.transform.position, base.transform.rotation); this.m_GrapplingHookRigidbody = this.m_GrapplingHook.GetComponent <Rigidbody>(); this.m_GrapplingHook.transform.parent = base.transform; this.m_GrapplingHookScript = this.m_GrapplingHook.GetComponent <Hook>(); this.m_GrapplingHook.SetActive(true); this.InitializeGrapplingHook(); if (WPFMonoBehaviour.levelManager.ContraptionRunning == null) { return; } BasePart.Direction direction = this.EffectDirection(); int num = (direction != BasePart.Direction.Left) ? ((direction != BasePart.Direction.Right) ? 0 : 1) : -1; int num2 = (direction != BasePart.Direction.Down) ? ((direction != BasePart.Direction.Up) ? 0 : 1) : -1; BasePart basePart = WPFMonoBehaviour.levelManager.ContraptionRunning.FindPartAt(this.m_coordX + num, this.m_coordY + num2); this.m_CanBeEnabled = (!WPFMonoBehaviour.levelManager.ContraptionRunning.HasSuperGlue || !this.m_FixedJointToBreak[0] || basePart.m_partType == BasePart.PartType.TNT); }
public static Vector3 GetDirectionVector(BasePart.Direction direction) { switch (direction) { case BasePart.Direction.Right: return(Vector3.right); case BasePart.Direction.Up: return(Vector3.up); case BasePart.Direction.Left: return(-Vector3.right); case BasePart.Direction.Down: return(-Vector3.up); default: return(Vector3.up); } }
public static BasePart.Direction InverseDirection(BasePart.Direction direction) { switch (direction) { case BasePart.Direction.Right: return(BasePart.Direction.Left); case BasePart.Direction.Up: return(BasePart.Direction.Down); case BasePart.Direction.Left: return(BasePart.Direction.Right); case BasePart.Direction.Down: return(BasePart.Direction.Up); default: return(BasePart.Direction.Right); } }
public void CreateSpringBody(BasePart.Direction direction) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_endPointPrefab, base.transform.position, base.transform.rotation); ConfigurableJoint configurableJoint = base.gameObject.AddComponent <ConfigurableJoint>(); configurableJoint.connectedBody = gameObject.GetComponent <Rigidbody>(); configurableJoint.angularXMotion = ConfigurableJointMotion.Locked; configurableJoint.angularYMotion = ConfigurableJointMotion.Locked; configurableJoint.angularZMotion = ConfigurableJointMotion.Locked; configurableJoint.xMotion = ConfigurableJointMotion.Locked; configurableJoint.yMotion = ConfigurableJointMotion.Limited; configurableJoint.zMotion = ConfigurableJointMotion.Locked; configurableJoint.enablePreprocessing = false; configurableJoint.configuredInWorldSpace = true; SoftJointLimitSpring linearLimitSpring = configurableJoint.linearLimitSpring; linearLimitSpring.spring = 250f; linearLimitSpring.damper = 20f; configurableJoint.linearLimitSpring = linearLimitSpring; SoftJointLimit linearLimit = configurableJoint.linearLimit; linearLimit.limit = 0.1f; linearLimit.bounciness = 1f; configurableJoint.linearLimit = linearLimit; gameObject.transform.parent = base.transform; if (this.m_connectedBody == null) { this.m_connectedBody = gameObject.GetComponent <Rigidbody>(); this.m_localConnectionPoint = new Vector3(0f, 0.5f, 0f); this.m_remoteConnectionPoint = gameObject.transform.InverseTransformPoint(base.transform.position - 0.5f * base.transform.up); } else { Vector3 position = this.m_connectedBody.position + (base.transform.position - this.m_connectedBody.position).normalized * 0.5f; this.m_connectedBody = gameObject.GetComponent <Rigidbody>(); this.m_connectedBody.position = position; this.m_localConnectionPoint = new Vector3(0f, 0.5f, 0f); this.m_remoteConnectionPoint = gameObject.transform.InverseTransformPoint(base.transform.position - 0.5f * base.transform.up); } }
public override void Initialize() { this.m_BoxingGlove = UnityEngine.Object.Instantiate <GameObject>(this.m_BoxingGlovePrefab, base.transform.position, base.transform.rotation); this.m_BoxingGloveRigidbody = this.m_BoxingGlove.GetComponent <Rigidbody>(); this.m_BoxingGlove.transform.parent = base.transform; this.m_BoxingGloveVisualization = this.m_BoxingGlove.transform.Find("Visualization").gameObject; this.CheckRotations(); this.m_BoxingGlove.SetActive(true); this.InitilizeBoxingGlove(); if (WPFMonoBehaviour.levelManager.ContraptionRunning == null) { return; } BasePart.Direction direction = this.EffectDirection(); int num = (direction != BasePart.Direction.Left) ? ((direction != BasePart.Direction.Right) ? 0 : 1) : -1; int num2 = (direction != BasePart.Direction.Down) ? ((direction != BasePart.Direction.Up) ? 0 : 1) : -1; this.m_EffectDirPart = WPFMonoBehaviour.levelManager.ContraptionRunning.FindPartAt(this.m_coordX + num, this.m_coordY + num2); if (this.m_EffectDirPart) { this.m_FixedJointToBreak = WPFMonoBehaviour.levelManager.ContraptionRunning.FindPartFixedJoints(this.m_EffectDirPart); } this.m_CanBeEnabled = (!WPFMonoBehaviour.levelManager.ContraptionRunning.HasSuperGlue || this.m_FixedJointToBreak == null || this.m_FixedJointToBreak.Count <= 0 || !this.m_FixedJointToBreak[0] || this.m_EffectDirPart.m_partType == BasePart.PartType.TNT); }
public GadgetControlEvent(BasePart.PartType partType, BasePart.Direction direction) { this.partType = partType; this.direction = direction; }