コード例 #1
0
    public IEnumerator DoInteraction(Unit unit)
    {
        if (storable.state != Storable.State.InWorld)
        {
            yield break;
        }

        yield return(storable.DoInteraction(unit));

        yield return(Inventory.StoreInteraction(unit));

        // Keep building the other buildings nearby
        Collider[] nearby = Physics.OverlapSphere(unit.transform.position, 10f);
        if (nearby != null)
        {
            for (int i = 0; i < nearby.Length; i++)
            {
                MoveToStorageInteraction nearbyStorable = nearby[i].GetComponent <MoveToStorageInteraction>();
                if (nearbyStorable && nearbyStorable.IsEnabled())
                {
                    yield return(nearbyStorable.DoInteraction(unit));
                }
            }
        }
        yield break;
    }