Пример #1
0
        /// <inheritdoc/>
        public override void Update(AbstractTrain NearestTrain, double TimeElapsed, bool ForceUpdate, bool CurrentlyVisible)
        {
            if (CurrentlyVisible | ForceUpdate)
            {
                if (Object.SecondsSinceLastUpdate >= Object.RefreshRate | ForceUpdate)
                {
                    double timeDelta = Object.SecondsSinceLastUpdate + TimeElapsed;
                    Object.SecondsSinceLastUpdate = 0.0;

                    if (base.Visible)
                    {
                        //Calculate the distance travelled
                        double delta = UpdateTrackFollowerScript(false, NearestTrain, NearestTrain == null ? 0 : NearestTrain.DriverCar, SectionIndex, TrackPosition, Position, true, timeDelta);
                        //Update the front and rear axle track followers
                        FrontAxleFollower.UpdateAbsolute((TrackPosition + FrontAxlePosition) + delta, true, true);
                        RearAxleFollower.UpdateAbsolute((TrackPosition + RearAxlePosition) + delta, true, true);
                        //Update the base object position
                        FrontAxleFollower.UpdateWorldCoordinates(false);
                        RearAxleFollower.UpdateWorldCoordinates(false);
                        UpdateObjectPosition();
                    }

                    //Update the actual animated object- This must be done last in case the user has used Translation or Rotation
                    Object.Update(false, NearestTrain, NearestTrain == null ? 0 : NearestTrain.DriverCar, SectionIndex, FrontAxleFollower.TrackPosition, FrontAxleFollower.WorldPosition, Direction, Up, Side, true, true, timeDelta, true);
                }
                else
                {
                    Object.SecondsSinceLastUpdate += TimeElapsed;
                }

                if (!base.Visible)
                {
                    currentHost.ShowObject(Object.internalObject, ObjectType.Dynamic);
                    base.Visible = true;
                }
            }
            else
            {
                Object.SecondsSinceLastUpdate += TimeElapsed;
                if (base.Visible)
                {
                    currentHost.HideObject(Object.internalObject);
                    base.Visible = false;
                }
            }
        }