60 lines
1.1 KiB
C#
60 lines
1.1 KiB
C#
using Godot;
|
|
|
|
public class Character(Sector sector, Vector3 localCoordinates) : GameObject(sector, localCoordinates)
|
|
{
|
|
private Player player;
|
|
|
|
public bool SheduledUpdateNode = false;
|
|
|
|
public override void AssignSector(Sector sector)
|
|
{
|
|
CurrentSector = sector;
|
|
|
|
ResetLocalCoordinates();
|
|
UpdateSectorOffsetToMainPlayer();
|
|
UpdateNodePosition();
|
|
|
|
if (IsMainPlayer())
|
|
{
|
|
GameManager.Instance.ApplyOrigin();
|
|
}
|
|
|
|
reassigning = false;
|
|
}
|
|
|
|
public bool IsMainPlayer()
|
|
{
|
|
return player == GameManager.Instance.MainPlayer;
|
|
}
|
|
|
|
public Player InstantiatePlayer()
|
|
{
|
|
PackedScene prefab = ResourceLoader.Load<PackedScene>("res://prefabs/gameObjects/player.tscn");
|
|
Player instance = prefab.Instantiate<Player>();
|
|
|
|
instance.PlayerData = this;
|
|
player = instance;
|
|
|
|
return instance;
|
|
}
|
|
|
|
public override void Simulate(double delta)
|
|
{
|
|
if (!reassigning && !IsInCurrentSector())
|
|
{
|
|
UpdateSector();
|
|
}
|
|
}
|
|
|
|
public override void UpdateNodePosition()
|
|
{
|
|
if (IsMainPlayer())
|
|
{
|
|
player.GlobalPosition = LocalCoordinates;
|
|
}
|
|
else
|
|
{
|
|
player.GlobalPosition = LocalCoordinates + SectorOffset;
|
|
}
|
|
}
|
|
}
|