using System.Collections; using System.Collections.Generic; using UnityEngine; using BITKit; using BITKit.Entities; using KinematicCharacterController; using Net.Share; using Net.Client; using Net.Unity; namespace BITFALL.Entites { public class EntityProxyMovement : EntityComponent, ICharacterController, IHealthCallback, IEntityMovement { public KinematicCharacterMotor motor; public List ignoreColliders; public Vector3 currentVelocity; public Vector3 currentPos; public Quaternion currentRot; public bool isGrounded; ClientBase client; public override void Initialize(IEntity entity) { base.Initialize(entity); entity.Set(this); } public void AfterCharacterUpdate(float deltaTime) { } public void BeforeCharacterUpdate(float deltaTime) { } public bool IsColliderValidForCollisions(Collider coll) { return ignoreColliders.Contains(coll) is false; } public void OnDiscreteCollisionDetected(Collider hitCollider) { } public void OnGroundHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport) { } public void OnMovementHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport) { } public void PostGroundingUpdate(float deltaTime) { } public void ProcessHitStabilityReport(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, Vector3 atCharacterPosition, Quaternion atCharacterRotation, ref HitStabilityReport hitStabilityReport) { } public void UpdateRotation(ref Quaternion currentRotation, float deltaTime) { currentRotation = currentRot; } public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime) { currentVelocity = this.currentVelocity; if (motor.GroundingStatus.FoundAnyGround) { currentVelocity.y = 0; } else { //currentVelocity -= Vector3.up * deltaTime; } } public override void OnStart() { base.OnStart(); motor.CharacterController = this; KinematicCharacterSystem.CharacterMotors.Add(motor); entity.RegisterCallback(this); } public override void OnDestroyComponent() { KinematicCharacterSystem.CharacterMotors.Remove(motor); } public void SyncMovement(Vector3 currentVelocity, Vector3 currentPos, Quaternion rotation, bool isGrounded) { this.currentVelocity = currentVelocity; this.currentPos = currentPos; this.currentRot = rotation; this.isGrounded = isGrounded; if (Vector3.Distance(currentPos,motor.TransientPosition)>0.32f) { motor.SetPosition(currentPos); } if(isGrounded is false && motor.GroundingStatus.FoundAnyGround) { motor.ForceUnground(); } else if (isGrounded is false && motor.GroundingStatus.FoundAnyGround is false) { } } [BIT] public void ResetPosition() { motor.SetPosition(Vector3.zero); } public void OnSetAlive(bool alive) { motor.SetCapsuleCollisionsActivation(alive); motor.SetGroundSolvingActivation(alive); motor.SetMovementCollisionsSolvingActivation(alive); } public void OnSetHP(int hp) { } } }