private void ResetPlayerState(ref ClientEntity cEntity) { cEntity.errorTime = -99999; //保证没有添加任何的错误衰减 cEntity.extrapolated = false; var lf = cEntity.playerEntity.legs; lf.frameTime = lf.oldFrameTime = time; // lf.oldFrame = lf.frame = lf.animation.firstFrame; // CG_SetLerpFrameAnimation(ci, lf, animationNumber); lf = cEntity.playerEntity.torso; lf.frameTime = lf.oldFrameTime = time; // lf.oldFrame = lf.frame = lf.animation.firstFrame; CUtils.BG_EvaluateTrajectory(cEntity.currentState.pos, time, out cEntity.lerpOrigin); CUtils.BG_EvaluateTrajectory(cEntity.currentState.apos, time, out cEntity.lerpAngles); cEntity.rawOrigin = cEntity.lerpOrigin; cEntity.rawAngles = cEntity.lerpAngles; cEntity.playerEntity.legs.Reset(); cEntity.playerEntity.legs.yawAngle = cEntity.rawAngles[CConstVar.YAW]; cEntity.playerEntity.torso.Reset(); cEntity.playerEntity.torso.yawAngle = cEntity.rawAngles[CConstVar.YAW]; cEntity.playerEntity.torso.pitchAngle = cEntity.rawAngles[CConstVar.PITCH]; cEntity.playerEntity.head.Reset(); cEntity.playerEntity.head.yawAngle = cEntity.rawAngles[CConstVar.YAW]; cEntity.playerEntity.head.pitchAngle = cEntity.rawAngles[CConstVar.PITCH]; }
public void AdjustPositionForMover(Vector3 inPos, int moverNum, int fromTime, int toTime, out Vector3 outPos, Vector3 anglesIn, out Vector3 anglesOut) { ClientEntity clientEntity; Vector3 oldOrigin, origin, deltaOrigin; Vector3 oldAngles, angles, deltaAngles; if (moverNum <= 0 || moverNum >= CConstVar.ENTITYNUM_MAX_NORMAL) { outPos = inPos; anglesOut = anglesIn; return; } clientEntity = CDataModel.GameState.clientEntities[moverNum]; if (clientEntity.currentState.entityType != EntityType.MOVER) { outPos = inPos; anglesOut = anglesIn; return; } CUtils.BG_EvaluateTrajectory(clientEntity.currentState.pos, fromTime, out oldOrigin); CUtils.BG_EvaluateTrajectory(clientEntity.currentState.apos, fromTime, out oldAngles); CUtils.BG_EvaluateTrajectory(clientEntity.currentState.pos, toTime, out origin); CUtils.BG_EvaluateTrajectory(clientEntity.currentState.pos, toTime, out angles); deltaOrigin = origin - oldOrigin; deltaAngles = angles - oldAngles; outPos = inPos + deltaOrigin; anglesOut = anglesIn + deltaAngles; }
private void CheckEvents(ref ClientEntity cEntity) { //检查entity only的事件 if (cEntity.currentState.entityType > (int)EntityType.EVENTS_COUNT) { if (cEntity.previousEvent > 0) { return; } if ((cEntity.currentState.entityFlags & EntityFlags.PLAYER_EVENT) > EntityFlags.NONE) { cEntity.currentState.entityIndex = cEntity.currentState.otherEntityIdx; } cEntity.previousEvent = 1; cEntity.currentState.eventID = (cEntity.currentState.entityType - EntityType.EVENTS_COUNT); } else { if (cEntity.currentState.eventID == cEntity.previousEvent) { return; } if (cEntity.currentState.eventID == cEntity.previousEvent) { return; } cEntity.previousEvent = cEntity.currentState.eventID; if (((int)cEntity.currentState.eventID & ~CConstVar.EVENT_BITS) == 0) { return; } } CUtils.BG_EvaluateTrajectory(cEntity.currentState.pos, snap.serverTime, out cEntity.lerpOrigin); EntityEvent(cEntity, cEntity.lerpOrigin); }