Improved map rendering, shops, light bugfix, junction boxes wont break as easily

This commit is contained in:
Regalis
2015-07-27 23:45:20 +03:00
parent 4238301ad3
commit 7155f1cef0
37 changed files with 472 additions and 300 deletions

View File

@@ -123,7 +123,7 @@ namespace Subsurface.Items.Components
MeltDown();
return;
}
else if (temperature==0.0f)
else if (temperature == 0.0f)
{
if (powerUpTask == null || powerUpTask.IsFinished)
{

View File

@@ -50,7 +50,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));
if (-pt.currPowerConsumption > pt.powerLoad * 2.0f) pt.item.Condition = 0.0f;
if (-pt.currPowerConsumption > Math.Max(pt.powerLoad * 2.0f, 200.0f)) pt.item.Condition -= deltaTime*10.0f;
}
}
@@ -139,7 +139,6 @@ namespace Subsurface.Items.Components
{
connection.SendSignal(signal, sender, 0.0f);
}
}
}
}
}

View File

@@ -83,6 +83,12 @@ namespace Subsurface.Items.Components
light.Position = ConvertUnits.ToDisplayUnits(item.body.Position);
}
if (item.container!= null)
{
light.Color = Color.Transparent;
return;
}
if (powerConsumption == 0.0f)
{
voltage = 1.0f;
@@ -92,9 +98,9 @@ namespace Subsurface.Items.Components
currPowerConsumption = powerConsumption;
}
if (Rand.Range(0.0f, 1.0f)<0.05f && voltage < Rand.Range(0.0f, minVoltage))
if (Rand.Range(0.0f, 1.0f) < 0.05f && voltage < Rand.Range(0.0f, minVoltage))
{
if (voltage>0.1f) sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 400.0f, item.Position);
if (voltage > 0.1f) sparkSounds[Rand.Int(sparkSounds.Length)].Play(1.0f, 400.0f, item.Position);
lightBrightness = 0.0f;
}
else
@@ -117,6 +123,13 @@ namespace Subsurface.Items.Components
}
}
public override void Remove()
{
base.Remove();
light.Remove();
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
{
base.ReceiveSignal(signal, connection, sender, power);

View File

@@ -65,6 +65,8 @@ namespace Subsurface
get { return condition; }
set
{
if (float.IsNaN(value)) return;
float prev = condition;
condition = MathHelper.Clamp(value, 0.0f, 100.0f);
if (condition==0.0f && prev>0.0f)
@@ -1063,6 +1065,8 @@ namespace Subsurface
public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data)
{
message.Write(condition);
switch (type)
{
case NetworkEventType.DropItem:
@@ -1077,6 +1081,8 @@ namespace Subsurface
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
{
Condition = message.ReadFloat();
switch (type)
{
case NetworkEventType.DropItem:
@@ -1096,7 +1102,7 @@ namespace Subsurface
base.Remove();
//sprite.Remove();
if (body!=null) body.Remove();
if (body != null) body.Remove();
foreach (ItemComponent ic in components)
{

View File

@@ -156,6 +156,8 @@ namespace Subsurface
focusOnSelected = ToolBox.GetAttributeBool(element, "focusonselected", false);
offsetOnSelected = ToolBox.GetAttributeFloat(element, "offsetonselected", 0.0f);
price = ToolBox.GetAttributeInt(element, "price", 0);
Triggers = new List<Rectangle>();