Merge branch 'master' of https://github.com/Regalis11/Barotrauma.git
This commit is contained in:
@@ -286,6 +286,43 @@ namespace Barotrauma.Items.Components
|
||||
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
|
||||
ParseMsg();
|
||||
|
||||
string inheritRequiredSkillsFrom = element.GetAttributeString("inheritrequiredskillsfrom", "");
|
||||
if (!string.IsNullOrEmpty(inheritRequiredSkillsFrom))
|
||||
{
|
||||
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.");
|
||||
}
|
||||
else
|
||||
{
|
||||
requiredSkills = component.requiredSkills;
|
||||
}
|
||||
}
|
||||
|
||||
string inheritStatusEffectsFrom = element.GetAttributeString("inheritstatuseffectsfrom", "");
|
||||
if (!string.IsNullOrEmpty(inheritStatusEffectsFrom))
|
||||
{
|
||||
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.");
|
||||
}
|
||||
else if (component.statusEffectLists != null)
|
||||
{
|
||||
statusEffectLists ??= new Dictionary<ActionType, List<StatusEffect>>();
|
||||
foreach (KeyValuePair<ActionType, List<StatusEffect>> kvp in component.statusEffectLists)
|
||||
{
|
||||
if (!statusEffectLists.TryGetValue(kvp.Key, out List<StatusEffect> effectList))
|
||||
{
|
||||
effectList = new List<StatusEffect>();
|
||||
statusEffectLists.Add(kvp.Key, effectList);
|
||||
}
|
||||
effectList.AddRange(kvp.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
@@ -317,19 +354,8 @@ namespace Barotrauma.Items.Components
|
||||
requiredSkills.Add(new Skill(skillIdentifier, subElement.GetAttributeInt("level", 0)));
|
||||
break;
|
||||
case "statuseffect":
|
||||
var statusEffect = StatusEffect.Load(subElement, item.Name);
|
||||
|
||||
if (statusEffectLists == null) statusEffectLists = new Dictionary<ActionType, List<StatusEffect>>();
|
||||
|
||||
List<StatusEffect> effectList;
|
||||
if (!statusEffectLists.TryGetValue(statusEffect.type, out effectList))
|
||||
{
|
||||
effectList = new List<StatusEffect>();
|
||||
statusEffectLists.Add(statusEffect.type, effectList);
|
||||
}
|
||||
|
||||
effectList.Add(statusEffect);
|
||||
|
||||
statusEffectLists ??= new Dictionary<ActionType, List<StatusEffect>>();
|
||||
LoadStatusEffect(subElement);
|
||||
break;
|
||||
default:
|
||||
if (LoadElemProjSpecific(subElement)) { break; }
|
||||
@@ -344,6 +370,17 @@ namespace Barotrauma.Items.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LoadStatusEffect(XElement subElement)
|
||||
{
|
||||
var statusEffect = StatusEffect.Load(subElement, item.Name);
|
||||
if (!statusEffectLists.TryGetValue(statusEffect.type, out List<StatusEffect> effectList))
|
||||
{
|
||||
effectList = new List<StatusEffect>();
|
||||
statusEffectLists.Add(statusEffect.type, effectList);
|
||||
}
|
||||
effectList.Add(statusEffect);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetActiveState(bool isActive)
|
||||
@@ -401,6 +438,8 @@ namespace Barotrauma.Items.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool UpdateWhenInactive => false;
|
||||
|
||||
//called when isActive is true and condition > 0.0f
|
||||
public virtual void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
@@ -545,6 +584,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
GUI.RemoveFromUpdateList(GuiFrame, true);
|
||||
GuiFrame.RectTransform.Parent = null;
|
||||
GuiFrame = null;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -812,7 +852,10 @@ namespace Barotrauma.Items.Components
|
||||
foreach (ItemComponent ic in item.Components)
|
||||
{
|
||||
if (ic.statusEffectLists == null || !ic.statusEffectLists.TryGetValue(ActionType.OnBroken, out List<StatusEffect> brokenEffects)) { continue; }
|
||||
brokenEffects.ForEach(e => e.SetUser(user));
|
||||
foreach (var brokenEffect in brokenEffects)
|
||||
{
|
||||
brokenEffect.SetUser(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,7 +1064,8 @@ namespace Barotrauma.Items.Components
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
return 1.0f;
|
||||
// Prefer items with the same identifier as the contained items'
|
||||
return container.ContainsItemsWithSameIdentifier(i) ? 1.0f : 0.5f;
|
||||
}
|
||||
};
|
||||
containObjective.Abandoned += () => aiController.IgnoredItems.Add(container.Item);
|
||||
|
||||
Reference in New Issue
Block a user