private void OnDestroy() { browseEntities.Dispose(); ECSUtils.DisableSystems(typeof(VehicleSelectionScreenQueueSystem), typeof(VehicleSelectionScreenInputHandler), typeof(VehicleSelectionScreenCameraSystem), typeof(VehicleSelectionScreenCameraTransformSystem)); }
private void InstantiateEntity(int size, GameObject template, Transform[] transforms) { for (int i = 0; i < size; i++) { var origName = transforms[i].name; var position = transforms[i].position; var rotation = transforms[i].rotation; var gameObject = GameObject.Instantiate(template, position, rotation); gameObject.name = origName; var entity = entities[i]; // Set the index value of the checkpoint entityManager.SetComponentData(entity, new IntId { value = i }); entityManager.SetComponentData(entity, new Position { Value = position }); entityManager.SetComponentData(entity, new Rotation { Value = rotation }); entityManager.SetComponentData(entity, new Scale { Value = template.GetComponent <ScaleComponent>().Value.Value }); var meshInstance = gameObject.GetComponent <MeshInstanceRendererComponent>().Value; entityManager.SetSharedComponentData(entity, new MeshInstanceRenderer { mesh = meshInstance.mesh, material = meshInstance.material, receiveShadows = true, castShadows = UnityEngine.Rendering.ShadowCastingMode.On }); var checkpoint = gameObject.GetComponent <CheckpointDetectionComponent>().Value; entityManager.SetSharedComponentData(entity, new CheckpointDetection { name = origName, matrix = gameObject.transform.localToWorldMatrix, values = checkpoint.values }); var colliders = gameObject.GetComponentsInChildren <Collider>(); entityManager.SetSharedComponentData(entity, new ColliderInstances { values = colliders }); ECSUtils.RemoveComponentWrappers(gameObject, typeof(MeshInstanceRenderer), typeof(ScaleComponent), typeof(CheckpointDetectionComponent), typeof(MeshFilter), typeof(MeshRenderer), typeof(MeshInstanceRendererComponent) ); } }
private void Awake() { Assert.IsNotNull(template, "No Camera found!"); Assert.IsNotNull(playerPool, "No PlayerPool found!"); Assert.IsNotNull(cache, "No SelectionCache found!"); PlayerPool = playerPool; VehicleSelectionCache = cache; // TODO: Uncomment ECSUtils.DisableSystems(typeof(GameplayPlayerPhysicsMoveSystem), typeof(GameplayPlayerHoverSystem)); #if UNITY_EDITOR ECSUtils.DisableSystems(typeof(Derby.Tests.CameraTestSystem), typeof(Derby.Tests.CameraTransformUpdater)); #endif }
protected override void SetUp(GameObject gameObject, int size) { for (int i = 0; i < entities.Length; i++) { var template = GameObject.Instantiate(gameObject); var camera = template.GetComponent <Camera>(); var entity = entities[i]; entityManager.SetComponentData(entity, new IntId { value = i }); entityManager.SetSharedComponentData(entity, new CameraInstance { camera = template.GetComponent <Camera>() }); CameraUtils.SetUpCamera(ref camera, i, size); ECSUtils.RemoveComponentWrappers(template, typeof(CameraInstanceComponent)); } }
private void SetUp() { ECSUtils.EnableSystems(typeof(GameplayPlayerHoverSystem), typeof(GameplayPlayerPhysicsMoveSystem), typeof(GameplayInputHandler), typeof(GameplayPlayerInputInterpreter)); }
protected override void SetUp(int size) { for (int i = 0; i < size; i++) { var entity = entities[i]; var gameObject = GameObject.Instantiate(profile[cache[i]]); #if UNITY_EDITOR if (DebugVelocity) { TryAddVelocityDrawer(gameObject); } #endif entityManager.SetSharedComponentData(entity, new RigidbodyInstance { rigidbody = gameObject.GetComponent <Rigidbody>() }); // Set up the player id entityManager.SetComponentData(entity, new IntId { value = i }); // Set up the car movement constraint (dead zone) entityManager.SetComponentData(entity, new FloatId { value = gameObject.GetComponent <VehicleMovementConstraintComponent>().Value.value }); var vehicleSpeed = gameObject.GetComponent <VehicleSpeedComponent>().Value; entityManager.SetComponentData(entity, new VehicleSpeed { forwardSpeed = vehicleSpeed.forwardSpeed, backwardSpeed = vehicleSpeed.backwardSpeed, turnSpeed = vehicleSpeed.turnSpeed, drag = vehicleSpeed.drag }); var hoverPoints = gameObject.GetComponent <HoverPointsComponent>().Value; entityManager.SetSharedComponentData(entity, new HoverPoints { hoverPoints = hoverPoints.hoverPoints }); var vehiclePhysics = gameObject.GetComponent <VehiclePhysicsComponent>().Value; entityManager.SetComponentData(entity, new VehiclePhysics { hover = vehiclePhysics.hover, gravity = vehiclePhysics.gravity, height = vehiclePhysics.height }); var playerCamera = gameObject.GetComponent <PlayerCameraComponent>().Value; entityManager.SetComponentData(entity, new PlayerCamera { translationSpeed = playerCamera.translationSpeed, rotationSpeed = playerCamera.rotationSpeed, minDistance = playerCamera.minDistance, lookAheadFactor = playerCamera.lookAheadFactor }); entityManager.SetSharedComponentData(entity, new ColliderInstances { values = gameObject.GetComponentsInChildren <Collider>() }); // Set the rotational and positional data entityManager.SetComponentData(entity, new Position { Value = gameObject.transform.position }); entityManager.SetComponentData(entity, new Rotation { Value = gameObject.transform.rotation }); ECSUtils.RemoveComponentWrappers(gameObject, typeof(VehicleMovementConstraintComponent), typeof(VehicleSpeedComponent), typeof(HoverPointsComponent), typeof(VehiclePhysicsComponent), typeof(PlayerCameraComponent) ); } }