Some more cleanup + event desync debug messages
This commit is contained in:
@@ -5,6 +5,21 @@ namespace Barotrauma
|
||||
{
|
||||
partial class HumanAIController : AIController
|
||||
{
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
if (GameMain.GameSession != null && GameMain.GameSession.CrewManager != null)
|
||||
{
|
||||
CurrentOrder = Order.PrefabList.Find(o => o.Name.ToLowerInvariant() == "dismissed");
|
||||
objectiveManager.SetOrder(CurrentOrder, "");
|
||||
GameMain.GameSession.CrewManager.SetCharacterOrder(Character, CurrentOrder);
|
||||
}
|
||||
}
|
||||
|
||||
partial void SetOrderProjSpecific(Order order)
|
||||
{
|
||||
GameMain.GameSession.CrewManager.SetCharacterOrder(Character, order);
|
||||
}
|
||||
|
||||
public override void DebugDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
if (selectedAiTarget != null)
|
||||
|
||||
@@ -5,6 +5,32 @@ namespace Barotrauma
|
||||
{
|
||||
partial class AICharacter : Character
|
||||
{
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
soundTimer = Rand.Range(0.0f, soundInterval);
|
||||
}
|
||||
|
||||
partial void SoundUpdate(float deltaTime)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawFront(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Camera cam)
|
||||
{
|
||||
base.DrawFront(spriteBatch, cam);
|
||||
|
||||
@@ -13,6 +13,58 @@ namespace Barotrauma
|
||||
{
|
||||
partial class Ragdoll
|
||||
{
|
||||
partial void ImpactProjSpecific(float impact, Body body)
|
||||
{
|
||||
float volume = Math.Min(impact - 3.0f, 1.0f);
|
||||
|
||||
if (body.UserData is Limb)
|
||||
{
|
||||
Limb limb = (Limb)body.UserData;
|
||||
|
||||
if (impact > 3.0f && limb.HitSound != null && limb.soundTimer <= 0.0f)
|
||||
{
|
||||
limb.soundTimer = Limb.SoundInterval;
|
||||
limb.HitSound.Play(volume, impact * 100.0f, limb.WorldPosition);
|
||||
}
|
||||
}
|
||||
else if (body == Collider.FarseerBody)
|
||||
{
|
||||
if (!character.IsRemotePlayer || GameMain.Server != null)
|
||||
{
|
||||
if (impact > ImpactTolerance)
|
||||
{
|
||||
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, Collider);
|
||||
}
|
||||
}
|
||||
|
||||
if (Character.Controlled == character) GameMain.GameScreen.Cam.Shake = strongestImpact;
|
||||
}
|
||||
}
|
||||
|
||||
partial void Splash(Limb limb, Hull limbHull)
|
||||
{
|
||||
//create a splash particle
|
||||
GameMain.ParticleManager.CreateParticle("watersplash",
|
||||
new Vector2(limb.Position.X, limbHull.Surface) + limbHull.Submarine.Position,
|
||||
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 20.0f)),
|
||||
0.0f, limbHull);
|
||||
|
||||
GameMain.ParticleManager.CreateParticle("bubbles",
|
||||
new Vector2(limb.Position.X, limbHull.Surface) + limbHull.Submarine.Position,
|
||||
limb.LinearVelocity * 0.001f,
|
||||
0.0f, limbHull);
|
||||
|
||||
//if the Character dropped into water, create a wave
|
||||
if (limb.LinearVelocity.Y < 0.0f)
|
||||
{
|
||||
if (splashSoundTimer <= 0.0f)
|
||||
{
|
||||
SoundPlayer.PlaySplashSound(limb.WorldPosition, Math.Abs(limb.LinearVelocity.Y) + Rand.Range(-5.0f, 0.0f));
|
||||
splashSoundTimer = 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (simplePhysicsEnabled) return;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Particles;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class Attack
|
||||
{
|
||||
private Sound sound;
|
||||
|
||||
private ParticleEmitterPrefab particleEmitterPrefab;
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
string soundPath = ToolBox.GetAttributeString(element, "sound", "");
|
||||
if (!string.IsNullOrWhiteSpace(soundPath))
|
||||
{
|
||||
sound = Sound.Load(soundPath);
|
||||
}
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "particleemitter":
|
||||
particleEmitterPrefab = new ParticleEmitterPrefab(subElement);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
partial void DamageParticles(Vector2 worldPosition)
|
||||
{
|
||||
if (particleEmitterPrefab != null)
|
||||
{
|
||||
particleEmitterPrefab.Emit(worldPosition);
|
||||
}
|
||||
|
||||
if (sound != null)
|
||||
{
|
||||
sound.Play(1.0f, 500.0f, worldPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,10 @@ namespace Barotrauma
|
||||
get { return hudProgressBars; }
|
||||
}
|
||||
|
||||
private void InitProjSpecific(XDocument doc)
|
||||
partial void InitProjSpecific(XDocument doc)
|
||||
{
|
||||
soundInterval = ToolBox.GetAttributeFloat(doc.Root, "soundinterval", 10.0f);
|
||||
|
||||
keys = new Key[Enum.GetNames(typeof(InputType)).Length];
|
||||
|
||||
for (int i = 0; i < Enum.GetNames(typeof(InputType)).Length; i++)
|
||||
@@ -65,6 +67,195 @@ namespace Barotrauma
|
||||
hudProgressBars = new Dictionary<object, HUDProgressBar>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Control the Character according to player input
|
||||
/// </summary>
|
||||
public void ControlLocalPlayer(float deltaTime, Camera cam, bool moveCam = true)
|
||||
{
|
||||
if (!DisableControls)
|
||||
{
|
||||
for (int i = 0; i < keys.Length; i++)
|
||||
{
|
||||
keys[i].SetState();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Key key in keys)
|
||||
{
|
||||
if (key == null) continue;
|
||||
key.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (moveCam && needsAir)
|
||||
{
|
||||
if (pressureProtection < 80.0f &&
|
||||
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure > 50.0f))
|
||||
{
|
||||
float pressure = AnimController.CurrentHull == null ? 100.0f : AnimController.CurrentHull.LethalPressure;
|
||||
|
||||
cam.Zoom = MathHelper.Lerp(cam.Zoom,
|
||||
(pressure / 50.0f) * Rand.Range(1.0f, 1.05f),
|
||||
(pressure - 50.0f) / 50.0f);
|
||||
}
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
|
||||
}
|
||||
|
||||
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
if (AnimController.CurrentHull != null && AnimController.CurrentHull.Submarine != null)
|
||||
{
|
||||
cursorPosition -= AnimController.CurrentHull.Submarine.Position;
|
||||
}
|
||||
|
||||
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
|
||||
|
||||
if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
|
||||
{
|
||||
Body body = Submarine.PickBody(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
||||
Structure structure = null;
|
||||
if (body != null) structure = body.UserData as Structure;
|
||||
if (structure != null)
|
||||
{
|
||||
if (!structure.CastShadow && moveCam)
|
||||
{
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 500.0f, 0.05f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!LockHands)
|
||||
{
|
||||
//find the closest item if selectkey has been hit, or if the Character is being
|
||||
//controlled by the player (in order to highlight it)
|
||||
|
||||
if (findClosestTimer <= 0.0f || Screen.Selected == GameMain.EditMapScreen)
|
||||
{
|
||||
closestCharacter = FindClosestCharacter(mouseSimPos);
|
||||
if (closestCharacter != null && closestCharacter.info == null)
|
||||
{
|
||||
closestCharacter = null;
|
||||
}
|
||||
|
||||
float closestItemDist = 0.0f;
|
||||
closestItem = FindClosestItem(mouseSimPos, out closestItemDist);
|
||||
|
||||
if (closestCharacter != null && closestItem != null)
|
||||
{
|
||||
if (Vector2.DistanceSquared(closestCharacter.SimPosition, mouseSimPos) < ConvertUnits.ToSimUnits(closestItemDist) * ConvertUnits.ToSimUnits(closestItemDist))
|
||||
{
|
||||
if (selectedConstruction != closestItem) closestItem = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
closestCharacter = null;
|
||||
}
|
||||
}
|
||||
|
||||
findClosestTimer = 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
findClosestTimer -= deltaTime;
|
||||
}
|
||||
|
||||
if (selectedCharacter == null && closestItem != null)
|
||||
{
|
||||
closestItem.IsHighlighted = true;
|
||||
if (!LockHands && closestItem.Pick(this))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (IsKeyHit(InputType.Select))
|
||||
{
|
||||
if (selectedCharacter != null)
|
||||
{
|
||||
DeselectCharacter();
|
||||
}
|
||||
else if (closestCharacter != null && closestCharacter.IsHumanoid && closestCharacter.CanBeSelected)
|
||||
{
|
||||
SelectCharacter(closestCharacter);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedCharacter != null) DeselectCharacter();
|
||||
selectedConstruction = null;
|
||||
closestItem = null;
|
||||
closestCharacter = null;
|
||||
}
|
||||
|
||||
DisableControls = false;
|
||||
}
|
||||
|
||||
partial void UpdateControlled(float deltaTime,Camera cam)
|
||||
{
|
||||
if (controlled == this)
|
||||
{
|
||||
ControlLocalPlayer(deltaTime, cam);
|
||||
}
|
||||
|
||||
Lights.LightManager.ViewTarget = this;
|
||||
CharacterHUD.Update(deltaTime, this);
|
||||
|
||||
foreach (HUDProgressBar progressBar in hudProgressBars.Values)
|
||||
{
|
||||
progressBar.Update(deltaTime);
|
||||
}
|
||||
|
||||
foreach (var pb in hudProgressBars.Where(pb => pb.Value.FadeTimer <= 0.0f).ToList())
|
||||
{
|
||||
hudProgressBars.Remove(pb.Key);
|
||||
}
|
||||
}
|
||||
|
||||
partial void DamageHUD(float amount)
|
||||
{
|
||||
if (controlled == this) CharacterHUD.TakeDamage(amount);
|
||||
}
|
||||
|
||||
partial void UpdateOxygenProjSpecific(float prevOxygen)
|
||||
{
|
||||
if (prevOxygen > 0.0f && Oxygen <= 0.0f && controlled == this)
|
||||
{
|
||||
SoundPlayer.PlaySound("drown");
|
||||
}
|
||||
}
|
||||
|
||||
partial void KillProjSpecific()
|
||||
{
|
||||
if (GameMain.NetworkMember != null && Character.controlled == this)
|
||||
{
|
||||
string chatMessage = InfoTextManager.GetInfoText("Self_CauseOfDeath." + causeOfDeath.ToString());
|
||||
if (GameMain.Client != null) chatMessage += " Your chat messages will only be visible to other dead players.";
|
||||
|
||||
GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead);
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
controlled = null;
|
||||
}
|
||||
|
||||
PlaySound(CharacterSound.SoundType.Die);
|
||||
}
|
||||
|
||||
partial void DisposeProjSpecific()
|
||||
{
|
||||
if (controlled == this) controlled = null;
|
||||
|
||||
if (GameMain.GameSession?.CrewManager != null &&
|
||||
GameMain.GameSession.CrewManager.characters.Contains(this))
|
||||
{
|
||||
GameMain.GameSession.CrewManager.characters.Remove(this);
|
||||
}
|
||||
|
||||
if (GameMain.Client != null && GameMain.Client.Character == this) GameMain.Client.Character = null;
|
||||
|
||||
if (Lights.LightManager.ViewTarget == this) Lights.LightManager.ViewTarget = null;
|
||||
}
|
||||
|
||||
public static void AddAllToGUIUpdateList()
|
||||
{
|
||||
for (int i = 0; i < CharacterList.Count; i++)
|
||||
@@ -80,26 +271,7 @@ namespace Barotrauma
|
||||
CharacterHUD.AddToGUIUpdateList(this);
|
||||
}
|
||||
}
|
||||
|
||||
partial void UpdateControlled(float deltaTime)
|
||||
{
|
||||
if (controlled == this)
|
||||
{
|
||||
Lights.LightManager.ViewTarget = this;
|
||||
CharacterHUD.Update(deltaTime, this);
|
||||
|
||||
foreach (HUDProgressBar progressBar in hudProgressBars.Values)
|
||||
{
|
||||
progressBar.Update(deltaTime);
|
||||
}
|
||||
|
||||
foreach (var pb in hudProgressBars.Where(pb => pb.Value.FadeTimer <= 0.0f).ToList())
|
||||
{
|
||||
hudProgressBars.Remove(pb.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class HuskInfection
|
||||
{
|
||||
partial void UpdateProjSpecific(float prevTimer, Character character)
|
||||
{
|
||||
if (IncubationTimer < 0.5f)
|
||||
{
|
||||
if (prevTimer % 0.1f > 0.05f && IncubationTimer % 0.1f < 0.05f)
|
||||
{
|
||||
GUI.AddMessage(InfoTextManager.GetInfoText("HuskDormant"), Color.Red, 4.0f);
|
||||
}
|
||||
}
|
||||
else if (IncubationTimer < 1.0f)
|
||||
{
|
||||
if (state == InfectionState.Dormant && Character.Controlled == character)
|
||||
{
|
||||
new GUIMessageBox("", InfoTextManager.GetInfoText("HuskCantSpeak"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Character.Controlled == character) new GUIMessageBox("", InfoTextManager.GetInfoText("HuskActivate"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,11 @@ namespace Barotrauma
|
||||
{
|
||||
partial class Limb
|
||||
{
|
||||
public readonly LightSource LightSource;
|
||||
public LightSource LightSource
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
Sound hitSound;
|
||||
|
||||
@@ -24,6 +28,31 @@ namespace Barotrauma
|
||||
get { return hitSound; }
|
||||
}
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "lightsource":
|
||||
LightSource = new LightSource(subElement);
|
||||
break;
|
||||
case "sound":
|
||||
hitSound = Sound.Load(ToolBox.GetAttributeString(subElement, "file", ""));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
partial void UpdateProjSpecific()
|
||||
{
|
||||
if (LightSource != null)
|
||||
{
|
||||
LightSource.Rotation = dir == Direction.Right ? body.DrawRotation : body.DrawRotation - MathHelper.Pi;
|
||||
LightSource.ParentSub = body.Submarine;
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
float brightness = 1.0f - (burnt / 100.0f) * 0.5f;
|
||||
|
||||
Reference in New Issue
Block a user