Example #1
0
    protected virtual void Update()
    {
        List <SurfaceDeposit> surface_deposits = SurfaceDeposits.OrderBy(surface_deposit => surface_deposit.Extent).Reverse().ToList();

        while (surface_deposits.Count > 0)
        {
            SurfaceDeposit surface_deposit = surface_deposits.TakeAt(0);

            foreach (SurfaceDeposit other_surface_deposit in new List <SurfaceDeposit>(SurfaceDeposits))
            {
                if (other_surface_deposit == surface_deposit)
                {
                    continue;
                }

                float distance = surface_deposit.transform.position
                                 .Distance(other_surface_deposit.transform.position);

                if (distance <= surface_deposit.Extent)
                {
                    surface_deposit.AddTo(other_surface_deposit.Composition.Normalized() * other_surface_deposit.Volume);

                    surface_deposits.Remove(other_surface_deposit);
                    other_surface_deposit.transform.SetParent(null);
                    GameObject.Destroy(other_surface_deposit.gameObject);
                }
            }
        }
    }
Example #2
0
    public void Litter(Vector3 position, Pile pile)
    {
        if (pile.Volume == 0)
        {
            return;
        }

        SurfaceDeposit nearest_deposit = SurfaceDeposits.ToList()
                                         .Find(deposit => deposit.transform.position.Distance(position) <= deposit.Extent);

        if (nearest_deposit == null)
        {
            nearest_deposit = SurfaceDeposit.Create();
            nearest_deposit.transform.SetParent(Surface.transform);
            nearest_deposit.transform.position = position;
        }


        nearest_deposit.AddTo(pile);
    }