public override void Update(float deltaTime, Camera cam) { base.Update(deltaTime, cam); if (!Enabled || IsRemotePlayer) { return; } float dist = Vector2.DistanceSquared(cam.WorldViewCenter, WorldPosition); if (dist > 8000.0f * 8000.0f) { AnimController.SimplePhysicsEnabled = true; } else if (dist < 7000.0f * 7000.0f) { AnimController.SimplePhysicsEnabled = false; } if (IsDead || Health <= 0.0f || IsUnconscious || Stun > 0.0f) { return; } if (Controlled == this || !aiController.Enabled) { return; } SoundUpdate(deltaTime); aiController.Update(deltaTime); }
public override void Update(float deltaTime, Camera cam) { base.Update(deltaTime, cam); if (!Enabled) { return; } if (!IsRemotePlayer) { float characterDist = Vector2.DistanceSquared(cam.WorldViewCenter, WorldPosition); if (GameMain.Server != null) { //get the distance from the closest player to this character foreach (Character c in CharacterList) { if (c != this && (c.IsRemotePlayer || c == GameMain.Server.Character)) { float dist = Vector2.DistanceSquared(c.WorldPosition, WorldPosition); if (dist < characterDist) { characterDist = dist; if (characterDist < DisableSimplePhysicsDistSqr) { break; } } } } } if (characterDist > EnableSimplePhysicsDistSqr) { AnimController.SimplePhysicsEnabled = true; } else if (characterDist < DisableSimplePhysicsDistSqr) { AnimController.SimplePhysicsEnabled = false; } } if (IsDead || Health <= 0.0f || IsUnconscious || Stun > 0.0f) { return; } if (Controlled == this || !aiController.Enabled) { return; } SoundUpdate(deltaTime); if (!IsRemotePlayer) { aiController.Update(deltaTime); } }
public override void Update(float deltaTime, Camera cam) { base.Update(deltaTime, cam); if (!Enabled) { return; } if (IsDead || Vitality <= 0.0f || Stun > 0.0f || IsIncapacitated) { //don't enable simple physics on dead/incapacitated characters //the ragdoll controls the movement of incapacitated characters instead of the collider, //but in simple physics mode the ragdoll would get disabled, causing the character to not move at all AnimController.SimplePhysicsEnabled = false; return; } if (!IsRemotePlayer && !(AIController is HumanAIController)) { float characterDist = float.MaxValue; #if CLIENT characterDist = Vector2.DistanceSquared(cam.GetPosition(), WorldPosition); #elif SERVER if (GameMain.Server != null) { characterDist = GetClosestDistance(); } #endif if (characterDist > EnableSimplePhysicsDistSqr) { AnimController.SimplePhysicsEnabled = true; } else if (characterDist < DisableSimplePhysicsDistSqr) { AnimController.SimplePhysicsEnabled = false; } } if (!aiController.Enabled) { return; } if (GameMain.NetworkMember != null && !GameMain.NetworkMember.IsServer) { return; } if (Controlled == this) { return; } if (!IsRemotePlayer) { aiController.Update(deltaTime); } }
public override void Update(float deltaTime, Camera cam) { base.Update(deltaTime, cam); if (!Enabled) { return; } if (!IsRemotePlayer) { float characterDist = float.MaxValue; #if CLIENT characterDist = Vector2.DistanceSquared(cam.GetPosition(), WorldPosition); #elif SERVER if (GameMain.Server != null) { characterDist = GetClosestDistance(); } #endif if (characterDist > EnableSimplePhysicsDistSqr) { AnimController.SimplePhysicsEnabled = true; } else if (characterDist < DisableSimplePhysicsDistSqr) { AnimController.SimplePhysicsEnabled = false; } } if (IsDead || Vitality <= 0.0f || IsUnconscious || Stun > 0.0f) { return; } if (!aiController.Enabled) { return; } if (GameMain.NetworkMember != null && !GameMain.NetworkMember.IsServer) { return; } if (Controlled == this) { return; } if (!IsRemotePlayer) { aiController.Update(deltaTime); } }
public override void Update(Camera cam, float deltaTime) { base.Update(cam, deltaTime); if (!Enabled || IsRemotePlayer) { return; } float dist = Vector2.DistanceSquared(cam.WorldViewCenter, WorldPosition); if (dist > 8000.0f * 8000.0f) { AnimController.SimplePhysicsEnabled = true; } else if (dist < 7000.0f * 7000.0f) { AnimController.SimplePhysicsEnabled = false; } if (IsDead || Health <= 0.0f || IsUnconscious || Stun > 0.0f) { return; } if (Controlled == this || !aiController.Enabled) { return; } if (soundTimer > 0) { soundTimer -= deltaTime; } else { switch (aiController.State) { case AIController.AiState.Attack: PlaySound(CharacterSound.SoundType.Attack); break; default: PlaySound(CharacterSound.SoundType.Idle); break; } soundTimer = soundInterval; } aiController.Update(deltaTime); }
public override void Update(float deltaTime, Camera cam) { base.Update(deltaTime, cam); if (!Enabled) { return; } if (!IsRemotePlayer && AIController is EnemyAIController enemyAi) { enemyAi.PetBehavior?.Update(deltaTime); } if (IsDead || Vitality <= 0.0f || Stun > 0.0f || IsIncapacitated) { //don't enable simple physics on dead/incapacitated characters //the ragdoll controls the movement of incapacitated characters instead of the collider, //but in simple physics mode the ragdoll would get disabled, causing the character to not move at all AnimController.SimplePhysicsEnabled = false; return; } if (!IsRemotePlayer && !(AIController is HumanAIController)) { float characterDistSqr = GetDistanceSqrToClosestPlayer(); if (characterDistSqr > EnableSimplePhysicsDistSqr) { AnimController.SimplePhysicsEnabled = true; } else if (characterDistSqr < DisableSimplePhysicsDistSqr) { AnimController.SimplePhysicsEnabled = false; } } if (GameMain.NetworkMember != null && !GameMain.NetworkMember.IsServer) { return; } if (Controlled == this) { return; } if (!IsRemotelyControlled && aiController != null && aiController.Enabled) { aiController.Update(deltaTime); } }