- 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

View File

@@ -7,7 +7,7 @@
pickdistance="150"
price="50"
canuseonself="true"
description="A syringe filled with a potent general-purpose medical compound.">
description="Injection is often a much more effective method of administering drugs than taking them orally.">
<Sprite texture ="med.png" sourcerect="0,0,25,5" depth="0.6"/>

View File

@@ -1151,12 +1151,13 @@ namespace Barotrauma
case LimbType.RightThigh:
case LimbType.RightLeg:
case LimbType.RightFoot:
mirror = true;
flipAngle = true;
wrapAngle = true;
mirror = Crouching && !inWater;
flipAngle = (limb.DoesFlip || Crouching) && !inWater;
wrapAngle = !inWater;
break;
default:
flipAngle = limb.DoesFlip;
flipAngle = limb.DoesFlip && !inWater;
wrapAngle = !inWater;
break;
}

View File

@@ -429,6 +429,13 @@ namespace Barotrauma
case "showaitargets":
AITarget.ShowAITargets = !AITarget.ShowAITargets;
break;
case "killmonsters":
foreach (Character c in Character.CharacterList)
{
if (!(c.AIController is EnemyAIController)) continue;
c.AddDamage(CauseOfDeath.Damage, 10000.0f, null);
}
break;
case "sendrandomdata":
int messageCount = 1;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -46,6 +46,9 @@ namespace Barotrauma
private Inventory parentInventory;
//a dictionary containing lists of the status effects in all the components of the item
private Dictionary<ActionType, List<StatusEffect>> statusEffectLists;
public readonly Dictionary<string, ObjectProperty> properties;
public Dictionary<string, ObjectProperty> ObjectProperties
{
@@ -350,7 +353,31 @@ namespace Barotrauma
if (ic == null) break;
components.Add(ic);
//if (!string.IsNullOrWhiteSpace(ic.Msg)) highlightText.Add(ic.Msg);
if (ic.statusEffectLists == null) continue;
if (statusEffectLists == null)
statusEffectLists = new Dictionary<ActionType, List<StatusEffect>>();
//go through all the status effects of the component
//and add them to the corresponding statuseffect list
foreach (List<StatusEffect> componentEffectList in ic.statusEffectLists.Values)
{
ActionType actionType = componentEffectList.First().type;
List<StatusEffect> statusEffectList;
if (!statusEffectLists.TryGetValue(actionType, out statusEffectList))
{
statusEffectList = new List<StatusEffect>();
statusEffectLists.Add(actionType, statusEffectList);
}
foreach (StatusEffect effect in componentEffectList)
{
statusEffectList.Add(effect);
}
}
break;
}
@@ -496,12 +523,14 @@ namespace Barotrauma
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null)
{
foreach (ItemComponent ic in components)
if (statusEffectLists == null) return;
List<StatusEffect> statusEffects;
if (!statusEffectLists.TryGetValue(type, out statusEffects)) return;
foreach (StatusEffect effect in statusEffects)
{
foreach (StatusEffect effect in ic.statusEffects)
{
ApplyStatusEffect(effect, type, deltaTime, character);
}
ApplyStatusEffect(effect, type, deltaTime, character);
}
}

View File

@@ -245,28 +245,33 @@ namespace Barotrauma
if (isHorizontal)
{
pos.X += Math.Sign(flowForce.X);
pos.Y = MathHelper.Clamp((higherSurface+lowerSurface)/2.0f, rect.Y - rect.Height, rect.Y);
pos.Y = MathHelper.Clamp((higherSurface + lowerSurface) / 2.0f, rect.Y - rect.Height, rect.Y);
Vector2 velocity = new Vector2(
MathHelper.Clamp(flowForce.X, -5000.0f, 5000.0f) * Rand.Range(0.5f, 0.7f),
flowForce.Y * Rand.Range(0.5f, 0.7f));
var particle = GameMain.ParticleManager.CreateParticle(
"watersplash",
(Submarine.Loaded==null ? pos : pos + Submarine.Loaded.Position) - Vector2.UnitY * Rand.Range(0.0f, 10.0f),
(Submarine.Loaded == null ? pos : pos + Submarine.Loaded.Position) - Vector2.UnitY * Rand.Range(0.0f, 10.0f),
velocity);
if (particle != null)
{
particle.Size = particle.Size * Math.Min(Math.Abs(flowForce.X / 1000.0f),5.0f);
particle.Size = particle.Size * Math.Min(Math.Abs(flowForce.X / 1000.0f), 5.0f);
}
pos.Y = Rand.Range(lowerSurface, rect.Y - rect.Height);
GameMain.ParticleManager.CreateParticle(
"bubbles",
Submarine.Loaded==null ? pos : pos + Submarine.Loaded.Position,
flowForce / 200.0f);
if (Math.Abs(flowForce.X) > 300.0f)
{
pos.X += Math.Sign(flowForce.X) * 10.0f;
pos.Y = Rand.Range(lowerSurface, rect.Y - rect.Height);
GameMain.ParticleManager.CreateParticle(
"bubbles",
Submarine.Loaded == null ? pos : pos + Submarine.Loaded.Position,
flowForce / 10.0f);
}
}
else
{