Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates #84

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions src/Server/Systems/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Network : Shared.Systems.System
private DisconnectHandler m_disconnectHandler;
private HashSet<uint> m_reportThese = new HashSet<uint>();
private TimeSpan m_lastGlobalUpdateTime = new TimeSpan(m_globalUpdateFrequency);
private static int m_globalUpdateFrequency = 300;
private static int m_globalUpdateFrequency = 1000;

/// <summary>
/// Primary activity in the constructor is to setup the command map
Expand Down Expand Up @@ -54,22 +54,9 @@ public Network() :
});
}

// Have to implement this because it is abstract in the base class
public override void update(TimeSpan elapsedTime)
{
m_lastGlobalUpdateTime -= elapsedTime;
if (m_lastGlobalUpdateTime.TotalMilliseconds < 0)
{
Console.WriteLine("Global Worm Location Update");
m_lastGlobalUpdateTime = new TimeSpan(m_globalUpdateFrequency);
foreach (var entity in m_entities.Values)
{
if (entity.contains<Shared.Components.Worm>())
{
m_reportThese.Add(entity.id);
}
}
}

}

/// <summary>
Expand All @@ -89,7 +76,7 @@ public void update(TimeSpan elapsedTime, Queue<Tuple<int, Message>> messages)
}
}
}

// Send updated game state updates back out to connected clients
updateClients(elapsedTime);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Entities/WormHead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Shared.Entities;

public class WormHead
{
static readonly int size = 100;
static readonly int size = 150;
static readonly float moveRate = 0.3f;
static readonly float rotateRate = (float) Math.PI / 1000;
public static Entity create(Vector2 position, string name)
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Entities/WormSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Shared.Entities;

public class WormSegment
{
static readonly int size = 80;
static readonly int size = 150;
static readonly float moveRate = 0.3f;
static readonly float rotateRate = (float) Math.PI / 1000;
public static Entity create(Vector2 position, uint parent)
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Entities/WormTail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Shared.Entities;
public class WormTail
{

public static readonly int size = 80;
public static readonly int size = 150;
public static readonly float moveRate = 0.3f;
public static readonly float rotateRate = (float) Math.PI / 1000;
public static Entity create(Vector2 position, uint parent)
Expand Down
15 changes: 2 additions & 13 deletions src/Shared/Systems/WormMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,9 @@ private void applyThrust(Entity wormHead, TimeSpan elapsedTime)
var frameTotalMovement = movement.moveRate * (float)elapsedTime.TotalMilliseconds;
var orientation = headPosition.orientation;
float LOCATION_THRESHOLD = movement.moveRate * 20;
const float MIN_SEGMENT_SPACING = 30f;
const float IDEAL_SEGMENT_SPACING = 40f;
const float MIN_SEGMENT_SPACING = 40f;
const float IDEAL_SEGMENT_SPACING = 50f;

// Check how close the head is to its child
if (head.contains<ChildId>())
{
var child = m_entities[head.get<ChildId>().id];
var childPosition = child.get<Position>();
var distanceToChild = Vector2.Distance(headPosition.position, childPosition.position);
if (distanceToChild >= IDEAL_SEGMENT_SPACING)
{
// frameTotalMovement *= 0.1f;
}
}

// Move the head
var direction = new Vector2((float)Math.Cos(orientation), (float)Math.Sin(orientation));
Expand Down
Loading