Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop
This commit is contained in:
@@ -62,12 +62,19 @@ namespace Barotrauma.Items.Components
|
||||
set
|
||||
{
|
||||
if (parent == value) { return; }
|
||||
if (parent != null) { parent.OnActiveStateChanged -= SetActiveState; }
|
||||
if (value != null) { value.OnActiveStateChanged += SetActiveState; }
|
||||
if (InheritParentIsActive)
|
||||
{
|
||||
if (parent != null) { parent.OnActiveStateChanged -= SetActiveState; }
|
||||
if (value != null) { value.OnActiveStateChanged += SetActiveState; }
|
||||
}
|
||||
parent = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serialize(true, IsPropertySaveable.No, description: "If this is a child component of another component, should this component inherit the IsActive state of the parent?")]
|
||||
public bool InheritParentIsActive { get; set; }
|
||||
|
||||
public readonly ContentXElement originalElement;
|
||||
|
||||
protected const float CorrectionDelay = 1.0f;
|
||||
@@ -79,6 +86,12 @@ namespace Barotrauma.Items.Components
|
||||
/// </summary>
|
||||
public virtual bool DontTransferInventoryBetweenSubs => false;
|
||||
|
||||
/// <summary>
|
||||
/// If enabled, the items inside any of the item containers on this item cannot be sold at an outpost.
|
||||
/// Use in similar cases as <see cref="DontTransferInventoryBetweenSubs"/>.
|
||||
/// </summary>
|
||||
public virtual bool DisallowSellingItemsFromContainer => false;
|
||||
|
||||
[Editable, Serialize(0.0f, IsPropertySaveable.No, description: "How long it takes to pick up the item (in seconds).")]
|
||||
public float PickingTime
|
||||
{
|
||||
@@ -293,7 +306,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid select key in " + element + "!", e);
|
||||
DebugConsole.ThrowError("Invalid select key in " + element + "!", e,
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
|
||||
PickKey = InputType.Select;
|
||||
@@ -306,7 +320,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid pick key in " + element + "!", e);
|
||||
DebugConsole.ThrowError("Invalid pick key in " + element + "!", e,
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
|
||||
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
|
||||
@@ -318,7 +333,8 @@ namespace Barotrauma.Items.Components
|
||||
var component = item.Components.Find(ic => ic.Name.Equals(inheritRequiredSkillsFrom, StringComparison.OrdinalIgnoreCase));
|
||||
if (component == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in item \"{item.Name}\" - component \"{name}\" is set to inherit its required skills from \"{inheritRequiredSkillsFrom}\", but a component of that type couldn't be found.");
|
||||
DebugConsole.ThrowError($"Error in item \"{item.Name}\" - component \"{name}\" is set to inherit its required skills from \"{inheritRequiredSkillsFrom}\", but a component of that type couldn't be found.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -333,7 +349,8 @@ namespace Barotrauma.Items.Components
|
||||
var component = item.Components.Find(ic => ic.Name.Equals(inheritStatusEffectsFrom, StringComparison.OrdinalIgnoreCase));
|
||||
if (component == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in item \"{item.Name}\" - component \"{name}\" is set to inherit its StatusEffects from \"{inheritStatusEffectsFrom}\", but a component of that type couldn't be found.");
|
||||
DebugConsole.ThrowError($"Error in item \"{item.Name}\" - component \"{name}\" is set to inherit its StatusEffects from \"{inheritStatusEffectsFrom}\", but a component of that type couldn't be found.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
else if (component.statusEffectLists != null)
|
||||
{
|
||||
@@ -368,7 +385,8 @@ namespace Barotrauma.Items.Components
|
||||
case "requiredskills":
|
||||
if (subElement.GetAttribute("name") != null)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFilePath + "\" - skill requirement in component " + GetType().ToString() + " should use a skill identifier instead of the name of the skill.");
|
||||
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFilePath + "\" - skill requirement in component " + GetType().ToString() + " should use a skill identifier instead of the name of the skill.",
|
||||
contentPackage: element.ContentPackage);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -385,8 +403,11 @@ namespace Barotrauma.Items.Components
|
||||
if (ic == null) { break; }
|
||||
|
||||
ic.Parent = this;
|
||||
ic.IsActive = isActive;
|
||||
OnActiveStateChanged += ic.SetActiveState;
|
||||
if (ic.InheritParentIsActive)
|
||||
{
|
||||
ic.IsActive = isActive;
|
||||
OnActiveStateChanged += ic.SetActiveState;
|
||||
}
|
||||
|
||||
item.AddComponent(ic);
|
||||
break;
|
||||
@@ -434,7 +455,8 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else if (!allowEmpty)
|
||||
{
|
||||
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFilePath + "\" - component " + GetType().ToString() + " requires an item with no identifiers.");
|
||||
DebugConsole.ThrowError("Error in item config \"" + item.ConfigFilePath + "\" - component " + GetType().ToString() + " requires an item with no identifiers.",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -976,7 +998,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (errorMessages)
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not find the component \"{typeName}\" ({item.Prefab.ContentFile.Path})");
|
||||
DebugConsole.ThrowError($"Could not find the component \"{typeName}\" ({item.Prefab.ContentFile.Path})",
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -985,7 +1008,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (errorMessages)
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not find the component \"{typeName}\" ({item.Prefab.ContentFile.Path})", e);
|
||||
DebugConsole.ThrowError($"Could not find the component \"{typeName}\" ({item.Prefab.ContentFile.Path})", e,
|
||||
contentPackage: element.ContentPackage);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -998,14 +1022,16 @@ namespace Barotrauma.Items.Components
|
||||
if (constructor == null)
|
||||
{
|
||||
DebugConsole.ThrowError(
|
||||
$"Could not find the constructor of the component \"{typeName}\" ({item.Prefab.ContentFile.Path})");
|
||||
$"Could not find the constructor of the component \"{typeName}\" ({item.Prefab.ContentFile.Path})",
|
||||
contentPackage: element.ContentPackage);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError(
|
||||
$"Could not find the constructor of the component \"{typeName}\" ({item.Prefab.ContentFile.Path})", e);
|
||||
$"Could not find the constructor of the component \"{typeName}\" ({item.Prefab.ContentFile.Path})", e,
|
||||
contentPackage: element.ContentPackage);
|
||||
return null;
|
||||
}
|
||||
ItemComponent ic = null;
|
||||
@@ -1018,7 +1044,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error while loading component of the type {type}.", e.InnerException);
|
||||
DebugConsole.ThrowError($"Error while loading component of the type {type}.", e.InnerException, contentPackage: element.ContentPackage);
|
||||
GameAnalyticsManager.AddErrorEventOnce(
|
||||
$"ItemComponent.Load:TargetInvocationException{item.Name}{element.Name}",
|
||||
GameAnalyticsManager.ErrorSeverity.Error,
|
||||
|
||||
Reference in New Issue
Block a user