public bool CheckRaving() { toyCache.Clear(); CellDirector.GetToysNearMember(regionMember, toyCache); return(toyCache.Any((x) => x.Id == CustomIds.RAVE_BALL_TOY && x.gameObject != null && Vector3.Distance(x.gameObject.transform.position, transform.position) < 10f)); }
/// <summary> /// Spawns all areas in the reigstry list /// </summary> internal static void SpawnAreas() { // Register full areas foreach (Area area in Areas) { // Create object GameObject obj = UnityEngine.Object.Instantiate(area.area, area.position, Quaternion.identity); obj.name = area.area.name; // Setup Zone Director ZoneDirector director = obj.AddComponent <ZoneDirector>(); area.directorSetup?.Invoke(director); // Setup Each Cell foreach (Transform child in obj.transform) { if (area.cellSetup == null) { break; } if (!child.name.StartsWith("cell")) { continue; } CellDirector cell = child.gameObject.AddComponent <CellDirector>(); Region region = child.gameObject.AddComponent <Region>(); child.gameObject.AddComponent <RegionInitializer>(); area.cellSetup.Invoke(cell, region); } // Setup Each Marker foreach (AreaObjMarker marker in obj.GetComponentsInChildren <AreaObjMarker>()) { if (area.spawnAction == null) { break; } GameObject mo = SRObjects.GetInst <GameObject>(marker.objName); mo.transform.parent = marker.transform.parent; mo.transform.localPosition = marker.transform.localPosition; if (!marker.runSpawnAction) { continue; } area.spawnAction.Invoke(mo); } } // Register area cells foreach (AreaCell area in AreaCells) { // Create object GameObject obj = UnityEngine.Object.Instantiate(area.cell, area.position, Quaternion.identity, ZoneDirector.zones[area.zone].transform); obj.name = area.cell.name; // Setup Cell CellDirector cell = obj.AddComponent <CellDirector>(); Region region = obj.AddComponent <Region>(); obj.AddComponent <RegionInitializer>(); area.cellSetup.Invoke(cell, region); // Setup Each Marker foreach (AreaObjMarker marker in obj.GetComponentsInChildren <AreaObjMarker>()) { if (area.spawnAction == null) { break; } GameObject mo = SRObjects.GetInst <GameObject>(marker.objName); mo.transform.parent = marker.transform.parent; mo.transform.localPosition = marker.transform.localPosition; if (!marker.runSpawnAction) { continue; } area.spawnAction.Invoke(mo); } } // Register area cell content foreach (AreaCellContent area in CellContent) { // Get parent cell Transform parentCell = ZoneDirector.zones[area.zone].transform.Find(area.cellName); if (parentCell == null) { continue; } // Create object GameObject obj = UnityEngine.Object.Instantiate(area.content, area.position, Quaternion.identity, parentCell.transform); obj.name = area.content.name; // Setup Each Marker foreach (AreaObjMarker marker in obj.GetComponentsInChildren <AreaObjMarker>()) { if (area.spawnAction == null) { break; } GameObject mo = SRObjects.GetInst <GameObject>(marker.objName); mo.transform.parent = marker.transform.parent; mo.transform.localPosition = marker.transform.localPosition; if (!marker.runSpawnAction) { continue; } area.spawnAction.Invoke(mo); } } }