protected override void OnUpdate() { var grenadePresentArray = Group.GetComponentArray <GrenadePresentation>(); var grenadeClientArray = Group.GetComponentArray <GrenadeClient>(); var time = m_world.worldTime; for (var i = 0; i < grenadePresentArray.Length; i++) { var presentation = grenadePresentArray[i]; var grenadeClient = grenadeClientArray[i]; presentation.transform.position = presentation.state.position; if (presentation.state.bouncetick > grenadeClient.bounceTick) { grenadeClient.bounceTick = presentation.state.bouncetick; Game.SoundSystem.Play(grenadeClient.bounceSound, presentation.state.position); } if (presentation.state.exploded && !grenadeClient.exploded) { grenadeClient.exploded = true; grenadeClient.geometry.SetActive(false); if (grenadeClient.explodeEffect != null) { SpatialEffectRequest.Create(PostUpdateCommands, grenadeClient.explodeEffect, presentation.state.position, Quaternion.identity); } } } }
protected override void OnUpdate() { var playerCharControlArray = Group.GetComponentArray <PlayerCharacterControl>(); var playerStateArray = Group.GetComponentArray <PlayerState>(); for (var i = 0; i < playerCharControlArray.Length; i++) { var player = playerStateArray[i]; var controlledEntity = player.controlledEntity; if (controlledEntity == Entity.Null || !EntityManager.HasComponent <Character>(controlledEntity)) { continue; } var character = EntityManager.GetComponentObject <Character>(controlledEntity); // Update character team character.teamId = player.teamIndex; // Update hit collision if (EntityManager.HasComponent <HitCollisionOwnerData>(controlledEntity)) { var hitCollisionOwner = EntityManager.GetComponentData <HitCollisionOwnerData>(controlledEntity); hitCollisionOwner.colliderFlags = 1U << character.teamId; EntityManager.SetComponentData(controlledEntity, hitCollisionOwner); } character.characterName = player.playerName; } }
protected override void Initialize(ref ComponentGroup group) { var clientProjectileArray = group.GetComponentArray <ClientProjectile>(); var weaponArray = WeaponGroup.GetComponentArray <RobotWeaponA>(); var charPresentationArray = WeaponGroup.GetComponentArray <CharPresentation>(); for (var i = 0; i < clientProjectileArray.Length; i++) { var clientProjectile = clientProjectileArray[i]; var projectileData = EntityManager.GetComponentData <ProjectileData>(clientProjectile.projectile); var projectileOwner = projectileData.projectileOwner; for (var j = 0; j < charPresentationArray.Length; j++) { var charPresentation = charPresentationArray[j]; if (!charPresentation.IsVisible) { continue; } if (charPresentation.character == projectileOwner) { var weapon = weaponArray[j]; var index = weapon.barrelSetup.index; var pos = weapon.barrelSetup.barrels[index].position; // GameDebug.Log("MATCH weapon:" + weapon.name + "proj count;" + clientProjectileArray.Length + " Index:" + index + "muzzlepos:" + pos + " tick:" + m_world.worldTime.tick); clientProjectile.SetMuzzlePosition(EntityManager, pos); break; } } } }
public void Restart() { GameDebug.Log("Restarting gamdemode"); var bases = m_TeamBaseComponentGroup.GetComponentArray <TeamBase>(); teamBases.Clear(); for (var i = 0; i < bases.Length; i++) { teamBases.Add(bases[i]); } for (int i = 0, c = teams.Count; i < c; ++i) { teams[i].score = -1; } var players = playersComponentGroup.GetComponentArray <PlayerState>(); for (int i = 0, c = players.Length; i < c; ++i) { var player = players[i]; player.score = 0; player.displayGameScore = true; player.goalCompletion = -1.0f; player.actionString = ""; } m_EnableRespawning = true; m_GameMode.Restart(); chatSystem.ResetChatTime(); }
protected override void Initialize(ref ComponentGroup group) { var clientProjectileArray = group.GetComponentArray <ClientProjectile>(); var weaponArray = WeaponGroup.GetComponentArray <TerraformerWeaponA>(); var charPresentationArray = WeaponGroup.GetComponentArray <CharPresentation>(); for (var i = 0; i < clientProjectileArray.Length; i++) { var clientProjectile = clientProjectileArray[i]; var projectileData = EntityManager.GetComponentData <ProjectileData>(clientProjectile.projectile); var projectileOwner = projectileData.projectileOwner; for (var j = 0; j < charPresentationArray.Length; j++) { var charPresentation = charPresentationArray[j]; if (!charPresentation.IsVisible) { continue; } if (charPresentation.character == projectileOwner) { var weapon = weaponArray[j]; var pos = weapon.muzzle.position; //GameDebug.Log("proj count;" + clientProjectileArray.Length + "muzzlepos:" + pos); clientProjectile.SetMuzzlePosition(EntityManager, pos); break; } } } }
protected override void OnUpdate() { var puc = PostUpdateCommands; var gameUi = SurvivalShooterBootstrap.Settings.GameUi; var scorePerDeath = SurvivalShooterBootstrap.Settings.ScorePerDeath; var entity = enemyGroup.GetEntityArray(); var collider = enemyGroup.GetComponentArray <CapsuleCollider>(); var animator = enemyGroup.GetComponentArray <Animator>(); var audioSource = enemyGroup.GetComponentArray <AudioSource>(); for (var i = 0; i < entity.Length; i++) { collider[i].isTrigger = true; animator[i].SetTrigger(DeadHash); audioSource[i].clip = SurvivalShooterBootstrap.Settings.EnemyDeathClip; audioSource[i].Play(); puc.RemoveComponent <DeadData>(entity[i]); score += scorePerDeath; gameUi.OnEnemyKilled(score); } }
protected override void OnUpdate() { var deltaTime = m_world.frameDuration; // 3P character { var entityArray = CharGroup.GetEntityArray(); var animStateCtrlArray = CharGroup.GetComponentArray <AnimStateController>(); var charAnimStateArray = CharGroup.GetComponentDataArray <CharAnimState>(); for (var i = 0; i < entityArray.Length; i++) { var entity = entityArray[i]; var animStateCtrl = animStateCtrlArray[i]; var animState = charAnimStateArray[i]; animStateCtrl.ApplyPresentationState(m_world.worldTime, deltaTime); // Update transformation animStateCtrl.transform.position = animState.position; animStateCtrl.transform.rotation = Quaternion.Euler(0f, animState.rotation, 0f); } } // 1P character { var entityArray = Char1PGroup.GetEntityArray(); var animStateCtrlArray = Char1PGroup.GetComponentArray <AnimStateController>(); var char1PArray = Char1PGroup.GetComponentArray <Character1P>(); for (var i = 0; i < entityArray.Length; i++) { var character1P = char1PArray[i]; if (!EntityManager.Exists(character1P.character)) { continue; } var entity = entityArray[i]; var animStateCtrl = animStateCtrlArray[i]; var animState = EntityManager.GetComponentData <CharAnimState>(character1P.character); var character = EntityManager.GetComponentObject <Character>(character1P.character); var charPredictedState = EntityManager.GetComponentObject <CharacterPredictedState>(character1P.character); var userCmd = EntityManager.GetComponentObject <UserCommandComponent>(character1P.character); EntityManager.SetComponentData(entity, animState); animStateCtrl.ApplyPresentationState(m_world.worldTime, deltaTime); // 1P character position is not update here as it is dependent on animation result (camera location) var eyePos = charPredictedState.State.position + Vector3.up * character.eyeHeight; character1P.transform.position = eyePos; character1P.transform.rotation = userCmd.command.lookRotation; } } }
protected override void OnUpdate() { var locoStates = group.GetComponentDataArray <LocomotionState>(); var targets = group.GetComponentDataArray <TargetPosition>(); var querys = group.GetComponentArray <MoveQuery>(); var transforms = group.GetComponentArray <Transform>(); for (int i = 0; i < locoStates.Length; i++) { var locoState = locoStates[i]; if (locoState.LocoState == LocomotionState.State.Dead) { continue; } var query = querys[i]; // Check for ground change (hitting ground or leaving ground) var isOnGround = locoState.IsOnGround(); // Debug.Log("isOnGround : "+isOnGround.ToString()+" query:"+query.isGrounded); if (isOnGround != query.isGrounded) { if (query.isGrounded) { Vector3 startPos = transforms[i].localPosition; Vector3 targetPos = targets[i].Value; var groundDir = targetPos - startPos; bool isMoveWanted = Vector3.Magnitude(groundDir) > 0.01f; if (isMoveWanted) { locoState.LocoState = LocomotionState.State.Run; } else { locoState.LocoState = LocomotionState.State.Idle; } } else { locoState.LocoState = LocomotionState.State.InAir; } locoState.StartTime = Time.time; locoStates[i] = locoState; } // Manually calculate resulting velocity as characterController.velocity is linked to Time.deltaTime // var newPos = query.moveQueryResult; // var oldPos = query.moveQueryStart; // var velocity = (newPos - oldPos) / Time.deltaTime; // locoState.velocity = velocity; // locoState.position = query.moveQueryResult; // EntityManager.SetComponentData(charAbility.character, locoState); } }
protected override void OnDestroyManager() { var charControlArray = Group.GetComponentArray <LocalPlayerCharacterControl>(); for (int i = 0; i < charControlArray.Length; i++) { if (charControlArray[i].hud == null) { continue; } m_world.RequestDespawn(charControlArray[i].hud.gameObject, PostUpdateCommands); } }
protected override void OnUpdate() { var entityArray = Group.GetEntityArray(); var charPredictedStateArray = Group.GetComponentArray <CharacterPredictedState>(); var charAnimStateArray = Group.GetComponentDataArray <CharAnimState>(); var userCommandArray = Group.GetComponentArray <UserCommandComponent>(); var animStateCtrlArray = Group.GetComponentArray <AnimStateController>(); var deltaTime = m_world.frameDuration; for (var i = 0; i < charPredictedStateArray.Length; i++) { var entity = entityArray[i]; var charPredictedState = charPredictedStateArray[i]; var animState = charAnimStateArray[i]; var userCommand = userCommandArray[i].command; var animStateCtrl = animStateCtrlArray[i]; animState.position = charPredictedState.State.position; animState.previousCharLocoState = animState.charLocoState; animState.charLocoState = charPredictedState.State.locoState; animState.charLocoTick = charPredictedState.State.locoStartTick; animState.sprinting = charPredictedState.State.sprinting ? 1 : 0; animState.charAction = charPredictedState.State.action; animState.charActionTick = charPredictedState.State.actionStartTick; animState.aimYaw = userCommand.lookYaw; animState.aimPitch = userCommand.lookPitch; var groundMoveVec = Vector3.ProjectOnPlane(charPredictedState.State.velocity, Vector3.up); animState.moveYaw = Vector3.Angle(Vector3.forward, groundMoveVec); var cross = Vector3.Cross(Vector3.forward, groundMoveVec); if (cross.y < 0) { animState.moveYaw = 360 - animState.moveYaw; } animState.damageTick = charPredictedState.State.damageTick; var damageDirOnPlane = Vector3.ProjectOnPlane(charPredictedState.State.damageDirection, Vector3.up); animState.damageDirection = Vector3.SignedAngle(Vector3.forward, damageDirOnPlane, Vector3.up); // Set anim state before anim state ctrl is running EntityManager.SetComponentData(entity, animState); // Update presentationstate animstatecontroller animStateCtrl.UpdatePresentationState(m_world.worldTime, deltaTime); } }
protected override void Initialize(ref ComponentGroup group) { var clientProjectileArray = group.GetComponentArray <ClientProjectile>(); var weaponArray = WeaponGroup.GetComponentArray <RobotWeaponA>(); var charPresentationArray = WeaponGroup.GetComponentArray <CharacterPresentationSetup>(); for (var i = 0; i < clientProjectileArray.Length; i++) { var clientProjectile = clientProjectileArray[i]; var projectileData = EntityManager.GetComponentData <ProjectileData>(clientProjectile.projectile); var projectileOwner = projectileData.projectileOwner; for (var j = 0; j < charPresentationArray.Length; j++) { var charPresentation = charPresentationArray[j]; if (!charPresentation.IsVisible) { continue; } if (charPresentation.character == projectileOwner) { var weapon = weaponArray[j]; var index = weapon.barrelSetup.index; var pos = weapon.barrelSetup.barrels[index].position; // GameDebug.Log("MATCH weapon:" + weapon.name + "proj count;" + clientProjectileArray.Length + " Index:" + index + "muzzlepos:" + pos + " tick:" + m_world.worldTime.tick); clientProjectile.SetMuzzlePosition(EntityManager, pos); //Added by Logan 10-12-2021 //Probably gonna copy or delete this...this is the initialize function for the projectile! //weapon.barrelSetup.fireSoundInstance00 = FMODUnity.RuntimeManager.CreateInstance(weapon.barrelSetup.fireSoundEvent); //FMODUnity.RuntimeManager.AttachInstanceToGameObject(weapon.barrelSetup.fireSoundInstance00, weapon.barrelSetup.muzzleFlash[index].transform); //GameDebug.Log("Initialized -Logan"); //if (weapon.barrelSetup.fireSoundInstance00.isValid()) //{ // GameDebug.Log("Instance is valid"); // //Keep testing here, see what else you can set up //} break; } } } }
protected override void OnUpdate() { var damageAreaArray = Group.GetComponentArray <DamageArea>(); for (int idx = 0; idx < damageAreaArray.Length; ++idx) { var area = damageAreaArray[idx]; var damageAmount = area.damagePerHit; var ticksBetweenDamage = Mathf.FloorToInt(1.0f / (area.hitsPerSecond * m_GameWorld.worldTime.tickInterval)); if (area.instantKill) { damageAmount = 100000.0f; } var charactersInside = area.charactersInside; // Iterating backwards as we need to clear out any destroyed characters for (var i = charactersInside.Count - 1; i >= 0; --i) { if (charactersInside[i].hitCollisionOwner == null) { charactersInside.EraseSwap(i); continue; } if (m_GameWorld.worldTime.tick > charactersInside[i].nextDamageTick) { charactersInside[i].hitCollisionOwner.damageEvents.Add(new DamageEvent(Entity.Null, damageAmount, Vector3.zero, 0)); var info = charactersInside[i]; info.nextDamageTick = m_GameWorld.worldTime.tick + ticksBetweenDamage; charactersInside[i] = info; } } } }
protected override void OnUpdate() { var p_entity = player.GetEntityArray(); var p_movementInput = player.GetComponentDataArray <MovementInput> (); var p_walkSpeed = player.GetComponentDataArray <WalkSpeed> (); var p_rigidBody2d = player.GetComponentArray <Rigidbody2D> (); var dt = Time.deltaTime; for (int i = 0; i < player.CalculateLength(); i++) { if (p_movementInput[i].Value.Equals(Vector2.zero)) { continue; } p_rigidBody2d[i].velocity = new Vector2( p_movementInput[i].Value.x * p_walkSpeed[i].Value, p_rigidBody2d[i].velocity.y ); // Debug.Log(p_rigidBody2d[i].velocity); // Old Movement System: // p_transform[i].position = Vector3.Lerp( // p_transform[i].position, // p_transform[i].position + new Vector3(p_movementInput[i].Value.x, p_movementInput[i].Value.y, 0), // p_walkSpeed[i].Value * dt // ); } }
protected override void Deinitialize(ref ComponentGroup group) { var hitCollHistoryArray = group.GetComponentArray <HitCollisionHistory>().ToArray(); for (var i = 0; i < hitCollHistoryArray.Length; i++) { var hitCollHistory = hitCollHistoryArray[i]; if (hitCollHistory.colliderParents.isCreated) { hitCollHistory.colliderParents.Dispose(); } if (hitCollHistory.colliders == null) { return; } for (var j = 0; j < hitCollHistory.colliders.Length; j++) { var go = hitCollHistory.colliders[j].collider.gameObject; GameObject.Destroy(go); } GameObject.Destroy(hitCollHistory.collidersRoot); hitCollHistory.colliders = null; } }
protected override void Deinitialize(ref ComponentGroup group) { // Get all components of type, not just spawned/de-spawned ones var array = Group.GetComponentArray <Twist>(); TwistSystem.SetupTwistComponents(ref array); }
protected override void OnUpdate() { // Profiler.BeginSample("HandleMovementQueries"); var queryArray = Group.GetComponentArray <MoveQuery>(); // Debug.Log("queryArray.Length : "+queryArray.Length); for (var i = 0; i < queryArray.Length; i++) { var query = queryArray[i]; var charController = query.charController; // if (charController.gameObject.layer != query.collisionLayer) // charController.gameObject.layer = query.collisionLayer; float3 currentControllerPos = charController.transform.position; if (math.distance(currentControllerPos, query.moveQueryStart) > 0.01f) { currentControllerPos = query.moveQueryStart; charController.transform.position = currentControllerPos; } var deltaPos = query.moveQueryEnd - currentControllerPos; // Debug.Log("deltaPos : "+deltaPos.x+" "+deltaPos.y+" "+deltaPos.z); charController.Move(deltaPos); query.moveQueryResult = charController.transform.position; query.isGrounded = charController.isGrounded; // Debug.Log("res pos : "+query.moveQueryResult.x+" "+query.moveQueryResult.y+" "+query.moveQueryResult.z); query.transform.localPosition = query.moveQueryResult; } // Profiler.EndSample(); }
public bool GetRandomSpawnTransform(int teamIndex, ref Vector3 pos, ref Quaternion rot) { // Make list of spawnpoints for team var teamSpawns = new List <SpawnPoint>(); var spawnPoints = m_SpawnPointComponentGroup.GetComponentArray <SpawnPoint>(); for (var i = 0; i < spawnPoints.Length; i++) { var spawnPoint = spawnPoints[i]; if (spawnPoint.teamIndex == teamIndex) { teamSpawns.Add(spawnPoint); } } if (teamSpawns.Count == 0) { return(false); } var index = (m_prevTeamSpawnPointIndex[teamIndex] + 1) % teamSpawns.Count; m_prevTeamSpawnPointIndex[teamIndex] = index; pos = teamSpawns[index].transform.position; rot = teamSpawns[index].transform.rotation; GameDebug.Log("spawning at " + teamSpawns[index].name); return(true); }
private void UpdateAuthChangeGroup() { var rigidbodyArray = authChangeGroup.GetComponentArray <Rigidbody>(); var kinematicStateWhenAuthArray = authChangeGroup.GetComponentDataArray <KinematicStateWhenAuth>(); var spatialEntityIdArray = authChangeGroup.GetComponentDataArray <SpatialEntityId>(); for (int i = 0; i < rigidbodyArray.Length; ++i) { var rigidbody = rigidbodyArray[i]; var changes = updateSystem.GetAuthorityChangesReceived(spatialEntityIdArray[i].EntityId, TransformInternal.ComponentId); if (changes.Count == 0) { continue; } var auth = changes[changes.Count - 1]; switch (auth.Authority) { case Authority.NotAuthoritative: kinematicStateWhenAuthArray[i] = new KinematicStateWhenAuth { KinematicWhenAuthoritative = rigidbody.isKinematic }; rigidbody.isKinematic = true; break; case Authority.Authoritative: case Authority.AuthorityLossImminent: rigidbody.isKinematic = kinematicStateWhenAuthArray[i].KinematicWhenAuthoritative; break; } } }
protected override void OnUpdate() { var geneticTrainerID = new List <GeneticTrainerIDComponentData>(10); EntityManager.GetAllUniqueSharedComponentData(geneticTrainerID); var transforms = geneticTrainerGroup.GetComponentArray <Transform>(); for (int i = 0, length = transforms.Length; i < length; ++i) { var geneticTrainer = transforms[i].GetComponent <GeneticTrainerComponent>(); deadNetworkGroup.SetFilter(geneticTrainerID[i]); //may need to change if more than one if (deadNetworkGroup.GetEntityArray().Length != 0) { if (deadNetworkGroup.GetEntityArray().Length == geneticTrainer.pool.Length) { for (int j = 0, entityCount = deadNetworkGroup.GetEntityArray().Length; deadNetworkGroup.GetEntityArray().Length != 0;) { var entity = deadNetworkGroup.GetEntityArray()[j]; geneticTrainer.scores[deadNetworkGroup.GetComponentDataArray <PointComponentData>()[j].PointValue] = entity; EntityManager.AddComponentData(entity, new ResetComponentData()); EntityManager.RemoveComponent(entity, ComponentType.Create <DeadComponentData>()); } } } } }
protected override void Deinitialize(ref ComponentGroup group) { // Get all components of type, not just spawned/de-spawned ones var componentArray = Group.GetComponentArray <Fan>(); FanSystem.SetupFanComponents(ref componentArray); }
protected override void Initialize(ref ComponentGroup group) { // Get all components of type, not just spawned/de-spawned ones var array = Group.GetComponentArray <TranslateScale>(); TranslateScaleSystem.SetupTranslateScaleComponents(ref array); }
private void UpdateTransformData() { rigidbodyGroup.SetFilter(TransformInternal.ComponentAuthority.Authoritative); var ticksSinceLastUpdateArray = rigidbodyGroup.GetComponentDataArray <TicksSinceLastTransformUpdate>(); var transformComponentArray = rigidbodyGroup.GetComponentDataArray <TransformInternal.Component>(); var bufferedTransformArray = rigidbodyGroup.GetBufferArray <BufferedTransform>(); var rigidbodyArray = rigidbodyGroup.GetComponentArray <Rigidbody>(); var spatialEntityIdArray = rigidbodyGroup.GetComponentDataArray <SpatialEntityId>(); for (int i = 0; i < transformComponentArray.Length; ++i) { // todo this is not a correct constraint. Needs a the auth loss temporary exposed to correctly do this // alternatively this needs an authority changed component that is filled at the beginning of the tick if (updateSystem .GetAuthorityChangesReceived(spatialEntityIdArray[i].EntityId, TransformInternal.ComponentId) .Count == 0) { continue; } var t = transformComponentArray[i]; var rigidbody = rigidbodyArray[i]; rigidbody.MovePosition(t.Location.ToUnityVector3() + worker.Origin); rigidbody.MoveRotation(t.Rotation.ToUnityQuaternion()); rigidbody.AddForce(t.Velocity.ToUnityVector3() - rigidbody.velocity, ForceMode.VelocityChange); bufferedTransformArray[i].Clear(); ticksSinceLastUpdateArray[i] = new TicksSinceLastTransformUpdate(); } }
private void UpdateRigidbodyData() { transformGroup.SetFilter(TransformInternal.ComponentAuthority.Authoritative); var ticksSinceLastUpdateArray = transformGroup.GetComponentDataArray <TicksSinceLastTransformUpdate>(); var transformComponentArray = transformGroup.GetComponentDataArray <TransformInternal.Component>(); var bufferedTransformArray = transformGroup.GetBufferArray <BufferedTransform>(); var unityTransformArray = transformGroup.GetComponentArray <UnityEngine.Transform>(); var spatialEntityIdArray = transformGroup.GetComponentDataArray <SpatialEntityId>(); for (int i = 0; i < transformComponentArray.Length; ++i) { if (updateSystem .GetAuthorityChangesReceived(spatialEntityIdArray[i].EntityId, TransformInternal.ComponentId) .Count == 0) { continue; } var t = transformComponentArray[i]; var unityTransform = unityTransformArray[i]; unityTransform.position = t.Location.ToUnityVector3() + worker.Origin; unityTransform.rotation = t.Rotation.ToUnityQuaternion(); bufferedTransformArray[i].Clear(); ticksSinceLastUpdateArray[i] = new TicksSinceLastTransformUpdate(); } }
protected override void OnUpdate() { var mainCamera = Camera.main; if (mainCamera == null) { return; } var mousePos = Input.mousePosition; var camRayLen = SurvivalShooterBootstrap.Settings.CamRayLen; var floor = LayerMask.GetMask("Floor"); var go = playerGroup.GetGameObjectArray(); var rigidbody = playerGroup.GetComponentArray <Rigidbody>(); for (var i = 0; i < go.Length; i++) { var camRay = mainCamera.ScreenPointToRay(mousePos); RaycastHit floorHit; if (Physics.Raycast(camRay, out floorHit, camRayLen, floor)) { var position = go[i].transform.position; var playerToMouse = floorHit.point - new Vector3(position.x, position.y, position.z); playerToMouse.y = 0f; var newRot = Quaternion.LookRotation(playerToMouse); rigidbody[i].MoveRotation(newRot); } } }
protected override void OnUpdate() { // var states = group.GetComponentArray<RoleState>(); // var grounds = group.GetComponentDataArray<GroundInfo>(); var looksInfos = group.GetComponentDataArray <LooksInfo>(); var locoStates = group.GetComponentDataArray <LocomotionState>(); var directors = group.GetComponentArray <PlayableDirector>(); for (int i = 0; i < looksInfos.Length; i++) { var looksInfo = looksInfos[i]; var director = directors[i]; // Debug.Log("director.state : "+director.state.ToString()); if (looksInfo.CurState != LooksInfo.State.Loaded || director.state == PlayState.Playing) { continue; } var looksEntity = looksInfo.LooksEntity; var animator = m_world.GetEntityManager().GetComponentObject <Animator>(looksEntity); // Debug.Log("animator : "+(animator!=null).ToString()); if (animator != null) { UpdateAnimator(animator, locoStates[i].Value); } } }
protected override void OnUpdate() { float dt = Time.deltaTime; var userCommandArray = group.GetComponentDataArray <UserCommand>(); var targetPosArray = group.GetComponentDataArray <TargetPosition>(); var posArray = group.GetComponentArray <Transform>(); var moveSpeedArray = group.GetComponentDataArray <MoveSpeed>(); if (userCommandArray.Length == 0) { return; } var userCommand = userCommandArray[0]; // Vector2 input = new Vector2(); var input = GameInput.GetInstance().JoystickDir; // input.x = Input.GetAxis("Horizontal"); // input.y = Input.GetAxis("Vertical"); bool isJump = Input.GetKeyDown(KeyCode.Space); var forward = SceneMgr.Instance.MainCameraTrans.TransformDirection(Vector3.forward); forward.y = 0; var right = SceneMgr.Instance.MainCameraTrans.TransformDirection(Vector3.right); float3 targetDirection = input.x * right + input.y * forward; targetDirection.y = -10;//模仿重力,人物需要贴着地面走,有碰撞检测的所以不怕 // Debug.Log("targetDirection : "+targetDirection.x + " "+targetDirection.y+" "+targetDirection.z); float3 curPos = posArray[0].localPosition; var speed = moveSpeedArray[0].Value; var newTargetPos = new TargetPosition(); newTargetPos.Value = curPos + targetDirection * (speed / GameConst.SpeedFactor * 1);//延着方向前进1秒为目标坐标 //TODO:通过navmesh判断是否障碍区,是的话取得最近点 targetPosArray[0] = newTargetPos; // Debug.Log("curPos : "+curPos.x+" "+curPos.y+" "+curPos.z+" dir:"+targetDirection.x+" "+targetDirection.z); }
protected override void OnUpdate() { Profiler.BeginSample("HandleMovementQueries"); var queryArray = Group.GetComponentArray <CharacterMoveQuery>(); for (var i = 0; i < queryArray.Length; i++) { var query = queryArray[i]; var charController = query.charController; if (charController.gameObject.layer != query.collisionLayer) { charController.gameObject.layer = query.collisionLayer; } float3 currentControllerPos = charController.transform.position; if (math.distance(currentControllerPos, query.moveQueryStart) > 0.01f) { currentControllerPos = query.moveQueryStart; charController.transform.position = currentControllerPos; } var deltaPos = query.moveQueryEnd - currentControllerPos; charController.Move(deltaPos); query.moveQueryResult = charController.transform.position; query.isGrounded = charController.isGrounded; } Profiler.EndSample(); }
public void Restart() { GameDebug.Log("Restarting gamemode..."); var captures = m_CapturePointGroup.GetComponentArray <CapturePoint>(); for (var i = 0; i < captures.Length; i++) { var c = captures[i]; GameDebug.Log("Capture " + c.objectiveName + " reset"); c.status = CapturePoint.Status.Locked; c.captured = 0; } m_Phase = Phase.PreGame; m_GameModeSystemServer.StartGameTimer(preMatchTime, "PreMatch"); m_ActiveCapturePoint = null; SelectNextCapturePoint(); }
protected override void OnUpdate(){ var t_entity = trail.GetEntityArray(); var t_trail = trail.GetComponentArray<TrailRenderer>(); for(int i = 0; i < trail.CalculateLength(); i++){ t_trail[i].enabled = false; } }
protected override void Deinitialize(ref ComponentGroup group) { var hitCollHistoryArray = group.GetComponentArray <HitCollisionHistory>().ToArray(); for (var i = 0; i < hitCollHistoryArray.Length; i++) { hitCollHistoryArray[i].Shutdown(); } }