Medical items, improved falldamage, "power on" sounds
This commit is contained in:
@@ -90,6 +90,13 @@ namespace Subsurface
|
||||
set { canBeSelected = value; }
|
||||
}
|
||||
|
||||
[HasDefaultValue(false, false)]
|
||||
public bool DeleteOnUse
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Item Item
|
||||
{
|
||||
get { return item; }
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
pt.powerLoad += (fullLoad - pt.powerLoad) / inertia;
|
||||
pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia;
|
||||
pt.Item.SendSignal("",
|
||||
"power", fullPower / Math.Max(fullLoad, 1.0f));
|
||||
pt.Item.SendSignal("", "power", fullPower / Math.Max(fullLoad, 1.0f));
|
||||
if (-pt.currPowerConsumption > pt.powerLoad * 2.0f) pt.item.Condition = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,19 @@ namespace Subsurface.Items.Components
|
||||
//negative values mean that the item is providing power to connected items
|
||||
protected float currPowerConsumption;
|
||||
|
||||
//the amount of power available for the item through connected items
|
||||
//current voltage of the item (load / power)
|
||||
protected float voltage;
|
||||
|
||||
//the amount of power required for the item to work
|
||||
//the minimum voltage required for the item to work
|
||||
protected float minVoltage;
|
||||
|
||||
//the maximum amount of power the item can draw from connected items
|
||||
protected float powerConsumption;
|
||||
|
||||
private bool powerOnSoundPlayed;
|
||||
|
||||
private static Sound powerOnSound;
|
||||
|
||||
[Editable, HasDefaultValue(0.5f, true)]
|
||||
public float MinVoltage
|
||||
{
|
||||
@@ -68,14 +72,28 @@ namespace Subsurface.Items.Components
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (currPowerConsumption == 0.0f) return;
|
||||
if (voltage > minVoltage) ApplyStatusEffects(ActionType.OnActive, deltaTime);
|
||||
if (voltage > minVoltage)
|
||||
{
|
||||
if (!powerOnSoundPlayed)
|
||||
{
|
||||
powerOnSound.Play(1.0f, 600.0f, item.Position);
|
||||
powerOnSoundPlayed = true;
|
||||
}
|
||||
ApplyStatusEffects(ActionType.OnActive, deltaTime);
|
||||
}
|
||||
else if (voltage < 0.1f)
|
||||
{
|
||||
powerOnSoundPlayed = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Powered(Item item, XElement element)
|
||||
: base(item, element)
|
||||
{
|
||||
//minVoltage = ToolBox.GetAttributeFloat(element, "minvoltage", 10.0f);
|
||||
//powerConsumption = ToolBox.GetAttributeFloat(element, "powerconsumption", 15.0f);
|
||||
if (powerOnSound==null)
|
||||
{
|
||||
powerOnSound = Sound.Load("Content/Items/Electricity/powerOn.ogg");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user