- changes to the logic for distributing oxygen through vents: the oxygen generator pushes more oxygen to larger rooms

- bugfixes in HumanoidAnimController.Flip()
- item/itemcomponent statuseffects are stored in a dictionary with the actiontype as a key, so the item doesn't have to iterate over all the components and all their statuseffects
- gap bubble particle tweaking
This commit is contained in:
Regalis
2016-03-29 17:57:05 +03:00
parent 23f1623562
commit 3ac8139fc7
10 changed files with 129 additions and 62 deletions
@@ -100,12 +100,7 @@ namespace Barotrauma.Items.Components
DropConnectedWires(picker);
ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
//foreach (StatusEffect effect in item.Prefab.statusEffects)
//{
// effect.OnPicked(picker, null);
//}
return true;
}
@@ -189,10 +189,7 @@ namespace Barotrauma.Items.Components
{
targetItem.IsHighlighted = true;
foreach (StatusEffect effect in statusEffects)
{
effect.Apply(ActionType.OnUse, deltaTime, item, targetItem.AllPropertyObjects);
}
ApplyStatusEffects(ActionType.OnUse, targetItem.AllPropertyObjects, deltaTime);
}
return true;
@@ -53,7 +53,7 @@ namespace Barotrauma.Items.Components
public bool WasUsed;
public List<StatusEffect> statusEffects;
public readonly Dictionary<ActionType, List<StatusEffect>> statusEffectLists;
protected bool updated;
@@ -184,8 +184,6 @@ namespace Barotrauma.Items.Components
sounds = new Dictionary<ActionType, List<ItemSound>>();
statusEffects = new List<StatusEffect>();
SelectKey = InputType.Select;
try
@@ -230,7 +228,19 @@ namespace Barotrauma.Items.Components
requiredSkills.Add(new Skill(skillName, ToolBox.GetAttributeInt(subElement, "level", 0)));
break;
case "statuseffect":
statusEffects.Add(StatusEffect.Load(subElement));
var statusEffect = StatusEffect.Load(subElement);
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);
break;
case "guiframe":
string rectStr = ToolBox.GetAttributeString(subElement, "rect", "0.0,0.0,0.5,0.5");
@@ -597,19 +607,27 @@ namespace Barotrauma.Items.Components
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null)
{
if (statusEffectLists == null) return;
List<StatusEffect> statusEffects;
if (!statusEffectLists.TryGetValue(type, out statusEffects)) return;
foreach (StatusEffect effect in statusEffects)
{
if (effect.type != type) continue;
item.ApplyStatusEffect(effect, type, deltaTime, character);
}
}
public void ApplyStatusEffects(ActionType type, float deltaTime, IPropertyObject target)
public void ApplyStatusEffects(ActionType type, List<IPropertyObject> targets, float deltaTime)
{
if (statusEffectLists == null) return;
List<StatusEffect> statusEffects;
if (!statusEffectLists.TryGetValue(type, out statusEffects)) return;
foreach (StatusEffect effect in statusEffects)
{
if (effect.type != type) continue;
effect.Apply(type, deltaTime, item, target);
effect.Apply(type, deltaTime, item, targets);
}
}
@@ -115,15 +115,19 @@ namespace Barotrauma.Items.Components
foreach (FabricableItem fi in fabricableItems)
{
Color color = ((itemList.CountChildren % 2) == 0) ? Color.Transparent : Color.Black*0.3f;
GUITextBlock textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), fi.TargetItem.Name,
new GUITextBlock(
new Rectangle(0, 0, 0, 25), fi.TargetItem.Name,
color, Color.White,
Alignment.Left, Alignment.Left, null, itemList);
textBlock.UserData = fi;
textBlock.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
textBlock.HoverColor = Color.Gold * 0.2f;
textBlock.SelectedColor = Color.Gold * 0.5f;
Alignment.Left, Alignment.Left, null, itemList)
{
UserData = fi,
Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f),
HoverColor = Color.Gold * 0.2f,
SelectedColor = Color.Gold * 0.5f,
ToolTip = fi.TargetItem.Description
};
}
}
@@ -135,7 +139,7 @@ namespace Barotrauma.Items.Components
if (selectedItemFrame != null) GuiFrame.RemoveChild(selectedItemFrame);
//int width = 200, height = 150;
selectedItemFrame = new GUIFrame(new Rectangle(0,0,(int)(GuiFrame.Rect.Width*0.4f),250), Color.Black*0.8f, Alignment.CenterY | Alignment.Right, null, GuiFrame);
selectedItemFrame = new GUIFrame(new Rectangle(0, 0, (int)(GuiFrame.Rect.Width * 0.4f), 250), Color.Black * 0.8f, Alignment.CenterY | Alignment.Right, null, GuiFrame);
selectedItemFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
@@ -170,7 +174,7 @@ namespace Barotrauma.Items.Components
if (!inadequateSkills.Any())
{
text = "Required items:\n";
foreach (Tuple<ItemPrefab,int> ip in targetItem.RequiredItems)
foreach (Tuple<ItemPrefab, int> ip in targetItem.RequiredItems)
{
text += " - " + ip.Item1.Name + " x"+ip.Item2+"\n";
}
@@ -204,6 +208,16 @@ namespace Barotrauma.Items.Components
return true;
}
public override bool Select(Character character)
{
if (itemList.Selected != null)
{
SelectItem(itemList.Selected, itemList.Selected.UserData);
}
return base.Select(character);
}
public override bool Pick(Character picker)
{
return (picker != null);
@@ -224,16 +238,6 @@ namespace Barotrauma.Items.Components
item.NewComponentEvent(this, true, true);
}
//listElement.Color = Color.Green;
//itemList.Enabled = false;
//activateButton.Text = "Cancel";
//fabricatedItem = obj as FabricableItem;
//IsActive = true;
//timeUntilReady = fabricatedItem.RequiredTime;
return true;
}
@@ -18,6 +18,8 @@ namespace Barotrauma.Items.Components
List<Vent> ventList;
private float totalHullVolume;
public bool IsRunning()
{
return (running && item.Condition>0.0f);
@@ -98,18 +100,27 @@ namespace Barotrauma.Items.Components
if (linkedItem == null) continue;
Vent vent = linkedItem.GetComponent<Vent>();
if (vent != null) ventList.Add(vent);
if (vent == null) continue;
ventList.Add(vent);
if (linkedItem.CurrentHull!=null) totalHullVolume += linkedItem.CurrentHull.FullVolume;
}
}
public override void OnMapLoaded()
{
GetVents();
}
private void UpdateVents(float deltaOxygen)
{
if (!ventList.Any()) return;
if (!ventList.Any() || totalHullVolume == 0.0f) return;
deltaOxygen = deltaOxygen / ventList.Count;
foreach (Vent v in ventList)
{
v.OxygenFlow = deltaOxygen;
if (v.Item.CurrentHull == null) continue;
v.OxygenFlow = deltaOxygen * (v.Item.CurrentHull.FullVolume / totalHullVolume);
v.IsActive = true;
}
}