Implement basic networking
This commit is contained in:
parent
c320d9ddcb
commit
994823a9c3
25 changed files with 643 additions and 217 deletions
|
|
@ -4,6 +4,39 @@ public class Character(Sector sector, Vector3 localCoordinates) : GameObject(sec
|
|||
{
|
||||
private Player player;
|
||||
|
||||
public bool SheduledUpdateNode = false;
|
||||
|
||||
public override void AssignSector(Sector sector)
|
||||
{
|
||||
CurrentSector = sector;
|
||||
|
||||
ResetLocalCoordinates();
|
||||
UpdateSectorOffsetToMainPlayer();
|
||||
UpdateNodePosition();
|
||||
|
||||
if (IsMainPlayer())
|
||||
{
|
||||
GameManager.Singleton.ApplyOrigin();
|
||||
|
||||
if (!Global.IsGameHost)
|
||||
{
|
||||
GameManager.Singleton.RpcId(
|
||||
1,
|
||||
nameof(GameManager.Singleton.RpcSendNearbySectors),
|
||||
CurrentSector.Coordinates,
|
||||
NetworkManager.Singleton.LocalNetId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
reassigning = false;
|
||||
}
|
||||
|
||||
public bool IsMainPlayer()
|
||||
{
|
||||
return player == GameManager.Singleton.MainPlayer;
|
||||
}
|
||||
|
||||
public Player InstantiatePlayer()
|
||||
{
|
||||
PackedScene prefab = ResourceLoader.Load<PackedScene>("res://prefabs/gameObjects/player.tscn");
|
||||
|
|
@ -17,6 +50,13 @@ public class Character(Sector sector, Vector3 localCoordinates) : GameObject(sec
|
|||
|
||||
public override void UpdateNodePosition()
|
||||
{
|
||||
player.GlobalPosition = LocalCoordinates;
|
||||
if (IsMainPlayer())
|
||||
{
|
||||
player.GlobalPosition = LocalCoordinates;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.GlobalPosition = LocalCoordinates + SectorOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue