Character view model and fixed character display
This commit is contained in:
@@ -6,7 +6,12 @@ namespace Torch.Server.ViewModels.Entities
|
||||
{
|
||||
public CharacterViewModel(MyCharacter character, EntityTreeViewModel tree) : base(character, tree)
|
||||
{
|
||||
|
||||
character.ControllerInfo.ControlAcquired += (x) => { OnPropertyChanged(nameof(Name)); };
|
||||
character.ControllerInfo.ControlReleased += (x) => { OnPropertyChanged(nameof(Name)); };
|
||||
}
|
||||
|
||||
public CharacterViewModel()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
using System.Windows.Controls;
|
||||
using Sandbox.Game.World;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Collections;
|
||||
using Torch.Server.Managers;
|
||||
using VRage.Game.Entity;
|
||||
using VRage.Game.ModAPI;
|
||||
using VRage.ModAPI;
|
||||
using VRageMath;
|
||||
@@ -32,10 +34,11 @@ namespace Torch.Server.ViewModels.Entities
|
||||
|
||||
public virtual string Name
|
||||
{
|
||||
get => Entity?.DisplayName;
|
||||
get => Entity?.DisplayName ?? (Entity != null ? $"eid:{Entity.EntityId}" : "nil");
|
||||
set
|
||||
{
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.DisplayName = value);
|
||||
if (Entity!=null)
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.DisplayName = value);
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -48,7 +51,8 @@ namespace Torch.Server.ViewModels.Entities
|
||||
if (!Vector3D.TryParse(value, out Vector3D v))
|
||||
return;
|
||||
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.SetPosition(v));
|
||||
if (Entity != null)
|
||||
TorchBase.Instance.InvokeBlocking(() => Entity.SetPosition(v));
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user