reliable network messages aren't sent as frequently, equippable grenades/detonators
This commit is contained in:
@@ -112,15 +112,24 @@ namespace Subsurface.Items.Components
|
||||
targetLevel = null;
|
||||
isActive = !isActive;
|
||||
if (!isActive) currPowerConsumption = 0.0f;
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Flow percentage: " + (int)flowPercentage + " %", new Vector2(x + 20, y + 80), Color.White);
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 70, 40, 40), "+", true)) FlowPercentage += 1.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 70, 40, 40), "-", true)) FlowPercentage -= 1.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 70, 40, 40), "+", true))
|
||||
{
|
||||
FlowPercentage += 1.0f;
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 70, 40, 40), "-", true))
|
||||
{
|
||||
FlowPercentage -= 1.0f;
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
|
||||
|
||||
item.NewComponentEvent(this, true);
|
||||
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
|
||||
|
||||
@@ -269,10 +269,12 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
|
||||
|
||||
bool valueChanged = false;
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
isActive = true;
|
||||
|
||||
|
||||
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
@@ -291,27 +293,59 @@ namespace Subsurface.Items.Components
|
||||
spriteBatch.DrawString(GUI.Font, "Fission rate: " + (int)fissionRate + " %", new Vector2(x + 30, y + 30), Color.White);
|
||||
DrawGraph(fissionRateGraph, spriteBatch, x + 30, y + 50, 100.0f, xOffset);
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 30, 40, 40), "+", true)) FissionRate += 1.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 80, 40, 40), "-", true)) FissionRate -= 1.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 30, 40, 40), "+", true))
|
||||
{
|
||||
valueChanged = true;
|
||||
FissionRate += 1.0f;
|
||||
}
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 80, 40, 40), "-", true))
|
||||
{
|
||||
valueChanged = true;
|
||||
FissionRate -= 1.0f;
|
||||
}
|
||||
|
||||
y += 130;
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Cooling rate: " + (int)coolingRate + " %", new Vector2(x + 30, y + 30), Color.White);
|
||||
DrawGraph(coolingRateGraph, spriteBatch, x + 30, y + 50, 100.0f, xOffset);
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 30, 40, 40), "+", true)) CoolingRate += 1.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 80, 40, 40), "-", true)) CoolingRate -= 1.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 30, 40, 40), "+", true))
|
||||
{
|
||||
valueChanged = true;
|
||||
CoolingRate += 1.0f;
|
||||
}
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 280, y + 80, 40, 40), "-", true))
|
||||
{
|
||||
valueChanged = true;
|
||||
CoolingRate -= 1.0f;
|
||||
}
|
||||
|
||||
y = y - 260;
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 400, y + 30), Color.White);
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 60, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON"))) autoTemp = !autoTemp;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 60, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON")))
|
||||
{
|
||||
valueChanged = true;
|
||||
autoTemp = !autoTemp;
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 400, y + 150), Color.White);
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 180, 40, 40), "+", true)) shutDownTemp += 100.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 180, 40, 40), "-", true)) shutDownTemp -= 100.0f;
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 400, y + 180, 40, 40), "+", true))
|
||||
{
|
||||
valueChanged = true;
|
||||
shutDownTemp += 100.0f;
|
||||
}
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 180, 40, 40), "-", true))
|
||||
{
|
||||
valueChanged = true;
|
||||
shutDownTemp -= 100.0f;
|
||||
}
|
||||
|
||||
item.NewComponentEvent(this, true);
|
||||
if (valueChanged)
|
||||
{
|
||||
item.NewComponentEvent(this, true);
|
||||
valueChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateGraph<T>(IList<T> graph, T newValue)
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace Subsurface.Items.Components
|
||||
|
||||
private static PathFinder pathFinder;
|
||||
|
||||
private float networkUpdateTimer;
|
||||
private bool valueChanged;
|
||||
|
||||
bool AutoPilot
|
||||
{
|
||||
get { return autoPilot; }
|
||||
@@ -90,6 +93,16 @@ namespace Subsurface.Items.Components
|
||||
TargetVelocity = targetSpeed*100.0f;
|
||||
}
|
||||
}
|
||||
else if (valueChanged)
|
||||
{
|
||||
networkUpdateTimer -= deltaTime;
|
||||
if (networkUpdateTimer<=0.0f)
|
||||
{
|
||||
item.NewComponentEvent(this, true);
|
||||
networkUpdateTimer = 1.0f;
|
||||
valueChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
item.SendSignal(targetVelocity.X.ToString(CultureInfo.InvariantCulture), "velocity_x_out");
|
||||
item.SendSignal((-targetVelocity.Y).ToString(CultureInfo.InvariantCulture), "velocity_y_out");
|
||||
@@ -136,7 +149,7 @@ namespace Subsurface.Items.Components
|
||||
targetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y);
|
||||
targetVelocity.Y = -targetVelocity.Y;
|
||||
|
||||
item.NewComponentEvent(this, true);
|
||||
valueChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,9 +195,9 @@ namespace Subsurface.Items.Components
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (rechargeSpeed / maxRechargeSpeed), new Vector2(x + 30, y + 100), Color.White);
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 50, y + 150, 40, 40), "+", true))
|
||||
{
|
||||
item.NewComponentEvent(this, true);
|
||||
{
|
||||
rechargeSpeed = Math.Min(rechargeSpeed + 10.0f, maxRechargeSpeed);
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 150, 40, 40), "-", true))
|
||||
|
||||
@@ -38,7 +38,12 @@ namespace Subsurface.Items.Components
|
||||
get { return ToolBox.Vector4ToString(lightColor.ToVector4()); }
|
||||
set
|
||||
{
|
||||
lightColor = new Color(ToolBox.ParseToVector4(value));
|
||||
Vector4 newColor = ToolBox.ParseToVector4(value);
|
||||
newColor.X = MathHelper.Clamp(newColor.X, 0.0f, 1.0f);
|
||||
newColor.Y = MathHelper.Clamp(newColor.Y, 0.0f, 1.0f);
|
||||
newColor.Z = MathHelper.Clamp(newColor.Z, 0.0f, 1.0f);
|
||||
newColor.W = MathHelper.Clamp(newColor.W, 0.0f, 1.0f);
|
||||
lightColor = new Color(newColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user