(6d989732) Unstable v0.9.708.0
This commit is contained in:
@@ -28,6 +28,8 @@ namespace Barotrauma
|
||||
public float FadeOutTime { get; private set; } = 1;
|
||||
|
||||
public bool Static { get; private set; }
|
||||
public bool StaticSound { get; private set; }
|
||||
public bool StaticSight { get; private set; }
|
||||
|
||||
public float SoundRange
|
||||
{
|
||||
@@ -152,8 +154,8 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
// Non-static ai targets must be kept alive by a custom logic (e.g. item components)
|
||||
SightRange = MinSightRange;
|
||||
SoundRange = MinSoundRange;
|
||||
SightRange = StaticSight ? MaxSightRange : MinSightRange;
|
||||
SoundRange = StaticSound ? MaxSoundRange : MinSoundRange;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +169,13 @@ namespace Barotrauma
|
||||
MaxSoundRange = element.GetAttributeFloat("maxsoundrange", SoundRange);
|
||||
FadeOutTime = element.GetAttributeFloat("fadeouttime", FadeOutTime);
|
||||
Static = element.GetAttributeBool("static", Static);
|
||||
StaticSight = element.GetAttributeBool("staticsight", StaticSight);
|
||||
StaticSound = element.GetAttributeBool("staticsound", StaticSound);
|
||||
if (Static)
|
||||
{
|
||||
StaticSound = true;
|
||||
StaticSight = true;
|
||||
}
|
||||
SonarDisruption = element.GetAttributeFloat("sonardisruption", 0.0f);
|
||||
SonarLabel = element.GetAttributeString("sonarlabel", "");
|
||||
SonarIconIdentifier = element.GetAttributeString("sonaricon", "");
|
||||
@@ -189,11 +198,37 @@ namespace Barotrauma
|
||||
if (!Static && FadeOutTime > 0)
|
||||
{
|
||||
// The aitarget goes silent/invisible if the components don't keep it active
|
||||
SightRange -= deltaTime * (MaxSightRange / FadeOutTime);
|
||||
SoundRange -= deltaTime * (MaxSoundRange / FadeOutTime);
|
||||
if (!StaticSight)
|
||||
{
|
||||
DecreaseSightRange(deltaTime);
|
||||
}
|
||||
if (!StaticSound)
|
||||
{
|
||||
DecreaseSoundRange(deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void IncreaseSoundRange(float deltaTime, float speed = 1)
|
||||
{
|
||||
SoundRange += speed * deltaTime * (MaxSoundRange / FadeOutTime);
|
||||
}
|
||||
|
||||
public void IncreaseSightRange(float deltaTime, float speed = 1)
|
||||
{
|
||||
SightRange += speed * deltaTime * (MaxSightRange / FadeOutTime);
|
||||
}
|
||||
|
||||
public void DecreaseSoundRange(float deltaTime, float speed = 1)
|
||||
{
|
||||
SoundRange -= speed * deltaTime * (MaxSoundRange / FadeOutTime);
|
||||
}
|
||||
|
||||
public void DecreaseSightRange(float deltaTime, float speed = 1)
|
||||
{
|
||||
SightRange -= speed * deltaTime * (MaxSightRange / FadeOutTime);
|
||||
}
|
||||
|
||||
public bool IsWithinSector(Vector2 worldPosition)
|
||||
{
|
||||
if (sectorRad >= MathHelper.TwoPi) return true;
|
||||
|
||||
@@ -313,6 +313,10 @@ namespace Barotrauma
|
||||
selectedCharacter = value;
|
||||
if (selectedCharacter != null)
|
||||
selectedCharacter.selectedBy = this;
|
||||
|
||||
#if CLIENT
|
||||
CharacterHealth.SetHealthBarVisibility(value == null);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,37 +262,8 @@ namespace Barotrauma
|
||||
|
||||
#if CLIENT
|
||||
private Sprite jobIcon;
|
||||
private Vector2 jobIconPos
|
||||
{
|
||||
get { return new Vector2(HUDLayoutSettings.HealthBarAreaLeft.Right, HUDLayoutSettings.HealthBarAreaLeft.Y - HUDLayoutSettings.Padding); }
|
||||
}
|
||||
#endif
|
||||
|
||||
private Sprite portraitBackground;
|
||||
public Sprite PortraitBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
if (portraitBackground == null)
|
||||
{
|
||||
var portraitBackgroundElement = CharacterConfigElement.Element("portraitbackground");
|
||||
if (portraitBackgroundElement != null)
|
||||
{
|
||||
portraitBackground = new Sprite(portraitBackgroundElement.Element("sprite"));
|
||||
}
|
||||
}
|
||||
return portraitBackground;
|
||||
}
|
||||
private set
|
||||
{
|
||||
if (portraitBackground != null)
|
||||
{
|
||||
portraitBackground.Remove();
|
||||
}
|
||||
portraitBackground = value;
|
||||
}
|
||||
}
|
||||
|
||||
private List<WearableSprite> attachmentSprites;
|
||||
public List<WearableSprite> AttachmentSprites
|
||||
{
|
||||
@@ -956,8 +927,20 @@ namespace Barotrauma
|
||||
DebugConsole.ThrowError("Invalid inventory data in character \"" + Name + "\" - no slot indices found");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//make sure there's no other item in the slot
|
||||
//this should not happen normally, but can occur if the character is accidentally given new job items while also loading previous items in the campaign
|
||||
for (int i = 0; i < inventory.Capacity; i++)
|
||||
{
|
||||
if (slotIndices.Contains(i) && inventory.Items[i] != null && inventory.Items[i] != newItem)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error while loading character inventory data. The slot {i} was already occupied by the item \"{inventory.Items[i].Name} ({inventory.Items[i].ID})\" when loading the item \"{newItem.Name} ({newItem.ID})\"");
|
||||
inventory.Items[i].Drop(null, createNetworkEvent: false);
|
||||
}
|
||||
}
|
||||
|
||||
inventory.TryPutItem(newItem, slotIndices[0], false, false, null);
|
||||
newItem.ParentInventory = inventory;
|
||||
|
||||
//force the item to the correct slots
|
||||
// e.g. putting the item in a hand slot will also put it in the first available Any-slot,
|
||||
@@ -1016,7 +999,6 @@ namespace Barotrauma
|
||||
Character = null;
|
||||
HeadSprite = null;
|
||||
Portrait = null;
|
||||
PortraitBackground = null;
|
||||
AttachmentSprites = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1436,6 +1436,7 @@ namespace Barotrauma
|
||||
#endif
|
||||
}
|
||||
spawnedCharacter.GiveJobItems(spawnPoint);
|
||||
spawnedCharacter.Info.StartItemsGiven = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace Barotrauma
|
||||
|
||||
private readonly List<ScriptedEvent> activeEvents = new List<ScriptedEvent>();
|
||||
|
||||
#if DEBUG && SERVER
|
||||
private DateTime nextIntensityLogTime;
|
||||
#endif
|
||||
|
||||
private EventManagerSettings settings;
|
||||
|
||||
@@ -86,7 +89,6 @@ namespace Barotrauma
|
||||
intensityUpdateTimer = 0.0f;
|
||||
CalculateCurrentIntensity(0.0f);
|
||||
currentIntensity = targetIntensity;
|
||||
eventThreshold = settings.DefaultEventThreshold;
|
||||
eventCoolDown = 0.0f;
|
||||
}
|
||||
|
||||
@@ -114,6 +116,10 @@ namespace Barotrauma
|
||||
{
|
||||
settings = suitableSettings[Rand.Int(suitableSettings.Count, Rand.RandSync.Server)];
|
||||
}
|
||||
if (settings != null)
|
||||
{
|
||||
eventThreshold = settings.DefaultEventThreshold;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<ContentFile> GetFilesToPreload()
|
||||
@@ -320,6 +326,14 @@ namespace Barotrauma
|
||||
//(the intensity is used for controlling the background music)
|
||||
CalculateCurrentIntensity(deltaTime);
|
||||
|
||||
#if DEBUG && SERVER
|
||||
if (DateTime.Now > nextIntensityLogTime)
|
||||
{
|
||||
DebugConsole.NewMessage("EventManager intensity: " + (int)Math.Round(currentIntensity * 100) + " %");
|
||||
nextIntensityLogTime = DateTime.Now + new TimeSpan(0, minutes: 1, seconds: 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (isClient) { return; }
|
||||
|
||||
roundDuration += deltaTime;
|
||||
@@ -331,6 +345,9 @@ namespace Barotrauma
|
||||
if (settings == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Could not select EventManager settings. Disabling EventManager for the round...");
|
||||
#if SERVER
|
||||
GameMain.Server?.SendChatMessage("Could not select EventManager settings. Disabling EventManager for the round...", Networking.ChatMessageType.Error);
|
||||
#endif
|
||||
Enabled = false;
|
||||
return;
|
||||
}
|
||||
@@ -393,19 +410,20 @@ namespace Barotrauma
|
||||
int characterCount = 0;
|
||||
foreach (Character character in Character.CharacterList)
|
||||
{
|
||||
if (character.IsDead) continue;
|
||||
#if CLIENT
|
||||
if ((character.AIController is HumanAIController || character.IsRemotePlayer || character == Character.Controlled) &&
|
||||
(GameMain.Client?.Character == null || GameMain.Client.Character.TeamID == character.TeamID))
|
||||
if (character.IsDead || character.TeamID == Character.TeamType.FriendlyNPC) { continue; }
|
||||
if (character.AIController is HumanAIController || character.IsRemotePlayer)
|
||||
{
|
||||
avgCrewHealth += character.Vitality / character.MaxVitality * (character.IsUnconscious ? 0.5f : 1.0f);
|
||||
characterCount++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (characterCount > 0)
|
||||
{
|
||||
avgCrewHealth = avgCrewHealth / characterCount;
|
||||
avgCrewHealth /= characterCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
avgCrewHealth = 0.5f;
|
||||
}
|
||||
|
||||
// enemy amount --------------------------------------------------------
|
||||
|
||||
@@ -21,9 +21,6 @@ namespace Barotrauma
|
||||
|
||||
public readonly float EventCooldown = 360.0f;
|
||||
|
||||
public readonly float MinEventDifficulty = 0.0f;
|
||||
public readonly float MaxEventDifficulty = 100.0f;
|
||||
|
||||
public readonly float MinLevelDifficulty = 0.0f;
|
||||
public readonly float MaxLevelDifficulty = 100.0f;
|
||||
|
||||
@@ -77,9 +74,6 @@ namespace Barotrauma
|
||||
DefaultEventThreshold = element.GetAttributeFloat("DefaultEventThreshold", 0.2f);
|
||||
EventCooldown = element.GetAttributeFloat("EventCooldown", 360.0f);
|
||||
|
||||
MinEventDifficulty = element.GetAttributeFloat("MinEventDifficulty", 0.0f);
|
||||
MaxEventDifficulty = element.GetAttributeFloat("MaxEventDifficulty", 100.0f);
|
||||
|
||||
MinLevelDifficulty = element.GetAttributeFloat("MinLevelDifficulty", 0.0f);
|
||||
MaxLevelDifficulty = element.GetAttributeFloat("MaxLevelDifficulty", 100.0f);
|
||||
}
|
||||
|
||||
@@ -261,32 +261,43 @@ namespace Barotrauma.Items.Components
|
||||
if (picker.Inventory == null) { return; }
|
||||
|
||||
item.Submarine = picker.Submarine;
|
||||
|
||||
if (item.body != null)
|
||||
{
|
||||
item.body.ResetDynamics();
|
||||
Limb heldHand, arm;
|
||||
if (picker.Inventory.IsInLimbSlot(item, InvSlotType.LeftHand))
|
||||
if (item.body.Removed)
|
||||
{
|
||||
heldHand = picker.AnimController.GetLimb(LimbType.LeftHand);
|
||||
arm = picker.AnimController.GetLimb(LimbType.LeftArm);
|
||||
DebugConsole.ThrowError(
|
||||
"Failed to drop the Holdable component of the item \"" + item.Name + "\" (body has been removed"
|
||||
+ (item.Removed ? ", item has been removed)" : ")"));
|
||||
}
|
||||
else
|
||||
{
|
||||
heldHand = picker.AnimController.GetLimb(LimbType.RightHand);
|
||||
arm = picker.AnimController.GetLimb(LimbType.RightArm);
|
||||
item.body.ResetDynamics();
|
||||
Limb heldHand, arm;
|
||||
if (picker.Inventory.IsInLimbSlot(item, InvSlotType.LeftHand))
|
||||
{
|
||||
heldHand = picker.AnimController.GetLimb(LimbType.LeftHand);
|
||||
arm = picker.AnimController.GetLimb(LimbType.LeftArm);
|
||||
}
|
||||
else
|
||||
{
|
||||
heldHand = picker.AnimController.GetLimb(LimbType.RightHand);
|
||||
arm = picker.AnimController.GetLimb(LimbType.RightArm);
|
||||
}
|
||||
if (heldHand != null && arm != null)
|
||||
{
|
||||
//hand simPosition is actually in the wrist so need to move the item out from it slightly
|
||||
Vector2 diff = new Vector2(
|
||||
(heldHand.SimPosition.X - arm.SimPosition.X) / 2f,
|
||||
(heldHand.SimPosition.Y - arm.SimPosition.Y) / 2.5f);
|
||||
item.SetTransform(heldHand.SimPosition + diff, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetTransform(picker.SimPosition, 0.0f);
|
||||
}
|
||||
}
|
||||
if (heldHand != null && arm != null)
|
||||
{
|
||||
//hand simPosition is actually in the wrist so need to move the item out from it slightly
|
||||
Vector2 diff = new Vector2(
|
||||
(heldHand.SimPosition.X - arm.SimPosition.X) / 2f,
|
||||
(heldHand.SimPosition.Y - arm.SimPosition.Y) / 2.5f);
|
||||
item.SetTransform(heldHand.SimPosition + diff, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetTransform(picker.SimPosition, 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
picker.DeselectItem(item);
|
||||
|
||||
@@ -204,14 +204,14 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (picker == null || picker.Inventory == null)
|
||||
{
|
||||
if (item.ParentInventory != null && item.ParentInventory.Owner != null)
|
||||
if (item.ParentInventory != null && item.ParentInventory.Owner != null && !item.ParentInventory.Owner.Removed)
|
||||
{
|
||||
bodyDropPos = item.ParentInventory.Owner.SimPosition;
|
||||
|
||||
if (item.body != null) item.body.ResetDynamics();
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!picker.Removed)
|
||||
{
|
||||
DropConnectedWires(picker);
|
||||
|
||||
@@ -224,9 +224,18 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (item.body != null && !item.body.Enabled)
|
||||
{
|
||||
item.body.ResetDynamics();
|
||||
item.SetTransform(bodyDropPos, 0.0f);
|
||||
item.body.Enabled = true;
|
||||
if (item.body.Removed)
|
||||
{
|
||||
DebugConsole.ThrowError(
|
||||
"Failed to drop the Pickable component of the item \"" + item.Name + "\" (body has been removed"
|
||||
+ (item.Removed ? ", item has been removed)" : ")"));
|
||||
}
|
||||
else
|
||||
{
|
||||
item.body.ResetDynamics();
|
||||
item.SetTransform(bodyDropPos, 0.0f);
|
||||
item.body.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,22 +101,14 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 currForce = new Vector2(force * maxForce * forceMultiplier * voltageFactor, 0.0f);
|
||||
//less effective when in a bad condition
|
||||
currForce *= MathHelper.Lerp(0.5f, 2.0f, item.Condition / item.MaxCondition);
|
||||
|
||||
item.Submarine.ApplyForce(currForce);
|
||||
|
||||
UpdatePropellerDamage(deltaTime);
|
||||
|
||||
if (item.AiTarget != null)
|
||||
{
|
||||
var aiTarget = item.AiTarget;
|
||||
aiTarget.SoundRange = MathHelper.Lerp(aiTarget.MinSoundRange, aiTarget.MaxSoundRange, Math.Min(currForce.Length() * forceMultiplier / maxForce, 1.0f));
|
||||
}
|
||||
if (item.CurrentHull != null)
|
||||
{
|
||||
var aiTarget = item.CurrentHull.AiTarget;
|
||||
float noise = MathHelper.Lerp(aiTarget.MinSoundRange, aiTarget.MaxSoundRange, Math.Min(currForce.Length() * forceMultiplier / maxForce, 1.0f));
|
||||
aiTarget.SoundRange = Math.Max(noise, aiTarget.SoundRange);
|
||||
}
|
||||
float maxChangeSpeed = 0.5f;
|
||||
float modifier = 2;
|
||||
float noise = currForce.Length() * forceMultiplier * modifier / maxForce;
|
||||
float min = Math.Max(1 - maxChangeSpeed, 0);
|
||||
float max = 1 + maxChangeSpeed;
|
||||
UpdateAITargets(Math.Clamp(noise, min, max), deltaTime);
|
||||
#if CLIENT
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
@@ -128,6 +120,19 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAITargets(float increaseSpeed, float deltaTime)
|
||||
{
|
||||
if (item.AiTarget != null)
|
||||
{
|
||||
item.AiTarget.IncreaseSoundRange(deltaTime, increaseSpeed);
|
||||
if (item.CurrentHull != null && item.CurrentHull.AiTarget != null)
|
||||
{
|
||||
// It's possible that some othe item increases the hull's soundrange more than the engine.
|
||||
item.CurrentHull.AiTarget.SoundRange = Math.Max(item.CurrentHull.AiTarget.SoundRange, item.AiTarget.SoundRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePropellerDamage(float deltaTime)
|
||||
{
|
||||
damageTimer += deltaTime;
|
||||
|
||||
@@ -1279,10 +1279,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (!isActive) { return; }
|
||||
|
||||
aiTarget?.Update(deltaTime);
|
||||
|
||||
if (!isActive) { return; }
|
||||
|
||||
ApplyStatusEffects(ActionType.Always, deltaTime, character: (parentInventory as CharacterInventory)?.Owner as Character);
|
||||
|
||||
for (int i = 0; i < updateableComponents.Count; i++)
|
||||
@@ -1988,7 +1988,9 @@ namespace Barotrauma
|
||||
{
|
||||
if (body.Removed)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to drop the item \"" + Name + "\" (body has been removed).");
|
||||
DebugConsole.ThrowError(
|
||||
"Failed to drop the item \"" + Name + "\" (body has been removed"
|
||||
+ (Removed ? ", item has been removed)" : ")"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -60,7 +60,6 @@ namespace Barotrauma.Networking
|
||||
|
||||
QUERY_STARTGAME, //ask the clients whether they're ready to start
|
||||
STARTGAME, //start a new round
|
||||
STARTGAMEFINALIZE, //finalize round initialization
|
||||
ENDGAME,
|
||||
|
||||
TRAITOR_MESSAGE,
|
||||
|
||||
Reference in New Issue
Block a user