Example #1
0
        public void ForgetSkill(IXQueryable skill)
        {
            CrewInstance.TransferSkill(skill, _learntSkills, _availableSkills);
            this.Configuration.ScriptHost.SetScript(this.GetScriptKey(skill), null);
            this.SetLastSkillScriptLevelGetter(() => this.ActualLastSkillTrainingLevel);

            this.InvalidateSkillEffects();
        }
        internal CrewConfiguration(IRepository repository, TankEntity tank, ScriptHost scriptHost, CrewConfigurationInfo configInfo)
            : base(repository, tank, scriptHost)
        {
            if (configInfo == null)
            {
                _crewConfigurationInfo = new CrewConfigurationInfo();
            }

            _element = new XElement("crews");

            var crewDatum = tank.QueryMany("crews/crew");

            var redundancyCounters = new Dictionary <string, int>();
            var crewList           = new List <CrewInstance>();

            foreach (var data in crewDatum)
            {
                var primaryRole    = data["@role"];
                var secondaryRoles = data.QueryManyValues("secondaryRoles/secondaryRole").ToArray();
                int redundancyIndex;
                if (redundancyCounters.ContainsKey(primaryRole))
                {
                    redundancyIndex = redundancyCounters[primaryRole] = redundancyCounters[primaryRole] + 1;
                }
                else
                {
                    redundancyIndex = redundancyCounters[primaryRole] = 0;
                }

                var crew = new CrewInstance(this, primaryRole, secondaryRoles, redundancyIndex);
                crewList.Add(crew);
                this.Element.Add(crew.Element);

                if (configInfo == null)
                {
                    _crewConfigurationInfo[crew.PrimaryRole] = crew.CrewInstanceInfo;
                }
            }

            _crews = crewList.ToArray();

            if (configInfo != null)
            {
                _crewConfigurationInfo = configInfo;
            }
        }