mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-25 14:14:46 -04:00
More configurable physics
This commit is contained in:
parent
8f81cb6d9a
commit
8583c51cfc
@ -104,10 +104,8 @@ namespace ClassicalSharp.Entities {
|
||||
|
||||
static Vector3 waterDrag = new Vector3(0.8f, 0.8f, 0.8f),
|
||||
lavaDrag = new Vector3(0.5f, 0.5f, 0.5f),
|
||||
ropeDrag = new Vector3(0.5f, 0.85f, 0.5f),
|
||||
normalDrag = new Vector3(0.91f, 0.98f, 0.91f),
|
||||
airDrag = new Vector3(0.6f, 1f, 0.6f);
|
||||
const float liquidGrav = 0.02f, ropeGrav = 0.034f, normalGrav = 0.08f;
|
||||
ropeDrag = new Vector3(0.5f, 0.85f, 0.5f);
|
||||
const float liquidGrav = 0.02f, ropeGrav = 0.034f;
|
||||
|
||||
public void PhysicsTick(Vector3 vel) {
|
||||
if (hacks.Noclip) entity.onGround = false;
|
||||
@ -130,12 +128,12 @@ namespace ClassicalSharp.Entities {
|
||||
MoveNormal(vel, 0.02f * 1.7f, ropeDrag, ropeGrav, yMul);
|
||||
} else {
|
||||
float factor = !(hacks.Flying || hacks.Noclip) && entity.onGround ? 0.1f : 0.02f;
|
||||
float gravity = useLiquidGravity ? liquidGrav : normalGrav;
|
||||
float gravity = useLiquidGravity ? liquidGrav : entity.Model.Gravity;
|
||||
|
||||
if (hacks.Flying || hacks.Noclip) {
|
||||
MoveFlying(vel, factor * horMul, normalDrag, gravity, yMul);
|
||||
MoveFlying(vel, factor * horMul, entity.Model.Drag, gravity, yMul);
|
||||
} else {
|
||||
MoveNormal(vel, factor * horMul, normalDrag, gravity, yMul);
|
||||
MoveNormal(vel, factor * horMul, entity.Model.Drag, gravity, yMul);
|
||||
}
|
||||
|
||||
if (entity.BlockUnderFeet == Block.Ice && !(hacks.Flying || hacks.Noclip)) {
|
||||
@ -147,7 +145,7 @@ namespace ClassicalSharp.Entities {
|
||||
entity.Velocity.Z *= scale;
|
||||
}
|
||||
} else if (entity.onGround || hacks.Flying) {
|
||||
entity.Velocity = Utils.Mul(entity.Velocity, airDrag); // air drag or ground friction
|
||||
entity.Velocity = Utils.Mul(entity.Velocity, entity.Model.GroundFriction); // air drag or ground friction
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,16 @@ namespace ClassicalSharp.Model {
|
||||
/// <summary> Whether this entity requires downloading of a skin texture. </summary>
|
||||
public bool UsesSkin = true;
|
||||
|
||||
/// <summary> Gravity applied to this entity. </summary>
|
||||
public virtual float Gravity { get { return 0.08f; } }
|
||||
|
||||
/// <summary> Drag applied to the entity. </summary>
|
||||
public virtual Vector3 Drag { get { return new Vector3(0.91f, 0.98f, 0.91f); } }
|
||||
|
||||
/// <summary> Friction applied to the entity when is on the ground. </summary>
|
||||
public virtual Vector3 GroundFriction { get { return new Vector3(0.6f, 1.0f, 0.6f); } }
|
||||
|
||||
|
||||
/// <summary> Vertical offset from the model's feet/base that the name texture should be drawn at. </summary>
|
||||
public abstract float NameYOffset { get; }
|
||||
|
||||
@ -45,6 +55,7 @@ namespace ClassicalSharp.Model {
|
||||
/// <summary> Scaling factor applied, multiplied by the entity's current model scale. </summary>
|
||||
public virtual float NameScale { get { return 1; } }
|
||||
|
||||
|
||||
/// <summary> The size of the bounding box that is used when
|
||||
/// performing collision detection for this model. </summary>
|
||||
public abstract Vector3 CollisionSize { get; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user