Example #1
0
    public void GatherAllReceptaclesInScene()
    {
        foreach (SimObjPhysics sop in UniqueIdToSimObjPhysics.Values)
        {
            if (sop.DoesThisObjectHaveThisSecondaryProperty(SimObjSecondaryProperty.Receptacle))
            {
                ReceptaclesInScene.Add(sop);

                foreach (GameObject go in sop.ReceptacleTriggerBoxes)
                {
                    if (go == null)
                    {
                        Debug.LogWarning(sop.gameObject + " has non-empty receptacle trigger boxes but contains a null value.");
                        continue;
                    }
                    Contains c = go.GetComponent <Contains>();
                    c.CurrentlyContainedObjects().Clear();
                    c.GetComponent <Collider>().enabled = false;
                    c.GetComponent <Collider>().enabled = true;
                    if (c == null)
                    {
                        Debug.LogWarning(sop.gameObject + " is missing a contains script on one of its receptacle boxes.");
                        continue;
                    }
                    if (go.GetComponent <Contains>().myParent == null)
                    {
                        go.GetComponent <Contains>().myParent = sop.transform.gameObject;
                    }
                }
            }
        }
        ReceptaclesInScene.Sort((r0, r1) => (r0.gameObject.GetInstanceID().CompareTo(r1.gameObject.GetInstanceID())));
    }