Medical items, improved falldamage, "power on" sounds
This commit is contained in:
@@ -172,6 +172,13 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public float Bleeding
|
||||
{
|
||||
get { return bleeding; }
|
||||
set { bleeding = value; }
|
||||
}
|
||||
|
||||
|
||||
//public float Blood
|
||||
//{
|
||||
// get { return blood; }
|
||||
@@ -575,7 +582,7 @@ namespace Subsurface
|
||||
Body body = Submarine.PickBody(AnimController.limbs[0].SimPosition, mouseSimPos);
|
||||
Structure structure = null;
|
||||
if (body != null) structure = body.UserData as Structure;
|
||||
if (structure!=null)
|
||||
if (structure != null)
|
||||
{
|
||||
if (!structure.CastShadow && moveCam)
|
||||
{
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace Subsurface
|
||||
body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionMisc;
|
||||
}
|
||||
|
||||
impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 20.0f);
|
||||
impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 8.0f);
|
||||
|
||||
body.UserData = this;
|
||||
|
||||
|
||||
@@ -312,7 +312,17 @@ namespace Subsurface
|
||||
private void CalculateImpact(Fixture f1, Fixture f2, Contact contact)
|
||||
{
|
||||
Vector2 normal = contact.Manifold.LocalNormal;
|
||||
float impact = Vector2.Dot(f1.Body.LinearVelocity, -normal);
|
||||
|
||||
Vector2 avgVelocity = Vector2.Zero;
|
||||
foreach (Limb limb in limbs)
|
||||
{
|
||||
avgVelocity += limb.LinearVelocity;
|
||||
}
|
||||
|
||||
avgVelocity = avgVelocity / limbs.Count();
|
||||
|
||||
|
||||
float impact = Vector2.Dot((f1.Body.LinearVelocity + avgVelocity)/2.0f, -normal);
|
||||
|
||||
Limb l = (Limb)f1.Body.UserData;
|
||||
|
||||
|
||||
@@ -76,12 +76,12 @@
|
||||
<!-- body to left leg -->
|
||||
<joint limb1="12" limb1anchor="0,-1" limb2="6" limb2anchor="0,14" lowerlimit="-30" upperlimit="140"/>
|
||||
<joint limb1="6" limb1anchor="0,-15" limb2="7" limb2anchor="0,20" lowerlimit="-170" upperlimit="0"/>
|
||||
<joint limb1="7" limb1anchor="-3,-21" limb2="8" limb2anchor="5,7" lowerlimit="10" upperlimit="135"/>
|
||||
<joint limb1="7" limb1anchor="-3,-21" limb2="8" limb2anchor="5,7" lowerlimit="20" upperlimit="90"/>
|
||||
|
||||
<!-- body to right leg -->
|
||||
<joint limb1="12" limb1anchor="0,-1" limb2="9" limb2anchor="0,14" lowerlimit="-30" upperlimit="140"/>
|
||||
<joint limb1="9" limb1anchor="0,-15" limb2="10" limb2anchor="0,20" lowerlimit="-170" upperlimit="0"/>
|
||||
<joint limb1="10" limb1anchor="-3,-21" limb2="11" limb2anchor="5,7" lowerlimit="10" upperlimit="135"/>
|
||||
<joint limb1="10" limb1anchor="-3,-21" limb2="11" limb2anchor="5,7" lowerlimit="20" upperlimit="90"/>
|
||||
|
||||
</ragdoll>
|
||||
</character>
|
||||
|
||||
BIN
Subsurface/Content/Items/Medical/med.png
Normal file
BIN
Subsurface/Content/Items/Medical/med.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 340 B |
39
Subsurface/Content/Items/Medical/medical.xml
Normal file
39
Subsurface/Content/Items/Medical/medical.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Items>
|
||||
<Item
|
||||
name="Syringe"
|
||||
Tags="smallitem"
|
||||
pickdistance="150">
|
||||
|
||||
<Sprite texture ="med.png" sourcerect="0,0,24,5"/>
|
||||
|
||||
<Body width="24" height="5"/>
|
||||
|
||||
<Pickable slots="Any,RightHand,LeftHand"/>
|
||||
|
||||
<Holdable RemoveOnUse="true">
|
||||
<StatusEffect type="OnUse" target="This, Character" Condition="-100.0" health="30.0" disabledeltatime="true"/>
|
||||
</Holdable>
|
||||
</Item>
|
||||
|
||||
<Item
|
||||
name="Bandage"
|
||||
Tags="smallitem"
|
||||
pickdistance="150">
|
||||
|
||||
<Sprite texture ="med.png" sourcerect="0,14,14,18"/>
|
||||
|
||||
<Body width="9" height="15"/>
|
||||
|
||||
<Pickable slots="Any,RightHand,LeftHand"/>
|
||||
|
||||
<Holdable RemoveOnUse="true">
|
||||
<StatusEffect type="OnUse" target="This, Character" Condition="-100.0" bleeding="-10.0" disabledeltatime="true"/>
|
||||
</Holdable>
|
||||
</Item>
|
||||
|
||||
</Items>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -796,6 +796,8 @@ namespace Subsurface
|
||||
{
|
||||
if (condition == 0.0f) return;
|
||||
|
||||
bool remove = false;
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue;
|
||||
@@ -804,8 +806,12 @@ namespace Subsurface
|
||||
ic.PlaySound(ActionType.OnUse, 1.0f, Position);
|
||||
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, deltaTime, character);
|
||||
|
||||
if (ic.DeleteOnUse) remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (remove) Remove();
|
||||
}
|
||||
|
||||
public void SecondaryUse(float deltaTime, Character character = null)
|
||||
|
||||
@@ -286,6 +286,13 @@
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Medical\medical.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Medical\med.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Jobs.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user