public bool TryGetForce(IOceanData data, BuoyancyObject sender, out PosAndForce value) { value = new PosAndForce(); var pos = value.Position = transform.TransformPoint(offset); var distanceToSurface = data.DistanceToSurface(pos); float radius = ActualRadius; if (distanceToSurface > radius) { return(false); } else { float scale = (radius - distanceToSurface) / (radius * 2); scale = Mathf.Clamp01(scale); value.Force = data.Density * -Physics.gravity * scale * powerScale * sender.Power; return(true); } }
public static bool Unsubscribe(BuoyancyObject sender) { return(objects.Remove(sender)); }
public static bool Subscribe(BuoyancyObject sender) { Initialize(); return(objects.Add(sender)); }