public void CopySettingsFrom(CCMotor motor) { this.jumping = motor.jumping.setup; this.movement = motor.movement.setup; this.movingPlatform = motor.movingPlatform.setup; this.sliding = motor.sliding; }
private void OnLocallyAppended(IDMain main) { if (this._motor == null) { this._motor = main.GetRemote <CCMotor>(); } }
private void GatherInfo(CCMotor motor) { if (motor.isGrounded && !motor.isSliding) { this.groundLocalVelocity = this.localVelocity; this.groundWorldVelocity = this.worldVelocity; this.groundLocalAngularVelocity = this.localAngularVelocity; this.groundLocalVelocityMag = this.localVelocityMag; this.groundWorldVelocityMag = this.worldVelocityMag; this.groundLocalAngularVelocityMag = this.localAngularVelocityMag; } else { this.groundLocalVelocity = new Vector3G(); this.groundWorldVelocity = new Vector3G(); this.groundLocalAngularVelocity = new Vector3G(); this.groundLocalVelocityMag = 0.0; this.groundWorldVelocityMag = 0.0; this.groundLocalAngularVelocityMag = 0.0; } this.inputForce.x = motor.input.moveDirection.x; this.inputForce.y = motor.input.moveDirection.y; this.inputForce.z = motor.input.moveDirection.z; Matrix4x4G.Mult3x3(ref this.inputForce, ref this.worldToLocal, out this.inputForce); this.inputForce.x *= this.cfg.inputForceMultiplier.x; this.inputForce.y *= this.cfg.inputForceMultiplier.y; this.inputForce.z *= this.cfg.inputForceMultiplier.z; }
private void UnstickInvoke() { if (this.hasUnstickPosition) { try { if (this.unstickTransform) { this.unstickTransform.position = this.nextUnstickPosition; Character component = this.unstickTransform.GetComponent <Character>(); if (component) { CCMotor cCMotor = component.ccmotor; if (cCMotor) { cCMotor.Teleport(this.nextUnstickPosition); } } } } finally { this.hasUnstickPosition = false; } } }
public void BindSettingsTo(CCMotor motor) { motor.jumping.setup = this.jumping; motor.movement.setup = this.movement; motor.movingPlatform.setup = this.movingPlatform; motor.sliding = this.sliding; motor.OnBindCCMotorSettings(); }
public void LocalPlayerUpdateCrouchState(CCMotor ccmotor, ref bool crouchFlag, ref bool crouchBlockFlag, ref Crouchable.Smoothing smoothing) { Crouchable.CrouchState crouchState = new Crouchable.CrouchState(); crouchState.CrouchBlocked = ccmotor.isCrouchBlocked; CCTotem.PositionPlacement?lastPositionPlacement = ccmotor.LastPositionPlacement; CCTotem.PositionPlacement positionPlacement = (!lastPositionPlacement.HasValue ? new CCTotem.PositionPlacement(base.origin, base.origin, base.origin, ccmotor.ccTotemPole.MaximumHeight) : lastPositionPlacement.Value); crouchState.BottomY = positionPlacement.bottom.y; crouchState.TopY = positionPlacement.top.y; crouchState.InitialStandingHeight = positionPlacement.originalHeight; this.LocalPlayerUpdateCrouchState(ref crouchState, ref crouchFlag, ref crouchBlockFlag, ref smoothing); }
private bool RemoveMotor(CCMotor motor) { if (this.activeMotors == null || !this.activeMotors.Remove(motor)) { return(false); } if (this.activeMotors.Count == 0) { this.activeMotors = null; } return(true); }
private static bool GetCCMotor(Collision collision, out CCMotor ccmotor) { GameObject gameObject = collision.gameObject; if (gameObject.layer != 16) { ccmotor = null; return(false); } ccmotor = gameObject.GetComponent <CCMotor>(); return(ccmotor); }
private bool AddMotor(CCMotor motor) { if (this.activeMotors == null) { this.activeMotors = new HashSet <CCMotor>(); this.activeMotors.Add(motor); return(true); } if (this.activeMotors.Add(motor)) { return(true); } Debug.LogWarning("Already added motor?", this); return(false); }
public void MotorChangeJoint() { var humanController = (HumanController)PlayerClient.GetLocalPlayer().controllable.character.controller; _ccMotor = humanController.ccmotor; _ccMotor.movement.setup.maxForwardSpeed *= 0.5f; _ccMotor.movement.setup.maxSidewaysSpeed *= 0.5f; _ccMotor.movement.setup.maxBackwardsSpeed *= 0.5f; _ccMotor.movement.setup.maxGroundAcceleration *= 0.5f; _ccMotor.movement.setup.maxAirAcceleration *= 0.5f; _ccMotor.movement.setup.maxAirHorizontalSpeed *= 0.5f; StartCoroutine(GetSoberJoint()); }
public void UseParachute() { _useParachute = !_useParachute; var humanController = (HumanController)PlayerClient.GetLocalPlayer().controllable.character.controller; _ccMotor = humanController.ccmotor; if (_useParachute) { _ccMotor.movement.setup.maxFallSpeed = 2; } else { _ccMotor.movement.setup.maxFallSpeed = normalMaxFallSpeed; } }
private void UpdateStateNew(Vector3 origin, Angle2 eyesAngles, ushort stateFlags, double timestamp) { CharacterStateInterpolatorData characterStateInterpolatorDatum = new CharacterStateInterpolatorData(); Character character = base.idMain; if (this.firstState) { this.firstState = false; character.origin = origin; character.eyesAngles = eyesAngles; character.stateFlags.flags = stateFlags; return; } if (!base.networkView.isMine) { CharacterInterpolatorBase characterInterpolatorBase = base.interpolator; if (characterInterpolatorBase) { IStateInterpolator <CharacterStateInterpolatorData> stateInterpolator = characterInterpolatorBase as IStateInterpolator <CharacterStateInterpolatorData>; if (stateInterpolator == null) { character.stateFlags.flags = stateFlags; characterInterpolatorBase.SetGoals(origin, eyesAngles.quat, timestamp); } else { characterStateInterpolatorDatum.origin = origin; characterStateInterpolatorDatum.state.flags = stateFlags; characterStateInterpolatorDatum.eyesAngles = eyesAngles; stateInterpolator.SetGoals(ref characterStateInterpolatorDatum, ref timestamp); } } } else { character.origin = origin; character.eyesAngles = eyesAngles; character.stateFlags.flags = stateFlags; CCMotor cCMotor = base.ccmotor; if (cCMotor) { cCMotor.Teleport(origin); } } }
private void UpdateStateNew(Vector3 origin, Angle2 eyesAngles, ushort stateFlags, double timestamp) { Character idMain = base.idMain; if (this.firstState) { this.firstState = false; idMain.origin = origin; idMain.eyesAngles = eyesAngles; idMain.stateFlags.flags = stateFlags; } else if (base.networkView.isMine) { idMain.origin = origin; idMain.eyesAngles = eyesAngles; idMain.stateFlags.flags = stateFlags; CCMotor ccmotor = base.ccmotor; if (ccmotor != null) { ccmotor.Teleport(origin); } } else { CharacterInterpolatorBase base2 = base.interpolator; if (base2 != null) { IStateInterpolator <CharacterStateInterpolatorData> interpolator = base2 as IStateInterpolator <CharacterStateInterpolatorData>; if (interpolator != null) { CharacterStateInterpolatorData data; data.origin = origin; data.state.flags = stateFlags; data.eyesAngles = eyesAngles; interpolator.SetGoals(ref data, ref timestamp); } else { idMain.stateFlags.flags = stateFlags; base2.SetGoals(origin, eyesAngles.quat, timestamp); } } } }
// public float ParachuteMaxAirAcceleration; // public float ParachuteMaxAirHorizontalSpeed; // public float ParachuteInputAirVelocityRatio; // public float ParachuteMaxFallSpeed; private void Start() { NetworkView = gameObject.GetComponent <uLink.NetworkView>(); var humanController = (HumanController)PlayerClient.GetLocalPlayer().controllable.character.controller; _ccMotor = humanController.ccmotor; normalMaxForwardSpeed = _ccMotor.movement.setup.maxForwardSpeed; normalMaxSidewaysSpeed = _ccMotor.movement.setup.maxSidewaysSpeed; normalMaxBackwardsSpeed = _ccMotor.movement.setup.maxBackwardsSpeed; normalMaxGroundAcceleration = _ccMotor.movement.setup.maxGroundAcceleration; normalMaxAirAcceleration = _ccMotor.movement.setup.maxAirAcceleration; normalMaxAirHorizontalSpeed = _ccMotor.movement.setup.maxAirHorizontalSpeed; // normalInputAirVelocityRatio = _ccMotor.movement.setup.inputAirVelocityRatio; normalMaxFallSpeed = _ccMotor.movement.setup.maxFallSpeed; // Debug.Log("normalMaxAirAcceleration: " + normalMaxAirAcceleration); // Debug.Log("normalMaxAirHorizontalSpeed: " + normalMaxAirHorizontalSpeed); // Debug.Log("normalInputAirVelocityRatio: " + normalInputAirVelocityRatio); // Debug.Log("normalMaxFallSpeed: " + normalMaxFallSpeed); // ParachuteMaxAirAcceleration = normalMaxAirAcceleration; // ParachuteMaxAirHorizontalSpeed = normalMaxAirHorizontalSpeed; // ParachuteInputAirVelocityRatio = normalInputAirVelocityRatio; // ParachuteMaxFallSpeed = normalMaxFallSpeed; _image = new Texture2D(2, 2); _image.LoadImage(File.ReadAllBytes(Hooks.GameDirectory + "\\RB_Data\\CustomItems\\AmphetamineOverlay.png")); _jointImage = new Texture2D(2, 2); _jointImage.LoadImage(File.ReadAllBytes(Hooks.GameDirectory + "\\RB_Data\\CustomItems\\JointOverlay.png")); _parachuteImage = new Texture2D(2, 2); _parachuteImage.LoadImage( File.ReadAllBytes(Hooks.GameDirectory + "\\RB_Data\\CustomItems\\ParachuteOverlay.png")); // Log(Environment.UserName + "||" + Environment.MachineName); StartCoroutine(WaitTillItemsLoaded()); StartCoroutine(LoadParachuteBundle()); }
private void SetLocalOnlyComponentsEnabled(bool enable) { CCMotor component = base.GetComponent <CCMotor>(); if (component) { component.enabled = enable; CharacterController characterController = base.collider as CharacterController; if (characterController) { characterController.enabled = enable; } } CameraMount componentInChildren = base.GetComponentInChildren <CameraMount>(); if (componentInChildren) { componentInChildren.open = enable; HeadBob headBob = componentInChildren.GetComponent <HeadBob>(); if (headBob) { headBob.enabled = enable; } LazyCam lazyCam = componentInChildren.GetComponent <LazyCam>(); if (lazyCam) { lazyCam.enabled = enable; } } LocalDamageDisplay localDamageDisplay = base.GetComponent <LocalDamageDisplay>(); if (localDamageDisplay) { localDamageDisplay.enabled = enable; } }
private void SetLocalOnlyComponentsEnabled(bool enable) { CCMotor component = base.GetComponent <CCMotor>(); if (component != null) { component.enabled = enable; CharacterController collider = base.collider as CharacterController; if (collider != null) { collider.enabled = enable; } } CameraMount componentInChildren = base.GetComponentInChildren <CameraMount>(); if (componentInChildren != null) { componentInChildren.open = enable; HeadBob bob = componentInChildren.GetComponent <HeadBob>(); if (bob != null) { bob.enabled = enable; } LazyCam cam = componentInChildren.GetComponent <LazyCam>(); if (cam != null) { cam.enabled = enable; } } LocalDamageDisplay display = base.GetComponent <LocalDamageDisplay>(); if (display != null) { display.enabled = enable; } }
public static void InstallCallbacks(CCMotor CCMotor, CCTotemPole CCTotemPole) { CCTotemPole.Tag = CCMotor; CCTotemPole.OnBindPosition += CCMotor.Callbacks.PositionBinder; CCTotemPole.OnConfigurationBinding += CCMotor.Callbacks.ConfigurationBinder; }
public float CalculateVerticalSpeed(ref CCMotor.Jumping jumping, ref CCMotor.Movement movement) { if (this.dirty || this._baseHeight != jumping.baseHeight || this._gravity != movement.gravity) { this._baseHeight = jumping.baseHeight; this._gravity = movement.gravity; this._verticalSpeed = Mathf.Sqrt(2f * this._baseHeight * this._gravity); this.dirty = false; } return this._verticalSpeed; }
public MovingPlatformContext(CCMotor.MovingPlatform setup) : this(ref setup) { }
private void GatherInfo(CCMotor motor) { if (!motor.isGrounded || motor.isSliding) { this.groundLocalVelocity = new Vector3G(); this.groundWorldVelocity = new Vector3G(); this.groundLocalAngularVelocity = new Vector3G(); this.groundLocalVelocityMag = 0; this.groundWorldVelocityMag = 0; this.groundLocalAngularVelocityMag = 0; } else { this.groundLocalVelocity = this.localVelocity; this.groundWorldVelocity = this.worldVelocity; this.groundLocalAngularVelocity = this.localAngularVelocity; this.groundLocalVelocityMag = this.localVelocityMag; this.groundWorldVelocityMag = this.worldVelocityMag; this.groundLocalAngularVelocityMag = this.localAngularVelocityMag; } this.inputForce.x = (double)motor.input.moveDirection.x; this.inputForce.y = (double)motor.input.moveDirection.y; this.inputForce.z = (double)motor.input.moveDirection.z; Matrix4x4G.Mult3x3(ref this.inputForce, ref this.worldToLocal, out this.inputForce); this.inputForce.x = this.inputForce.x * (double)this.cfg.inputForceMultiplier.x; this.inputForce.y = this.inputForce.y * (double)this.cfg.inputForceMultiplier.y; this.inputForce.z = this.inputForce.z * (double)this.cfg.inputForceMultiplier.z; }
public JumpingContext(ref CCMotor.Jumping setup) { this.setup = setup; this.jumping = false; this.holdingJumpButton = false; this.startedJumping = false; this.lastStartTime = 0f; this.lastButtonDownTime = -100f; this.jumpDir.x = 0f; this.jumpDir.y = 1f; this.jumpDir.z = 0f; this.lastLandTime = Single.MinValue; }
private bool ContainsMotor(CCMotor motor) { return((this.activeMotors != null) && this.activeMotors.Contains(motor)); }
private void MotorHacks() { HumanController localController = HackLocal.LocalController; Character localCharacter = HackLocal.LocalCharacter; CCMotor ccmotor = localController.ccmotor; if (ccmotor != null) { if (!this.defaultJumping.HasValue) { this.defaultJumping = new CCMotor.Jumping?(ccmotor.jumping.setup); } else { ccmotor.minTimeBetweenJumps = 0.1f; ccmotor.jumping.setup.baseHeight = this.defaultJumping.Value.baseHeight * CVars.Misc.JumpModifer; } if (!this.defaultMovement.HasValue) { this.defaultMovement = new CCMotor.Movement?(ccmotor.movement.setup); } else { ccmotor.movement.setup.maxForwardSpeed = this.defaultMovement.Value.maxForwardSpeed * CVars.Misc.SpeedModifer / 10f; ccmotor.movement.setup.maxSidewaysSpeed = this.defaultMovement.Value.maxSidewaysSpeed * CVars.Misc.SpeedModifer / 10f; ccmotor.movement.setup.maxBackwardsSpeed = this.defaultMovement.Value.maxBackwardsSpeed * CVars.Misc.SpeedModifer / 10f; ccmotor.movement.setup.maxGroundAcceleration = this.defaultMovement.Value.maxGroundAcceleration * CVars.Misc.SpeedModifer / 10f; ccmotor.movement.setup.maxAirAcceleration = this.defaultMovement.Value.maxAirAcceleration * CVars.Misc.SpeedModifer / 10f; if (CVars.Misc.NoFallDamage) { ccmotor.movement.setup.maxFallSpeed = 17f; } else { ccmotor.movement.setup.maxFallSpeed = this.defaultMovement.Value.maxFallSpeed; } } if (CVars.Misc.FlyHack) { ccmotor.velocity = Vector3.zero; Vector3 forward = localCharacter.eyesAngles.forward; Vector3 right = localCharacter.eyesAngles.right; if (!ChatUI.IsVisible()) { if (Input.GetKey(KeyCode.W)) { ccmotor.velocity += forward * (ccmotor.movement.setup.maxForwardSpeed * 3f); } if (Input.GetKey(KeyCode.S)) { ccmotor.velocity -= forward * (ccmotor.movement.setup.maxBackwardsSpeed * 3f); } if (Input.GetKey(KeyCode.A)) { ccmotor.velocity -= right * (ccmotor.movement.setup.maxSidewaysSpeed * 3f); } if (Input.GetKey(KeyCode.D)) { ccmotor.velocity += right * (ccmotor.movement.setup.maxSidewaysSpeed * 3f); } if (Input.GetKey(KeyCode.Space)) { ccmotor.velocity += Vector3.up * (this.defaultMovement.Value.maxAirAcceleration * 3f); } } if (ccmotor.velocity == Vector3.zero) { ccmotor.velocity += Vector3.up * (ccmotor.settings.gravity * Time.deltaTime * 0.5f); } } } }
private void ProcessInput(ref HumanController.InputSample sample) { bool flag; bool flag1; CCMotor.InputFrame movementScale = new CCMotor.InputFrame(); float single; float single1; CCMotor cCMotor = base.ccmotor; if (!cCMotor) { flag1 = false; flag = true; } else { flag = cCMotor.isGrounded; flag1 = cCMotor.isSliding; if (!flag && !flag1) { sample.sprint = false; sample.crouch = false; sample.aim = false; sample.info__crouchBlocked = false; if (!this.wasInAir) { this.wasInAir = true; this.magnitudeAir = cCMotor.input.moveDirection.magnitude; this.midairStartPos = base.transform.position; } this.lastFrameVelocity = cCMotor.velocity; } else if (this.wasInAir) { this.wasInAir = false; this.magnitudeAir = 1f; this.landingSpeedPenaltyTime = 0f; if (base.transform.position.y < this.midairStartPos.y && Mathf.Abs(base.transform.position.y - this.midairStartPos.y) > 2f) { base.idMain.GetLocal <FallDamage>().SendFallImpact(this.lastFrameVelocity); } this.lastFrameVelocity = Vector3.zero; this.midairStartPos = Vector3.zero; } bool flag2 = (sample.crouch ? true : sample.info__crouchBlocked); movementScale.jump = sample.jump; movementScale.moveDirection.x = sample.strafe; movementScale.moveDirection.y = 0f; movementScale.moveDirection.z = sample.walk; movementScale.crouchSpeed = (!sample.crouch ? 1f : -1f); if (movementScale.moveDirection == Vector3.zero) { this.sprinting = false; this.exitingSprint = false; this.sprintTime = 0f; this.crouchTime = (!sample.crouch ? 0f : this.controlConfig.curveCrouchMulSpeedByTime.GetEndTime()); this.magnitudeAir = 1f; } else { float single2 = movementScale.moveDirection.magnitude; if (single2 < 1f) { movementScale.moveDirection = movementScale.moveDirection / single2; single2 = single2 * single2; movementScale.moveDirection = movementScale.moveDirection * single2; } else if (single2 > 1f) { movementScale.moveDirection = movementScale.moveDirection / single2; } if (HumanController.InputSample.MovementScale < 1f) { if (HumanController.InputSample.MovementScale <= 0f) { movementScale.moveDirection = Vector3.zero; } else { movementScale.moveDirection = movementScale.moveDirection * HumanController.InputSample.MovementScale; } } Vector3 vector3 = movementScale.moveDirection; vector3.x = vector3.x * this.controlConfig.sprintScaleX; vector3.z = vector3.z * this.controlConfig.sprintScaleY; if (!sample.sprint || flag2 || sample.aim) { sample.sprint = false; single = -Time.deltaTime; } else { single = Time.deltaTime * this.sprintInMulTime; } movementScale.moveDirection = movementScale.moveDirection + (vector3 * this.controlConfig.curveSprintAddSpeedByTime.EvaluateClampedTime(ref this.sprintTime, single)); single1 = (!flag2 ? -Time.deltaTime : Time.deltaTime * this.crouchInMulTime); movementScale.moveDirection = movementScale.moveDirection * this.controlConfig.curveCrouchMulSpeedByTime.EvaluateClampedTime(ref this.crouchTime, single1); movementScale.moveDirection = base.transform.TransformDirection(movementScale.moveDirection); if (!this.wasInAir) { movementScale.moveDirection = movementScale.moveDirection * this.controlConfig.curveLandingSpeedPenalty.EvaluateClampedTime(ref this.landingSpeedPenaltyTime, Time.deltaTime); } else { float single3 = movementScale.moveDirection.magnitude; if (!Mathf.Approximately(single3, this.magnitudeAir)) { movementScale.moveDirection = movementScale.moveDirection / single3; movementScale.moveDirection = movementScale.moveDirection * this.magnitudeAir; } } } if (DebugInput.GetKey(KeyCode.H)) { movementScale.moveDirection = movementScale.moveDirection * 100f; } cCMotor.input = movementScale; if (cCMotor.stepMode == CCMotor.StepMode.Elsewhere) { cCMotor.Step(); } } Character character = base.idMain; Crouchable crouchable = character.crouchable; if (character) { Angle2 angle2 = base.eyesAngles; Angle2 angle21 = base.eyesAngles; angle2.yaw = Mathf.DeltaAngle(0f, angle21.yaw + sample.yaw); angle2.pitch = base.ClampPitch(angle2.pitch + sample.pitch); base.eyesAngles = angle2; ushort num = character.stateFlags.flags; if (crouchable) { this.crouch_smoothing.AddSeconds((double)Time.deltaTime); crouchable.LocalPlayerUpdateCrouchState(cCMotor, ref sample.crouch, ref sample.info__crouchBlocked, ref this.crouch_smoothing); } int num1 = (!sample.aim ? 0 : 4) | (!sample.sprint ? 0 : 2) | (!sample.attack ? 0 : 8) | (!sample.attack2 ? 0 : 256) | (!sample.crouch ? 0 : 1) | (sample.strafe != 0f || sample.walk != 0f ? 64 : 0) | (!LockCursorManager.IsLocked() ? 128 : 0) | (!flag ? 16 : 0) | (!flag1 ? 0 : 32) | (!this.bleeding ? 0 : 512) | (!sample.lamp ? 0 : 2048) | (!sample.laser ? 0 : 4096) | (!sample.info__crouchBlocked ? 0 : 1024); character.stateFlags = num1; if (num != num1) { character.Signal_State_FlagsChanged(false); } } this.crouch_was_blocked = sample.info__crouchBlocked; if (sample.inventory) { RPOS.Toggle(); } if (Input.GetKeyDown(KeyCode.Escape)) { RPOS.Hide(); } }
private void ProcessInput(ref InputSample sample) { bool isGrounded; bool isSliding; CCMotor ccmotor = base.ccmotor; if (ccmotor != null) { CCMotor.InputFrame frame; isGrounded = ccmotor.isGrounded; isSliding = ccmotor.isSliding; if (!isGrounded && !isSliding) { sample.sprint = false; sample.crouch = false; sample.aim = false; sample.info__crouchBlocked = false; if (!this.wasInAir) { this.wasInAir = true; this.magnitudeAir = ccmotor.input.moveDirection.magnitude; this.midairStartPos = base.transform.position; } this.lastFrameVelocity = ccmotor.velocity; } else if (this.wasInAir) { this.wasInAir = false; this.magnitudeAir = 1f; this.landingSpeedPenaltyTime = 0f; if ((base.transform.position.y < this.midairStartPos.y) && (Mathf.Abs((float)(base.transform.position.y - this.midairStartPos.y)) > 2f)) { base.idMain.GetLocal <FallDamage>().SendFallImpact(this.lastFrameVelocity); } this.lastFrameVelocity = Vector3.zero; this.midairStartPos = Vector3.zero; } bool flag3 = sample.crouch || sample.info__crouchBlocked; frame.jump = sample.jump; frame.moveDirection.x = sample.strafe; frame.moveDirection.y = 0f; frame.moveDirection.z = sample.walk; frame.crouchSpeed = !sample.crouch ? 1f : -1f; if (frame.moveDirection != Vector3.zero) { float num2; float num3; float magnitude = frame.moveDirection.magnitude; if (magnitude < 1f) { frame.moveDirection = (Vector3)(frame.moveDirection / magnitude); magnitude *= magnitude; frame.moveDirection = (Vector3)(frame.moveDirection * magnitude); } else if (magnitude > 1f) { frame.moveDirection = (Vector3)(frame.moveDirection / magnitude); } if (InputSample.MovementScale < 1f) { if (InputSample.MovementScale > 0f) { frame.moveDirection = (Vector3)(frame.moveDirection * InputSample.MovementScale); } else { frame.moveDirection = Vector3.zero; } } Vector3 moveDirection = frame.moveDirection; moveDirection.x *= this.controlConfig.sprintScaleX; moveDirection.z *= this.controlConfig.sprintScaleY; if ((sample.sprint && !flag3) && !sample.aim) { num2 = Time.deltaTime * this.sprintInMulTime; } else { sample.sprint = false; num2 = -Time.deltaTime; } frame.moveDirection += (Vector3)(moveDirection * this.controlConfig.curveSprintAddSpeedByTime.EvaluateClampedTime(ref this.sprintTime, num2)); if (flag3) { num3 = Time.deltaTime * this.crouchInMulTime; } else { num3 = -Time.deltaTime; } frame.moveDirection = (Vector3)(frame.moveDirection * this.controlConfig.curveCrouchMulSpeedByTime.EvaluateClampedTime(ref this.crouchTime, num3)); frame.moveDirection = base.transform.TransformDirection(frame.moveDirection); if (this.wasInAir) { float a = frame.moveDirection.magnitude; if (!Mathf.Approximately(a, this.magnitudeAir)) { frame.moveDirection = (Vector3)(frame.moveDirection / a); frame.moveDirection = (Vector3)(frame.moveDirection * this.magnitudeAir); } } else { frame.moveDirection = (Vector3)(frame.moveDirection * this.controlConfig.curveLandingSpeedPenalty.EvaluateClampedTime(ref this.landingSpeedPenaltyTime, Time.deltaTime)); } } else { this.sprinting = false; this.exitingSprint = false; this.sprintTime = 0f; this.crouchTime = !sample.crouch ? 0f : this.controlConfig.curveCrouchMulSpeedByTime.GetEndTime(); this.magnitudeAir = 1f; } if (DebugInput.GetKey(KeyCode.H)) { frame.moveDirection = (Vector3)(frame.moveDirection * 100f); } ccmotor.input = frame; if (ccmotor.stepMode == CCMotor.StepMode.Elsewhere) { ccmotor.Step(); } } else { isSliding = false; isGrounded = true; } Character idMain = base.idMain; Crouchable crouchable = idMain.crouchable; if (idMain != null) { Angle2 eyesAngles = base.eyesAngles; eyesAngles.yaw = Mathf.DeltaAngle(0f, base.eyesAngles.yaw + sample.yaw); eyesAngles.pitch = base.ClampPitch((float)(eyesAngles.pitch + sample.pitch)); base.eyesAngles = eyesAngles; ushort flags = idMain.stateFlags.flags; if (crouchable != null) { this.crouch_smoothing.AddSeconds((double)Time.deltaTime); crouchable.LocalPlayerUpdateCrouchState(ccmotor, ref sample.crouch, ref sample.info__crouchBlocked, ref this.crouch_smoothing); } int num6 = ((((((((((((!sample.aim ? 0 : 4) | (!sample.sprint ? 0 : 2)) | (!sample.attack ? 0 : 8)) | (!sample.attack2 ? 0 : 0x100)) | (!sample.crouch ? 0 : 1)) | (((sample.strafe == 0f) && (sample.walk == 0f)) ? 0 : 0x40)) | (!LockCursorManager.IsLocked() ? 0x80 : 0)) | (!isGrounded ? 0x10 : 0)) | (!isSliding ? 0 : 0x20)) | (!this.bleeding ? 0 : 0x200)) | (!sample.lamp ? 0 : 0x800)) | (!sample.laser ? 0 : 0x1000)) | (!sample.info__crouchBlocked ? 0 : 0x400); idMain.stateFlags = num6; if (flags != num6) { idMain.Signal_State_FlagsChanged(false); } } this.crouch_was_blocked = sample.info__crouchBlocked; if (sample.inventory) { RPOS.Toggle(); } if (Input.GetKeyDown(KeyCode.Escape)) { RPOS.Hide(); } }
public static void UninstallCallbacks(CCMotor CCMotor, CCTotemPole CCTotemPole) { if (CCTotemPole && object.ReferenceEquals(CCTotemPole.Tag, CCMotor)) { CCTotemPole.OnConfigurationBinding -= CCMotor.Callbacks.ConfigurationBinder; CCTotemPole.OnBindPosition -= CCMotor.Callbacks.PositionBinder; CCTotemPole.Tag = null; } }
public JumpingContext(CCMotor.Jumping setup) : this(ref setup) { }
public MovementContext(ref CCMotor.Movement setup) { this.setup = setup; this.collisionFlags = CollisionFlags.None; this.crouchBlocked = false; this.acceleration = new Vector3(); this.velocity = new Vector3(); this.frameVelocity = new Vector3(); this.hitPoint = new Vector3(); this.lastHitPoint.x = Single.PositiveInfinity; this.lastHitPoint.y = 0f; this.lastHitPoint.z = 0f; }
private void OnLocallyAppended(IDMain main) { if (!this._motor) { this._motor = main.GetRemote<CCMotor>(); } }
public MovementContext(CCMotor.Movement setup) : this(ref setup) { }
private bool ContainsMotor(CCMotor motor) { return(this.activeMotors == null ? false : this.activeMotors.Contains(motor)); }
public MovingPlatformContext(ref CCMotor.MovingPlatform setup) { this.setup = setup; this.hitPlatform = null; this.activePlatform = null; this.activeLocal = new CCMotor.MovingPlatformContext.PointAndRotation(); this.activeGlobal = new CCMotor.MovingPlatformContext.PointAndRotation(); this.lastMatrix = new Matrix4x4(); this.platformVelocity = new Vector3(); this.newPlatform = false; }
public void Update() { try { character = Hooks.LocalPlayer?.controllable?.GetComponent <Character>() ?? null; if (character != null) { IsAlive = character.alive; } if (AdminPlus.IsAllowed) { if (!ChatUI.IsVisible() && !ConsoleWindow.IsVisible() && !MainMenu.IsVisible() && Input.GetKeyDown(KeyCode.BackQuote)) { AdminPlus.Enabled = !AdminPlus.Enabled; Screen.lockCursor = !AdminPlus.Enabled; } if (IsAlive) { //-- Speed / Jump hack -- character.ccmotor.jumping.setup.baseHeight = 1f + JumpHeight; character.ccmotor.movement.setup.maxForwardSpeed = 4f + SpeedLevel; character.ccmotor.movement.setup.maxSidewaysSpeed = 4f + SpeedLevel; character.ccmotor.movement.setup.maxBackwardsSpeed = 3f + SpeedLevel; character.ccmotor.movement.setup.maxAirAcceleration = 20f + SpeedLevel; //---------------- if (Fly) { var LocalController = PlayerClient.GetLocalPlayer().controllable.GetComponent <HumanController>(); var LocalPlayerClient = PlayerClient.GetLocalPlayer().controllable.GetComponent <PlayerClient>(); CCMotor ccmotor = LocalController.ccmotor; ccmotor.velocity = Vector3.zero; Angle2 eyesAngles = character.eyesAngles; Vector3 forward = eyesAngles.forward; Vector3 back = eyesAngles.back; Vector3 right = eyesAngles.right; Vector3 left = eyesAngles.left; Vector3 up = eyesAngles.up; if (!ChatUI.IsVisible() && !ConsoleWindow.IsVisible() && !MainMenu.IsVisible()) { if (Input.GetKey(KeyCode.W)) { if (Input.GetKey(KeyCode.LeftShift)) { ccmotor.velocity = ccmotor.velocity + forward * (ccmotor.movement.setup.maxForwardSpeed * 20f); } else { ccmotor.velocity = ccmotor.velocity + forward * (ccmotor.movement.setup.maxForwardSpeed * 5f); } } if (Input.GetKey(KeyCode.S)) { if (Input.GetKey(KeyCode.LeftShift)) { ccmotor.velocity = ccmotor.velocity + back * (ccmotor.movement.setup.maxBackwardsSpeed * 20f); } else { ccmotor.velocity = ccmotor.velocity + back * (ccmotor.movement.setup.maxBackwardsSpeed * 5f); } } if (Input.GetKey(KeyCode.A)) { if (Input.GetKey(KeyCode.LeftShift)) { ccmotor.velocity = ccmotor.velocity + left * (ccmotor.movement.setup.maxSidewaysSpeed * 20f); } else { ccmotor.velocity = ccmotor.velocity + left * (ccmotor.movement.setup.maxSidewaysSpeed * 5f); } } if (Input.GetKey(KeyCode.D)) { if (Input.GetKey(KeyCode.LeftShift)) { ccmotor.velocity = ccmotor.velocity + right * (ccmotor.movement.setup.maxSidewaysSpeed * 20f); } else { ccmotor.velocity = ccmotor.velocity + right * (ccmotor.movement.setup.maxSidewaysSpeed * 5f); } } if (Input.GetKey(KeyCode.Space)) { if (Input.GetKey(KeyCode.LeftShift)) { ccmotor.velocity = ccmotor.velocity + up * (ccmotor.movement.setup.maxSidewaysSpeed * 10f); } else { ccmotor.velocity = ccmotor.velocity + up * (ccmotor.movement.setup.maxSidewaysSpeed * 4f); } } } if (ccmotor.velocity == Vector3.zero) { ccmotor.velocity = ccmotor.velocity + Vector3.up * (float)((double)ccmotor.settings.gravity * (double)Time.deltaTime * 0.5); } } } } } catch { } }
public void Update() { if (_fly) { CCMotor ccmotor = this.localController.ccmotor; var defaultMovement = new CCMotor.Movement?(ccmotor.movement.setup); ccmotor.velocity = Vector3.zero; Vector3 forward = this.localCharacter.eyesAngles.forward; Vector3 right = this.localCharacter.eyesAngles.right; if (!ChatUI.IsVisible()) { if (Input.GetKey(KeyCode.W)) { ccmotor.velocity += forward * (ccmotor.movement.setup.maxForwardSpeed * flySpeed); } if (Input.GetKey(KeyCode.S)) { ccmotor.velocity -= forward * (ccmotor.movement.setup.maxBackwardsSpeed * flySpeed); } if (Input.GetKey(KeyCode.A)) { ccmotor.velocity -= right * (ccmotor.movement.setup.maxSidewaysSpeed * flySpeed); } if (Input.GetKey(KeyCode.D)) { ccmotor.velocity += right * (ccmotor.movement.setup.maxSidewaysSpeed * flySpeed); } if (Input.GetKey(KeyCode.Space)) { ccmotor.velocity += Vector3.up * (defaultMovement.Value.maxAirAcceleration * flySpeed); } } if (ccmotor.velocity == Vector3.zero) { ccmotor.velocity += Vector3.up * (ccmotor.settings.gravity * Time.deltaTime * 0.5f); } } if (Input.GetKeyDown(KeyCode.PageUp)) { flySpeed += 0.5f; if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { flySpeed += 1.5f; } } else if (Input.GetKeyDown(KeyCode.PageDown)) { flySpeed -= 0.5f; if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { flySpeed -= 1.5f; } } if (!WorldEditor.Instance.Enabled) { return; } if (Input.GetKeyDown(KeyCode.LeftAlt)) { if (ShowList) { Screen.lockCursor = true; ShowList = false; } else { Screen.lockCursor = false; ShowList = true; } } if (SpawnedObject != null && SpawnedObject.ObjectInstantiate != null) { if (Input.GetKey(KeyCode.Keypad1)) { if (Input.GetKey(KeyCode.RightControl)) { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(0.1f, 0, 0); //POSX } else if (Input.GetKey(KeyCode.RightShift)) { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(1f, 0, 0); //POSX } else { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(0.01f, 0, 0); //POSX } } if (Input.GetKey(KeyCode.Keypad2)) { if (Input.GetKey(KeyCode.RightControl)) { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(0.1f, 0, 0); //POSX } else if (Input.GetKey(KeyCode.RightShift)) { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(1f, 0, 0); //POSX } else { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(0.01f, 0, 0); //POSX } } if (Input.GetKey(KeyCode.Keypad4)) { if (Input.GetKey(KeyCode.RightControl)) { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(0, 0, 0.1f); //POSZ } else if (Input.GetKey(KeyCode.RightShift)) { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(0, 0, 1f); //POSZ } else { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(0, 0, 0.01f); //POSZ } } if (Input.GetKey(KeyCode.Keypad5)) { if (Input.GetKey(KeyCode.RightControl)) { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(0, 0, 0.1f); //POSZ } else if (Input.GetKey(KeyCode.RightShift)) { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(0, 0, 1f); //POSZ } else { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(0, 0, 0.01f); //POSZ } } if (Input.GetKey(KeyCode.Keypad7)) { if (Input.GetKey(KeyCode.RightControl)) { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(0, 0.1f, 0); //POSY } else if (Input.GetKey(KeyCode.RightShift)) { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(0, 1f, 0); //POSY } else { SpawnedObject.ObjectInstantiate.transform.position += new Vector3(0, 0.01f, 0); //POSY } } if (Input.GetKey(KeyCode.Keypad8)) { if (Input.GetKey(KeyCode.RightControl)) { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(0, 0.1f, 0); //POSY } else if (Input.GetKey(KeyCode.RightShift)) { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(0, 1f, 0); //POSY } else { SpawnedObject.ObjectInstantiate.transform.position -= new Vector3(0, 0.01f, 0); //POSY } } if (Input.GetKey(KeyCode.UpArrow)) { if (Input.GetKey(KeyCode.RightControl)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.x = rot.x + 0.1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else if (Input.GetKey(KeyCode.RightShift)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.x = rot.x + 1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.x = rot.x + 0.01f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } } if (Input.GetKey(KeyCode.DownArrow)) { if (Input.GetKey(KeyCode.RightControl)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.x = rot.x - 0.1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else if (Input.GetKey(KeyCode.RightShift)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.x = rot.x - 1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.x = rot.x - 0.01f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } } if (Input.GetKey(KeyCode.LeftArrow)) { if (Input.GetKey(KeyCode.RightControl)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.y = rot.y + 0.1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else if (Input.GetKey(KeyCode.RightShift)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.y = rot.y + 1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.y = rot.y + 0.01f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } } if (Input.GetKey(KeyCode.RightArrow)) { if (Input.GetKey(KeyCode.RightControl)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.y = rot.y - 0.1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else if (Input.GetKey(KeyCode.RightShift)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.y = rot.y - 1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.y = rot.y - 0.01f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } } if (Input.GetKey(KeyCode.Keypad3)) { if (Input.GetKey(KeyCode.RightControl)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.z = rot.z + 0.1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else if (Input.GetKey(KeyCode.RightShift)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.z = rot.z + 1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.z = rot.z + 0.01f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } } if (Input.GetKey(KeyCode.KeypadEnter)) { if (Input.GetKey(KeyCode.RightControl)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.z = rot.z - 0.1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else if (Input.GetKey(KeyCode.RightShift)) { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.z = rot.z - 1f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } else { var rot = SpawnedObject.ObjectInstantiate.transform.rotation; rot.z = rot.z - 0.01f; SpawnedObject.ObjectInstantiate.transform.rotation = rot; } } if (Input.GetKey(KeyCode.KeypadMultiply)) { if (Input.GetKey(KeyCode.RightControl)) { SpawnedObject.ObjectInstantiate.transform.localScale += new Vector3(0.1f, 0.1f, 0.1f); //SIZE + } else if (Input.GetKey(KeyCode.RightShift)) { SpawnedObject.ObjectInstantiate.transform.localScale += new Vector3(1f, 1f, 1f); } else { SpawnedObject.ObjectInstantiate.transform.localScale += new Vector3(0.01f, 0.01f, 0.01f); //SIZE + } } if (Input.GetKey(KeyCode.KeypadMinus)) { if (SpawnedObject.ObjectInstantiate.transform.localScale == Vector3.zero) { return; } if (Input.GetKey(KeyCode.RightControl)) { SpawnedObject.ObjectInstantiate.transform.localScale -= new Vector3(0.1f, 0.1f, 0.1f); //SIZE - } else if (Input.GetKey(KeyCode.RightShift)) { SpawnedObject.ObjectInstantiate.transform.localScale -= new Vector3(1f, 1f, 1f); } else { SpawnedObject.ObjectInstantiate.transform.localScale -= new Vector3(0.01f, 0.01f, 0.01f); //SIZE - } } } }