コード例 #1
0
        /// <summary>
        /// Restores the general variable parameters
        /// Called from within the MSTSWagon class.
        /// </summary>
        public void Restore(BinaryReader inf)
        {
            FreightWeight = inf.ReadSingle();
            var fType = inf.ReadInt32();

            FreightType = (MSTSWagon.PickupType)fType;
            LoadedOne   = null;
            foreach (var freightAnim in Animations)
            {
                if (freightAnim is FreightAnimationContinuous)
                {
                    if ((freightAnim as FreightAnimationContinuous).LinkedIntakePoint != null)
                    {
                        if ((freightAnim as FreightAnimationContinuous).LinkedIntakePoint.Type == FreightType)
                        {
                            LoadedOne             = freightAnim as FreightAnimationContinuous;
                            LoadedOne.LoadPerCent = FreightWeight / LoadedOne.FreightWeightWhenFull * 100;
                        }
                        else
                        {
                            (freightAnim as FreightAnimationContinuous).LoadPerCent = 0;
                        }
                    }
                }
            }
            StaticFreightWeight = inf.ReadSingle();
        }
コード例 #2
0
 public FreightAnimations(FreightAnimations copyFACollection, MSTSWagon wagon)
 {
     foreach (FreightAnimation freightAnim in copyFACollection.Animations)
     {
         if (freightAnim is FreightAnimationContinuous)
         {
             Animations.Add(new FreightAnimationContinuous(freightAnim as FreightAnimationContinuous, wagon));
             if ((Animations.Last() as FreightAnimationContinuous).FullAtStart)
             {
                 LoadedOne = Animations.Last() as FreightAnimationContinuous;
             }
         }
         else if (freightAnim is FreightAnimationStatic)
         {
             Animations.Add(new FreightAnimationStatic(freightAnim as FreightAnimationStatic));
         }
         else if (freightAnim is FreightAnimationDiscrete)
         {
             Animations.Add(new FreightAnimationDiscrete(freightAnim as FreightAnimationDiscrete));
         }
     }
     FreightWeight          = copyFACollection.FreightWeight;
     FreightType            = copyFACollection.FreightType;
     MSTSFreightAnimEnabled = copyFACollection.MSTSFreightAnimEnabled;
     WagonEmptyWeight       = copyFACollection.WagonEmptyWeight;
     LoadingStartDelay      = copyFACollection.LoadingStartDelay;
     UnloadingStartDelay    = copyFACollection.UnloadingStartDelay;
     IsGondola = copyFACollection.IsGondola;
 }
コード例 #3
0
        public FreightAnimations(FreightAnimations copyFACollection, MSTSWagon wagon)
        {
            foreach (FreightAnimation freightAnim in copyFACollection.Animations)
            {
                if (freightAnim is FreightAnimationContinuous)
                {
                    Animations.Add(new FreightAnimationContinuous(freightAnim as FreightAnimationContinuous, wagon));
                    if ((Animations.Last() as FreightAnimationContinuous).FullAtStart)
                    {
                        LoadedOne = Animations.Last() as FreightAnimationContinuous;
                    }
                }
                else if (freightAnim is FreightAnimationStatic)
                {
                    Animations.Add(new FreightAnimationStatic(freightAnim as FreightAnimationStatic));
                }
                else if (freightAnim is FreightAnimationDiscrete)
                {
                    Animations.Add(new FreightAnimationDiscrete(freightAnim as FreightAnimationDiscrete));
                }
            }
            FreightWeight          = copyFACollection.FreightWeight;
            FreightType            = copyFACollection.FreightType;
            MSTSFreightAnimEnabled = copyFACollection.MSTSFreightAnimEnabled;
            WagonEmptyWeight       = copyFACollection.WagonEmptyWeight;
            LoadingStartDelay      = copyFACollection.LoadingStartDelay;
            UnloadingStartDelay    = copyFACollection.UnloadingStartDelay;
            IsGondola = copyFACollection.IsGondola;

            // additions to manage consequences of variable weight on friction and brake forces
            EmptyORTSDavis_A                   = copyFACollection.EmptyORTSDavis_A;
            EmptyORTSDavis_B                   = copyFACollection.EmptyORTSDavis_B;
            EmptyORTSDavis_C                   = copyFACollection.EmptyORTSDavis_C;
            EmptyORTSWagonFrontalAreaM2        = copyFACollection.EmptyORTSWagonFrontalAreaM2;
            EmptyORTSDavisDragConstant         = copyFACollection.EmptyORTSDavisDragConstant;
            EmptyMaxBrakeForceN                = copyFACollection.EmptyMaxBrakeForceN;
            EmptyMaxHandbrakeForceN            = copyFACollection.EmptyMaxHandbrakeForceN;
            EmptyCentreOfGravityM_Y            = copyFACollection.EmptyCentreOfGravityM_Y;
            ContinuousFreightAnimationsPresent = copyFACollection.ContinuousFreightAnimationsPresent;
            StaticFreightAnimationsPresent     = copyFACollection.StaticFreightAnimationsPresent;
        }
コード例 #4
0
        public bool StaticFreightAnimationsPresent     = false; // Flag to indicate that a continuous freight animation is present

        public FreightAnimations(STFReader stf, MSTSWagon wagon)
        {
            stf.MustMatch("(");
            bool empty = true;

            stf.ParseBlock(new[] {
                new STFReader.TokenProcessor("mstsfreightanimenabled", () => { MSTSFreightAnimEnabled = stf.ReadBoolBlock(true); }),
                new STFReader.TokenProcessor("wagonemptyweight", () => { WagonEmptyWeight = stf.ReadFloatBlock(STFReader.UNITS.Mass, -1); }),
                new STFReader.TokenProcessor("loadingstartdelay", () => { UnloadingStartDelay = stf.ReadFloatBlock(STFReader.UNITS.None, 0); }),
                new STFReader.TokenProcessor("unloadingstartdelay", () => { UnloadingStartDelay = stf.ReadFloatBlock(STFReader.UNITS.None, 0); }),
                new STFReader.TokenProcessor("isgondola", () => { IsGondola = stf.ReadBoolBlock(false); }),
                // additions to manage consequences of variable weight on friction and brake forces
                new STFReader.TokenProcessor("emptyortsdavis_a", () => { EmptyORTSDavis_A = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
                new STFReader.TokenProcessor("emptyortsdavis_b", () => { EmptyORTSDavis_B = stf.ReadFloatBlock(STFReader.UNITS.Resistance, -1); }),
                new STFReader.TokenProcessor("emptyortsdavis_c", () => { EmptyORTSDavis_C = stf.ReadFloatBlock(STFReader.UNITS.ResistanceDavisC, -1); }),
                new STFReader.TokenProcessor("emptyortswagonfrontalarea", () => { EmptyORTSWagonFrontalAreaM2 = stf.ReadFloatBlock(STFReader.UNITS.AreaDefaultFT2, -1); }),
                new STFReader.TokenProcessor("emptyortsdavisdragconstant", () => { EmptyORTSDavisDragConstant = stf.ReadFloatBlock(STFReader.UNITS.Any, -1); }),
                new STFReader.TokenProcessor("emptymaxbrakeforce", () => { EmptyMaxBrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
                new STFReader.TokenProcessor("emptymaxhandbrakeforce", () => { EmptyMaxHandbrakeForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, -1); }),
                new STFReader.TokenProcessor("emptycentreofgravity_y", () => { EmptyCentreOfGravityM_Y = stf.ReadFloatBlock(STFReader.UNITS.Distance, -1); }),
                new STFReader.TokenProcessor("freightanimcontinuous", () =>
                {
                    Animations.Add(new FreightAnimationContinuous(stf, wagon));
                    FullPhysicsContinuousOne = Animations.Last() as FreightAnimationContinuous;
                    if (wagon.WeightLoadController == null)
                    {
                        wagon.WeightLoadController = new MSTSNotchController(0, 1, 0.01f);
                    }
                    if ((Animations.Last() as FreightAnimationContinuous).FullAtStart)
                    {
                        if (empty)
                        {
                            empty                 = false;
                            FreightType           = wagon.IntakePointList.Last().Type;
                            LoadedOne             = Animations.Last() as FreightAnimationContinuous;
                            FreightWeight        += LoadedOne.FreightWeightWhenFull;
                            LoadedOne.LoadPerCent = 100;
                        }
                        else
                        {
                            (Animations.Last() as FreightAnimationContinuous).FullAtStart = false;
                            Trace.TraceWarning("The wagon can't be full with two different materials, only first is retained");
                        }
                    }
                    ContinuousFreightAnimationsPresent = true;
                }),
                new STFReader.TokenProcessor("freightanimstatic", () =>
                {
                    Animations.Add(new FreightAnimationStatic(stf));
                    StaticFreightWeight           += (Animations.Last() as FreightAnimationStatic).FreightWeight;
                    StaticFreightAnimationsPresent = true;
                    FullPhysicsStaticOne           = Animations.Last() as FreightAnimationStatic;
                }),

/*                new STFReader.TokenProcessor("freightanimdiscrete", ()=>
 *              {
 *                  ORTSFreightAnims.Add(new FreightAnimDiscrete(stf));
 *                  if ((ORTSFreightAnims.Last() as FreightAnimDiscrete).LoadedAtStart)
 *                  {
 *                      if (empty)
 *                      {
 *                          empty = false;
 *                          DiscreteLoadedOne = ORTSFreightAnims.Last() as FreightAnimDiscrete;
 *                          FreightWeight += DiscreteLoadedOne.LoadWeight;
 *                      }
 *                      else
 *                      {
 *                          (ORTSFreightAnims.Last() as FreightAnimContinuous).FullAtStart = false;
 *                          Trace.TraceWarning("The wagon can't be full with two different materials, only first is retained");
 *                      }
 *                  }
 *              }),*/
            });
        }
コード例 #5
0
        public FreightAnimations(STFReader stf, MSTSWagon wagon)
        {
            stf.MustMatch("(");
            bool empty = true;

            stf.ParseBlock(new[] {
                new STFReader.TokenProcessor("mstsfreightanimenabled", () => { MSTSFreightAnimEnabled = stf.ReadBoolBlock(true); }),
                new STFReader.TokenProcessor("wagonemptyweight", () => { WagonEmptyWeight = stf.ReadFloatBlock(STFReader.UNITS.Mass, -1); }),
                new STFReader.TokenProcessor("loadingstartdelay", () => { UnloadingStartDelay = stf.ReadFloatBlock(STFReader.UNITS.None, 0); }),
                new STFReader.TokenProcessor("unloadingstartdelay", () => { UnloadingStartDelay = stf.ReadFloatBlock(STFReader.UNITS.None, 0); }),
                new STFReader.TokenProcessor("isgondola", () => { IsGondola = stf.ReadBoolBlock(false); }),
                new STFReader.TokenProcessor("freightanimcontinuous", () =>
                {
                    Animations.Add(new FreightAnimationContinuous(stf, wagon));
                    if (wagon.WeightLoadController == null)
                    {
                        wagon.WeightLoadController = new MSTSNotchController(0, 1, 0.01f);
                    }
                    if ((Animations.Last() as FreightAnimationContinuous).FullAtStart)
                    {
                        if (empty)
                        {
                            empty                 = false;
                            FreightType           = wagon.IntakePointList.Last().Type;
                            LoadedOne             = Animations.Last() as FreightAnimationContinuous;
                            FreightWeight        += LoadedOne.FreightWeightWhenFull;
                            LoadedOne.LoadPerCent = 100;
                        }
                        else
                        {
                            (Animations.Last() as FreightAnimationContinuous).FullAtStart = false;
                            Trace.TraceWarning("The wagon can't be full with two different materials, only first is retained");
                        }
                    }
                }),
                new STFReader.TokenProcessor("freightanimstatic", () =>
                {
                    Animations.Add(new FreightAnimationStatic(stf));
                    StaticFreightWeight += (Animations.Last() as FreightAnimationStatic).FreightWeight;
                }),

/*                new STFReader.TokenProcessor("freightanimdiscrete", ()=>
 *              {
 *                  ORTSFreightAnims.Add(new FreightAnimDiscrete(stf));
 *                  if ((ORTSFreightAnims.Last() as FreightAnimDiscrete).LoadedAtStart)
 *                  {
 *                      if (empty)
 *                      {
 *                          empty = false;
 *                          DiscreteLoadedOne = ORTSFreightAnims.Last() as FreightAnimDiscrete;
 *                          FreightWeight += DiscreteLoadedOne.LoadWeight;
 *                      }
 *                      else
 *                      {
 *                          (ORTSFreightAnims.Last() as FreightAnimContinuous).FullAtStart = false;
 *                          Trace.TraceWarning("The wagon can't be full with two different materials, only first is retained");
 *                      }
 *                  }
 *              }),*/
            });
        }