public void UpdateViewCollision(bool viewCollision) { if (perso.collSet != null) { CollSet c = perso.collSet; if (collSetObjects == null) { collSetObjects = new Dictionary <CollideType, GameObject[]>(); foreach (KeyValuePair <CollideType, ZdxList> zdxListKV in c.zdxList) { CollideType type = zdxListKV.Key; ZdxList zdxList = zdxListKV.Value; if (zdxList == null) { continue; } collSetObjects[type] = new GameObject[zdxList.entries?.Length ?? 0]; for (int i = 0; i < zdxList.entries?.Length; i++) { ZdxEntry zdx = zdxList.entries[i]; collSetObjects[type][i] = zdx.GetGameObject(type); collSetObjects[type][i].transform.SetParent(transform); collSetObjects[type][i].transform.localPosition = Vector3.zero; collSetObjects[type][i].transform.localRotation = Quaternion.identity; collSetObjects[type][i].transform.localScale = Vector3.one; } } } foreach (KeyValuePair <CollideType, GameObject[]> entry in collSetObjects) { if (entry.Value != null && entry.Value.Length > 0) { foreach (GameObject gao in entry.Value) { if (gao != null) { gao.SetActive(false); } } } } if (viewCollision) { if (state != null && c.activationList != null) { foreach (KeyValuePair <CollideType, short> activationZone in state.zoneZdx) { CollideType type = activationZone.Key; short cur_activation = activationZone.Value; if (cur_activation == -1) { continue; } if (!collSetObjects.ContainsKey(type) || collSetObjects[type] == null) { continue; } if (cur_activation < 0 || cur_activation >= c.activationList.num_activationZones) { continue; } if (c.activationList.activationZones[cur_activation].num_activations == 0) { continue; } for (int i = 0; i < c.activationList.activationZones[cur_activation].activations.Length; i++) { uint ind_zdx = c.activationList.activationZones[cur_activation].activations[i]; if (collSetObjects[type].Length <= ind_zdx) { continue; } GameObject gao = collSetObjects[type][ind_zdx]; if (gao == null) { continue; } gao.SetActive(true); } } } } } }
public void UpdateViewCollision(bool viewCollision) { if (perso.collset.Value != null) { CollSet c = perso.collset.Value; if (collSetObjects == null) { collSetObjects = new Dictionary <CollideType, GameObject[]>(); foreach (KeyValuePair <CollideType, Reference <ZdxList> > entry in c.zdxList) { if (entry.Value.Value != null) { ZdxList zdx = entry.Value.Value; collSetObjects[entry.Key] = new GameObject[zdx.num_objects]; if (zdx.num_objects > 0 && zdx.objects.Value != null) { for (int i = 0; i < zdx.objects.Value.objects.Length; i++) { GeometricObject geo = zdx.objects.Value.objects[i].Value; if (geo == null) { continue; } collSetObjects[entry.Key][i] = geo.GetGameObject(GeometricObject.Type.Collide, entry.Key); collSetObjects[entry.Key][i].transform.SetParent(transform); collSetObjects[entry.Key][i].transform.localPosition = Vector3.zero; collSetObjects[entry.Key][i].transform.localRotation = Quaternion.identity; collSetObjects[entry.Key][i].transform.localScale = Vector3.one; /*if(viewCollision && * if (viewCollision && c.GetPrivilegedActionZoneStatus(entry.Key, i) == CollSet.PrivilegedActivationStatus.ForceActive) { * col.SetVisualsActive(true); * } else { * col.SetVisualsActive(false); * }*/ } } } } } foreach (KeyValuePair <CollideType, GameObject[]> entry in collSetObjects) { if (entry.Value != null && entry.Value.Length > 0) { foreach (GameObject gao in entry.Value) { if (gao != null) { gao.SetActive(false); } } } } if (viewCollision) { foreach (KeyValuePair <CollideType, Reference <ActivationList> > entry in c.activationList) { if (!collSetObjects.ContainsKey(entry.Key)) { continue; } if (entry.Value.Value != null && entry.Value.Value.num_objects > 0 && entry.Value.Value.objects.Value != null) { ActivationZoneArray azr = entry.Value.Value.objects.Value; if (azr.elements.Length == 0) { continue; } for (int i = 0; i < azr.elements.Length; i++) { if (azr.elements[i].state.Value == state) { ActivationZone zone = azr.elements[i].activationList.Value; if (zone != null && zone.num_objects > 0 && zone.objects.Value != null) { foreach (ushort act in zone.objects.Value.objects) { if (collSetObjects[entry.Key].Length > act && collSetObjects[entry.Key][act] != null) { collSetObjects[entry.Key][act].SetActive(true); } } } break; } } } } } } }