public static CoverPointVolume CreateNewCoverVolume( Vector3 point, Transform coverPointGroup) { if (!Object.op_Inequality((Object)SingletonComponent <AiManager> .Instance, (Object)null) || !((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() || !((AiManager)SingletonComponent <AiManager> .Instance).UseCover) { return((CoverPointVolume)null); } CoverPointVolume coverPointVolume = ((AiManager)SingletonComponent <AiManager> .Instance).GetCoverVolumeContaining(point); if (Object.op_Equality((Object)coverPointVolume, (Object)null)) { Vector2i gridCoords = ((AiManager)SingletonComponent <AiManager> .Instance).coverPointVolumeGrid.WorldToGridCoords(point); coverPointVolume = !Object.op_Inequality((Object)((AiManager)SingletonComponent <AiManager> .Instance).cpvPrefab, (Object)null) ? (CoverPointVolume) new GameObject("CoverPointVolume").AddComponent <CoverPointVolume>() : (CoverPointVolume)Object.Instantiate <CoverPointVolume>((M0)((AiManager)SingletonComponent <AiManager> .Instance).cpvPrefab); ((Component)coverPointVolume).get_transform().set_localPosition((Vector3)null); ((Component)coverPointVolume).get_transform().set_position(Vector3.op_Addition(((AiManager)SingletonComponent <AiManager> .Instance).coverPointVolumeGrid.GridToWorldCoords(gridCoords), Vector3.op_Multiply(Vector3.get_up(), (float)point.y))); ((Component)coverPointVolume).get_transform().set_localScale(new Vector3(((AiManager)SingletonComponent <AiManager> .Instance).CoverPointVolumeCellSize, ((AiManager)SingletonComponent <AiManager> .Instance).CoverPointVolumeCellHeight, ((AiManager)SingletonComponent <AiManager> .Instance).CoverPointVolumeCellSize)); coverPointVolume.CoverLayerMask = ((AiManager)SingletonComponent <AiManager> .Instance).DynamicCoverPointVolumeLayerMask; coverPointVolume.CoverPointRayLength = ((AiManager)SingletonComponent <AiManager> .Instance).CoverPointRayLength; ((AiManager)SingletonComponent <AiManager> .Instance).coverPointVolumeGrid.set_Item(gridCoords, coverPointVolume); coverPointVolume.GenerateCoverPoints(coverPointGroup); } return(coverPointVolume); }
public static CoverPointVolume CreateNewCoverVolume(Vector3 point, Transform coverPointGroup) { if (!(SingletonComponent <AiManager> .Instance != null) || !SingletonComponent <AiManager> .Instance.enabled || !SingletonComponent <AiManager> .Instance.UseCover) { return(null); } CoverPointVolume coverVolumeContaining = SingletonComponent <AiManager> .Instance.GetCoverVolumeContaining(point); if (coverVolumeContaining == null) { Vector2i gridCoords = SingletonComponent <AiManager> .Instance.coverPointVolumeGrid.WorldToGridCoords(point); coverVolumeContaining = (SingletonComponent <AiManager> .Instance.cpvPrefab == null ? (new GameObject("CoverPointVolume")).AddComponent <CoverPointVolume>() : UnityEngine.Object.Instantiate <CoverPointVolume>(SingletonComponent <AiManager> .Instance.cpvPrefab)); coverVolumeContaining.transform.localPosition = new Vector3(); coverVolumeContaining.transform.position = SingletonComponent <AiManager> .Instance.coverPointVolumeGrid.GridToWorldCoords(gridCoords) + (Vector3.up * point.y); coverVolumeContaining.transform.localScale = new Vector3(SingletonComponent <AiManager> .Instance.CoverPointVolumeCellSize, SingletonComponent <AiManager> .Instance.CoverPointVolumeCellHeight, SingletonComponent <AiManager> .Instance.CoverPointVolumeCellSize); coverVolumeContaining.CoverLayerMask = SingletonComponent <AiManager> .Instance.DynamicCoverPointVolumeLayerMask; coverVolumeContaining.CoverPointRayLength = SingletonComponent <AiManager> .Instance.CoverPointRayLength; SingletonComponent <AiManager> .Instance.coverPointVolumeGrid[gridCoords] = coverVolumeContaining; coverVolumeContaining.GenerateCoverPoints(coverPointGroup); } return(coverVolumeContaining); }