void RemovePullableObject(PullData pullData) { if (!pullData.HadRigidbody) { pullData.RemoveRigidbody(); } pullableDatas.Remove(pullData); }
void AddPullableObject(PullData pullData) { if (!pullData.ObjectRigidbody) { pullData.AddRigidbody(); } pullableDatas.Add(pullData); }
public void RemoveGravityObject(PullData pullData) { if (pullableDatas.Contains(pullData)) { RemovePullableObject(pullData); } if (pullerDatas.Contains(pullData)) { pullerDatas.Remove(pullData); } }
public void AddGravityObject(PullData pullData) { RemoveGravityObject(pullData); if (pullData.Type == PullType.Both) { AddPullableObject(pullData); pullerDatas.Add(pullData); } else if (pullData.Type == PullType.Pullable) { AddPullableObject(pullData); } else { pullerDatas.Add(pullData); } }
Vector3 GetAffectingPullPower(PullData pullData) { Vector3 pullPower = Vector3.zero; if (pullData.Type != PullType.Puller) { var count = pullerDatas.Count; for (int i = 0; i < count; i++) { var pullerData = pullerDatas[i]; if (pullerData == pullData) { continue; } Vector3 positionDifference = pullerData.ObjectTransform.position - pullData.ObjectTransform.position; pullPower += positionDifference.normalized * pullerData.PullPower * pullData.PullPower / Mathf.Pow(Mathf.Max(positionDifference.magnitude, minDistance), 2); } } return(pullPower); }