private static void CreateLoadSitRepMappings() { Mapper.CreateMap<HexVectorComponentSto, HexVectorComponent>() .ForMember(hvc => hvc.Direction, ac => ac.MapFrom(vcs => Enum.Parse(typeof(HexAxis), vcs.Direction))) .ForMember(hvc => hvc.Magnitude, ac => ac.MapFrom(vcs => vcs.Value)); Mapper.CreateMap<HexVectorSto, RawHexVector>() .ForMember(hvc => hvc.Components, ac => ac.Ignore()) .AfterMap((hvs, rhv) => rhv.AddComponents(Mapper.Map<IEnumerable<HexVectorComponentSto>, IEnumerable<HexVectorComponent>>(hvs.Components))); Mapper.CreateMap<ImpulseRecordSto, ImpulseTrackElement>() .ForMember(ite => ite.Impulse, ac => ac.MapFrom(irs => TurnData.Parse(irs.Impulse))); Mapper.CreateMap<ShellstarSto, ShellstarInfo>(); Mapper.CreateMap<UnitSto, UnitModel>() .ForMember(um => um.Position, ac => ac.MapFrom(uns => HexGridCoordinate.Parse(uns.Position))) .ForMember(um => um.Vectors, ac => ac.MapFrom(uns => uns.Velocity)) .AfterMap((uns, um) => uns.IncomingProjectiles.ForEach(st => { var evasionInfo = new EvasionInfoModel(AvidWindow.Parse(st.EvasionInfo.ImpactWindow), AvidWindow.Parse(st.EvasionInfo.EvasionUp).Direction); var shellstarModel = new ShellstarModel(Mapper.Map<ShellstarSto, ShellstarInfo>(st), TurnData.Parse(st.SegmentOfLaunch), evasionInfo); shellstarModel.Tag = st.Tag; um.AttachShellstar(shellstarModel); })); }
private IShellstarModel BuildShellstar(FiringSolution firingSolution, MissileAccelerationData accelerationData) { if (firingSolution == null || firingSolution.AimAdjustment == AimAdjustment.NoShot || (accelerationData != null && accelerationData.ValidLaunch == false)) { return null; } var shellstar = _shellstarBuilder.BuildShellstarInfo(TargetDistance.Magnitude, LaunchingSegment, firingSolution, accelerationData); var result = new ShellstarModel(shellstar, LaunchingSegment) { Tag = GetDefaultTag() }; return result; }