public bool AddNewAccount(UplinkAccount acc) { var entity = _entityManager.GetEntity(acc.AccountHolder); if (entity.TryGetComponent(out MindComponent mindComponent)) { if (!mindComponent.HasMind) { return(false); } if (mindComponent.Mind !.AllRoles.Any(role => !role.Antagonist)) { return(false); } } if (_accounts.Contains(acc)) { return(false); } _accounts.Add(acc); return(true); }
public override void Validate() { base.Validate(); var dupRole = Roles.FirstOrDefault(i => AllRoles.Any(r => r != i && r.Name.EqualsIgnoreCase(i.Name))); if (dupRole != null) { throw new DuplicatedException(dupRole.Name); } var dupGroup = Groups.FirstOrDefault(i => AllGroups.Any(r => r != i && r.Name.EqualsIgnoreCase(i.Name))); if (dupRole != null) { throw new DuplicatedException(dupRole.Name); } }