diff --git a/Torch.Server/ViewModels/Entities/CharacterViewModel.cs b/Torch.Server/ViewModels/Entities/CharacterViewModel.cs index e111666..fe55549 100644 --- a/Torch.Server/ViewModels/Entities/CharacterViewModel.cs +++ b/Torch.Server/ViewModels/Entities/CharacterViewModel.cs @@ -4,14 +4,24 @@ namespace Torch.Server.ViewModels.Entities { public class CharacterViewModel : EntityViewModel { + private MyCharacter _character; public CharacterViewModel(MyCharacter character, EntityTreeViewModel tree) : base(character, tree) { - character.ControllerInfo.ControlAcquired += (x) => { OnPropertyChanged(nameof(Name)); }; - character.ControllerInfo.ControlReleased += (x) => { OnPropertyChanged(nameof(Name)); }; + _character = character; + character.ControllerInfo.ControlAcquired += ControllerInfo_ControlAcquired; + character.ControllerInfo.ControlReleased += ControllerInfo_ControlAcquired; + } + + private void ControllerInfo_ControlAcquired(Sandbox.Game.World.MyEntityController obj) + { + OnPropertyChanged(nameof(Name)); + OnPropertyChanged(nameof(CanDelete)); } public CharacterViewModel() { } + + public override bool CanDelete => _character.ControllerInfo?.Controller?.Player == null; } } diff --git a/Torch.Server/ViewModels/Entities/EntityViewModel.cs b/Torch.Server/ViewModels/Entities/EntityViewModel.cs index c1f7d0d..3a37720 100644 --- a/Torch.Server/ViewModels/Entities/EntityViewModel.cs +++ b/Torch.Server/ViewModels/Entities/EntityViewModel.cs @@ -136,7 +136,7 @@ namespace Torch.Server.ViewModels.Entities public virtual bool CanStop => Entity.Physics?.Enabled ?? false; - public virtual bool CanDelete => !(Entity is IMyCharacter); + public virtual bool CanDelete => true; public virtual void Delete() { diff --git a/Torch/Commands/TorchCommands.cs b/Torch/Commands/TorchCommands.cs index accb888..001e184 100644 --- a/Torch/Commands/TorchCommands.cs +++ b/Torch/Commands/TorchCommands.cs @@ -261,7 +261,7 @@ namespace Torch.Commands private Task DoSave() { - Task task = Context.Torch.Save(60 * 1000, true); + Task task = Context.Torch.Save(300 * 1000, true); if (task == null) { Context.Respond("Save failed, a save is already in progress");