private void AttachColliderToIntersectionMap(VisualTriggerMarkerComponent trigger, Entity entity, TankPartIntersectionWithCameraData[] map, int index) { MeshCollider visualTriggerMeshCollider = trigger.VisualTriggerMeshCollider; map[index] = new TankPartIntersectionWithCameraData(visualTriggerMeshCollider, entity); entity.AddComponent <TankPartNotIntersectedWithCameraStateComponent>(); }
public void InitCollidersForChecking(NodeAddedEvent evt, TankNode tank, [Context, JoinByTank] WeaponNode weapon) { VisualTriggerMarkerComponent visualTriggerMarker = tank.tankVisualRoot.VisualTriggerMarker; VisualTriggerMarkerComponent trigger = weapon.weaponVisualRoot.VisualTriggerMarker; TankPartIntersectionWithCameraData[] map = new TankPartIntersectionWithCameraData[2]; this.AttachColliderToIntersectionMap(visualTriggerMarker, tank.Entity, map, 0); this.AttachColliderToIntersectionMap(trigger, weapon.Entity, map, 1); tank.Entity.AddComponent(new TankPartIntersectionWithCameraMapComponent(map)); }
public void ResetState(NodeRemoveEvent evt, TankPartIntersectionWithCameraMapVisibleNode tank) { TankPartIntersectionWithCameraData[] tankPartIntersectionMap = tank.tankPartIntersectionWithCameraMap.TankPartIntersectionMap; int length = tankPartIntersectionMap.Length; for (int i = 0; i < length; i++) { TankPartIntersectionWithCameraData data = tankPartIntersectionMap[i]; Entity tankPart = data.entity; this.UpdateState(tankPart, false); } }
private void CheckCameraVisualIntersection(TankPartIntersectionWithCameraMapVisibleNode tank, CameraNode camera) { Vector3 position = camera.cameraRootTransform.Root.position; TankPartIntersectionWithCameraData[] tankPartIntersectionMap = tank.tankPartIntersectionWithCameraMap.TankPartIntersectionMap; int length = tankPartIntersectionMap.Length; for (int i = 0; i < length; i++) { TankPartIntersectionWithCameraData data = tankPartIntersectionMap[i]; Collider collider = data.collider; Entity tankPart = data.entity; bool hasIntersection = this.CheckPointInsideCollider(position, collider); this.UpdateState(tankPart, hasIntersection); } }