fixed railgun, fixed repairtools radar ping & improved rendering, waypoint bugfixes, inventory bugfixes, syncing wires between clients
This commit is contained in:
@@ -23,6 +23,8 @@ namespace Subsurface.Items.Components
|
||||
//the x-position where the user walks to when using the controller
|
||||
float userPos;
|
||||
|
||||
Camera cam;
|
||||
|
||||
Character character;
|
||||
|
||||
[HasDefaultValue(1.0f,false)]
|
||||
@@ -38,19 +40,6 @@ namespace Subsurface.Items.Components
|
||||
|
||||
dir = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(element, "direction", "None"), true);
|
||||
|
||||
//userPos = ToolBox.GetAttributeInt(element, "userpos", 1);
|
||||
|
||||
//string allowedIdString = ToolBox.GetAttributeString(element, "allowedids", "");
|
||||
//if (allowedIdString!="")
|
||||
//{
|
||||
// string[] splitIds = allowedIdString.Split(',');
|
||||
// allowedIDs = new string[splitIds.Length];
|
||||
// for (int i = 0; i<splitIds.Length; i++)
|
||||
// {
|
||||
// allowedIDs[i] = allowedIDs[i].Trim();
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach (XElement el in element.Elements())
|
||||
{
|
||||
if (el.Name != "limbposition") continue;
|
||||
@@ -75,6 +64,8 @@ namespace Subsurface.Items.Components
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
this.cam = cam;
|
||||
|
||||
if (character == null || character.SelectedConstruction != item)
|
||||
{
|
||||
if (character != null)
|
||||
@@ -126,25 +117,29 @@ namespace Subsurface.Items.Components
|
||||
fmj.WorldAnchorB = position;
|
||||
}
|
||||
|
||||
foreach (MapEntity e in item.linkedTo)
|
||||
{
|
||||
Item linkedItem = e as Item;
|
||||
if (linkedItem == null) continue;
|
||||
linkedItem.Update(cam, deltaTime);
|
||||
}
|
||||
//foreach (MapEntity e in item.linkedTo)
|
||||
//{
|
||||
// Item linkedItem = e as Item;
|
||||
// if (linkedItem == null) continue;
|
||||
// linkedItem.Update(cam, deltaTime);
|
||||
//}
|
||||
|
||||
item.SendSignal(ToolBox.Vector2ToString(character.CursorPosition), "position_out");
|
||||
}
|
||||
|
||||
public override bool Use(float deltaTime, Character activator = null)
|
||||
{
|
||||
character = activator;
|
||||
foreach (MapEntity e in item.linkedTo)
|
||||
{
|
||||
Item linkedItem = e as Item;
|
||||
if (linkedItem == null) continue;
|
||||
linkedItem.Use(deltaTime, activator);
|
||||
}
|
||||
//character = activator;
|
||||
//foreach (MapEntity e in item.linkedTo)
|
||||
//{
|
||||
// Item linkedItem = e as Item;
|
||||
// if (linkedItem == null) continue;
|
||||
// linkedItem.Use(deltaTime, activator);
|
||||
//}
|
||||
|
||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
item.SendSignal("1", "trigger_out");
|
||||
|
||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, activator);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -153,15 +148,43 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
if (character == null) return;
|
||||
|
||||
foreach (MapEntity e in item.linkedTo)
|
||||
foreach (Connection c in item.Connections)
|
||||
{
|
||||
Item linkedItem = e as Item;
|
||||
if (linkedItem == null) continue;
|
||||
linkedItem.SecondaryUse(deltaTime, character);
|
||||
if (c.Name != "position_out") continue;
|
||||
|
||||
foreach (Connection c2 in c.Recipients)
|
||||
{
|
||||
if (c2 == null || c2.Item==null || !c2.Item.Prefab.FocusOnSelected) continue;
|
||||
|
||||
Vector2 centerPos = c2.Item.Position;
|
||||
|
||||
if (character == Character.Controlled && cam != null)
|
||||
{
|
||||
Lights.LightManager.ViewPos = centerPos;
|
||||
cam.TargetPos = c2.Item.Position;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//foreach (MapEntity e in item.linkedTo)
|
||||
//{
|
||||
// Item linkedItem = e as Item;
|
||||
// if (linkedItem == null) continue;
|
||||
// linkedItem.SecondaryUse(deltaTime, character);
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override bool Pick(Character activator = null)
|
||||
public override bool Pick(Character picker)
|
||||
{
|
||||
item.SendSignal("1", "signal_out");
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Select(Character activator = null)
|
||||
{
|
||||
if (character!=null && character.SelectedConstruction == item)
|
||||
{
|
||||
|
||||
@@ -51,10 +51,19 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
base.Update(deltaTime, cam);
|
||||
|
||||
pingState = (pingState + deltaTime * 0.5f) % 1.0f;
|
||||
|
||||
pingState = (pingState + deltaTime * 0.5f);
|
||||
if (pingState>1.0f)
|
||||
{
|
||||
item.Use(deltaTime,null);
|
||||
pingState = 0.0f;
|
||||
}
|
||||
|
||||
angle = (angle + deltaTime) % MathHelper.TwoPi;
|
||||
//angle = (angle + deltaTime) % MathHelper.TwoPi;
|
||||
}
|
||||
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void DrawHUD(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Character character)
|
||||
|
||||
@@ -34,45 +34,37 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
isActive = true;
|
||||
}
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
PathFinder pathFinder = new PathFinder(WayPoint.WayPointList, false);
|
||||
steeringPath = pathFinder.FindPath(
|
||||
ConvertUnits.ToSimUnits(Level.Loaded.StartPosition),
|
||||
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
|
||||
}
|
||||
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
base.Update(deltaTime, cam);
|
||||
|
||||
if (autoPilot || true)
|
||||
|
||||
|
||||
if (autoPilot)
|
||||
{
|
||||
steeringPath.GetNode(Vector2.Zero, 5.0f);
|
||||
if (steeringPath==null)
|
||||
{
|
||||
PathFinder pathFinder = new PathFinder(WayPoint.WayPointList, false);
|
||||
steeringPath = pathFinder.FindPath(
|
||||
ConvertUnits.ToSimUnits(Level.Loaded.StartPosition),
|
||||
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
|
||||
}
|
||||
|
||||
steeringPath.GetNode(Vector2.Zero, 20.0f);
|
||||
|
||||
if (steeringPath.CurrentNode!=null)
|
||||
{
|
||||
Vector2 targetSpeed = steeringPath.CurrentNode.Position;
|
||||
float prediction = 10.0f;
|
||||
|
||||
float dist = targetSpeed.Length();
|
||||
Vector2 futurePosition = Submarine.Loaded.Speed * prediction;
|
||||
|
||||
Vector2 targetSpeed = (steeringPath.CurrentNode.Position - futurePosition);
|
||||
|
||||
//float dist = targetSpeed.Length();
|
||||
targetSpeed = Vector2.Normalize(targetSpeed);
|
||||
|
||||
if (dist<2000.0f)
|
||||
{
|
||||
targetSpeed = targetSpeed * Math.Max(dist / 2000.0f, 0.5f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Vector2 currSpeed = (Submarine.Loaded.Speed == Vector2.Zero) ? Vector2.Zero : Vector2.Normalize(Submarine.Loaded.Speed);
|
||||
|
||||
//targetSpeed.X = (targetSpeed.X - currSpeed.X);
|
||||
//targetSpeed.Y = (targetSpeed.Y - currSpeed.Y);
|
||||
|
||||
//TargetVelocity += targetSpeed;
|
||||
|
||||
TargetVelocity += (targetSpeed-currSpeed);
|
||||
TargetVelocity = targetSpeed*100.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +83,13 @@ namespace Subsurface.Items.Components
|
||||
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
|
||||
GUI.DrawRectangle(spriteBatch, velRect, Color.White, false);
|
||||
|
||||
if (GUI.DrawButton(spriteBatch, new Rectangle(x + width - 150, y + height - 30, 150, 30), "Autopilot"))
|
||||
{
|
||||
autoPilot = !autoPilot;
|
||||
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(velRect.Center.X,velRect.Center.Y),
|
||||
new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y),
|
||||
@@ -113,10 +112,10 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
targetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y);
|
||||
targetVelocity.Y = -targetVelocity.Y;
|
||||
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
item.NewComponentEvent(this, true);
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
|
||||
@@ -131,14 +130,19 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
message.Write(targetVelocity.X);
|
||||
message.Write(targetVelocity.Y);
|
||||
|
||||
message.Write(autoPilot);
|
||||
}
|
||||
|
||||
public override void ReadNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetIncomingMessage message)
|
||||
{
|
||||
Vector2 newTargetVelocity = Vector2.Zero;
|
||||
Vector2 newTargetVelocity = Vector2.Zero;
|
||||
bool newAutoPilot = false;
|
||||
|
||||
try
|
||||
{
|
||||
newTargetVelocity = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||
newAutoPilot = message.ReadBoolean();
|
||||
}
|
||||
|
||||
catch
|
||||
@@ -147,6 +151,7 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
|
||||
TargetVelocity = newTargetVelocity;
|
||||
autoPilot = newAutoPilot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user