コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public static bool Unsubscribe(BuoyancyObject sender)
 {
     return(objects.Remove(sender));
 }
コード例 #3
0
 public static bool Subscribe(BuoyancyObject sender)
 {
     Initialize();
     return(objects.Add(sender));
 }