public void RemoveViper(Viper viper, bool destroyed = false) { CurrentGameState.Dradis.RemoveComponent(viper); var modifiedViper = CurrentGameState.Vipers.FindIndex(x => x.PermanentDesignation == viper.PermanentDesignation); if (modifiedViper == -1) return; CurrentGameState.Vipers[modifiedViper].Status = (destroyed ? ComponentStatus.Destroyed : ComponentStatus.Damaged); }
private List<Viper> BuildVipers() { var viperLimit = ConfigurationManager.AppSettings["MaxVipers"].ParseAs<int>(); var vipers = new Viper[viperLimit]; var viperInt = 0; // This is a janky way to do a ForEach loop but this is still superior to a For loop because this is guaranteed to terminate. foreach (var viper in vipers) { var newViper = new Viper { PermanentDesignation = Guid.NewGuid(), InternalDesignation = Guid.NewGuid(), PublicDesignation = "Vigilante " + (viperInt+1), Status = ComponentStatus.InReserve }; vipers[viperInt] = newViper; viperInt++; } return vipers.OrderBy(x => x.InternalDesignation).ToList(); }