예제 #1
0
 public PlaybackPool(CodecSettings codecSettings, IPriorityManager priority, IVolumeProvider volume)
 {
     _codecSettings = codecSettings;
     _priority      = priority;
     _volume        = volume;
     _pool          = new Pool <VoicePlayback>(6, CreatePlayback);
 }
예제 #2
0
 public XmlQuestionConverter(IFactory<ITest> testFactory, IFactory<IQuestion> questionFactory, 
     IFactory<IAnswer> answerFactory, IFactory<IExercise> exerciseFactory,
     IKernel kernel, TaggedExerciseInitializer taggedInitializer, IVolumeProvider volumeProvider){
     this.testFactory = testFactory;
     this.questionFactory = questionFactory;
     this.answerFactory = answerFactory;
     this.exerciseFactory = exerciseFactory;
     this.kernel = kernel;
     this.taggedInitializer = taggedInitializer;
     this.volumeProvider = volumeProvider;
 }
예제 #3
0
        public TestRunnerImpl(ITestRunUi testUi,
                                ITaskDetailUi detailUi,
                                [Named(inject.UiModule.LOCATION_BOTTOM)] IUiPositioner positioner,
                                IVolumeProvider volumeProvider) {
            this.testUi = testUi;
            this.positioner = positioner;
            this.detailUi = detailUi;
            this.volumeProvider = volumeProvider;

            InitializeBindings(testUi);
        }
예제 #4
0
 public XmlQuestionConverter(IFactory <ITest> testFactory, IFactory <IQuestion> questionFactory,
                             IFactory <IAnswer> answerFactory, IFactory <IExercise> exerciseFactory,
                             IKernel kernel, TaggedExerciseInitializer taggedInitializer, IVolumeProvider volumeProvider)
 {
     this.testFactory       = testFactory;
     this.questionFactory   = questionFactory;
     this.answerFactory     = answerFactory;
     this.exerciseFactory   = exerciseFactory;
     this.kernel            = kernel;
     this.taggedInitializer = taggedInitializer;
     this.volumeProvider    = volumeProvider;
 }
예제 #5
0
        public ResourceModifier(TankResource tankResource, IVolumeProvider volumeProvider, Part part, float filledProportion, bool?tweakable)
        {
            tankResource.ThrowIfNullArgument(nameof(tankResource));
            volumeProvider.ThrowIfNullArgument(nameof(volumeProvider));
            part.ThrowIfNullArgument(nameof(part));

            this.tankResource     = tankResource;
            this.volumeProvider   = volumeProvider;
            this.part             = part;
            this.filledProportion = filledProportion;
            this.tweakable        = tweakable;
        }
예제 #6
0
        public TestRunnerImpl(ITestRunUi testUi,
                              ITaskDetailUi detailUi,
                              [Named(inject.UiModule.LOCATION_BOTTOM)] IUiPositioner positioner,
                              IVolumeProvider volumeProvider)
        {
            this.testUi         = testUi;
            this.positioner     = positioner;
            this.detailUi       = detailUi;
            this.volumeProvider = volumeProvider;

            InitializeBindings(testUi);
        }
예제 #7
0
        public PlaybackPool([NotNull] IPriorityManager priority, [NotNull] IVolumeProvider volume)
        {
            if (priority == null)
            {
                throw new ArgumentNullException("priority");
            }
            if (volume == null)
            {
                throw new ArgumentNullException("volume");
            }

            _priority = priority;
            _volume   = volume;
            _pool     = new Pool <VoicePlayback>(10, CreatePlayback);
        }
예제 #8
0
 public SpeechSessionStream(IVolumeProvider volumeProvider)
 {
     _volumeProvider     = volumeProvider;
     _awaitingActivation = new Queue <SpeechSession>();
 }
예제 #9
0
        [NotNull] private static DecoderPipeline GetOrCreateDecoderPipeline(FrameFormat format, [NotNull] IVolumeProvider volume)
        {
            if (volume == null)
            {
                throw new ArgumentNullException("volume");
            }

            ConcurrentPool <DecoderPipeline> pool;

            if (!FreePipelines.TryGetValue(format, out pool))
            {
                pool = new ConcurrentPool <DecoderPipeline>(3, () => {
                    var decoder = DecoderFactory.Create(format);

                    return(new DecoderPipeline(decoder, format.FrameSize, p =>
                    {
                        p.Reset();
                        Recycle(format, p);
                    }));
                });
                FreePipelines[format] = pool;
            }

            var pipeline = pool.Get();

            pipeline.Reset();

            pipeline.VolumeProvider = volume;

            return(pipeline);
        }
예제 #10
0
        public void Setup(ModuleB9PartSwitch parent, bool displayWarnings = true)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent cannot be null");
            }
            if (parent.part == null)
            {
                throw new ArgumentNullException("parent.part cannot be null");
            }

            this.parent = parent;

            aspectLocks.Clear();

            Part part       = parent.part;
            Part partPrefab = part.GetPrefab() ?? part;

            partModifiers.Clear();

            IEnumerable <object> aspectLocksOnOtherModules = parent.PartAspectLocksOnOtherModules;

            string errorString = null;

            void OnInitializationError(string message)
            {
                LogError(message);

                if (displayWarnings)
                {
                    if (errorString == null)
                    {
                        errorString = $"Initialization errors on {parent} subtype '{Name}'";
                    }

                    errorString += "\n  " + message;
                }
            }

            void MaybeAddModifier(IPartModifier modifier)
            {
                if (modifier == null)
                {
                    return;
                }
                if (aspectLocksOnOtherModules.Contains(modifier.PartAspectLock))
                {
                    OnInitializationError($"More than one module can't manage {modifier.Description}");
                }
                else
                {
                    partModifiers.Add(modifier);
                    aspectLocks.Add(modifier.PartAspectLock);
                }
            }

            if (maxTemp > 0)
            {
                MaybeAddModifier(new PartMaxTempModifier(part, partPrefab.maxTemp, maxTemp));
            }

            if (skinMaxTemp > 0)
            {
                MaybeAddModifier(new PartSkinMaxTempModifier(part, partPrefab.skinMaxTemp, skinMaxTemp));
            }

            if (crashTolerance > 0)
            {
                MaybeAddModifier(new PartCrashToleranceModifier(part, partPrefab.crashTolerance, crashTolerance));
            }

            if (attachNode.IsNotNull())
            {
                if (part.attachRules.allowSrfAttach)
                {
                    if (part.srfAttachNode.IsNotNull())
                    {
                        MaybeAddModifier(new PartAttachNodeModifier(part.srfAttachNode, partPrefab.srfAttachNode, attachNode, parent));
                    }
                    else
                    {
                        OnInitializationError("attachNode specified but part does not have a surface attach node");
                    }
                }
                else
                {
                    OnInitializationError("attachNode specified but part does not allow surface attach");
                }
            }

            if (CoMOffset.IsFinite())
            {
                MaybeAddModifier(new PartCoMOffsetModifier(part, partPrefab.CoMOffset, CoMOffset));
            }

            if (CoPOffset.IsFinite())
            {
                MaybeAddModifier(new PartCoPOffsetModifier(part, partPrefab.CoPOffset, CoPOffset));
            }

            if (CoLOffset.IsFinite())
            {
                MaybeAddModifier(new PartCoLOffsetModifier(part, partPrefab.CoLOffset, CoLOffset));
            }

            if (CenterOfBuoyancy.IsFinite())
            {
                MaybeAddModifier(new PartCenterOfBuoyancyModifier(part, partPrefab.CenterOfBuoyancy, CenterOfBuoyancy));
            }

            if (CenterOfDisplacement.IsFinite())
            {
                MaybeAddModifier(new PartCenterOfDisplacementModifier(part, partPrefab.CenterOfDisplacement, CenterOfDisplacement));
            }

            if (stackSymmetry >= 0)
            {
                MaybeAddModifier(new PartStackSymmetryModifier(part, partPrefab.stackSymmetry, stackSymmetry));
            }

            foreach (AttachNodeModifierInfo info in attachNodeModifierInfos)
            {
                MaybeAddModifier(info.CreateAttachNodeModifier(part, parent, OnInitializationError));
            }

            foreach (TextureSwitchInfo info in textureSwitches)
            {
                foreach (TextureReplacement replacement in info.CreateTextureReplacements(part, OnInitializationError))
                {
                    MaybeAddModifier(replacement);
                }
            }

            nodes.Clear();
            foreach (string nodeName in nodeNames)
            {
                string pattern     = '^' + Regex.Escape(nodeName).Replace(@"\*", ".*").Replace(@"\?", ".") + '$';
                Regex  nodeIdRegex = new Regex(pattern);

                bool foundNode = false;

                foreach (AttachNode node in part.attachNodes)
                {
                    if (!nodeIdRegex.IsMatch(node.id))
                    {
                        continue;
                    }

                    foundNode = true;

                    if (node.nodeType != AttachNode.NodeType.Stack)
                    {
                        OnInitializationError($"Node {node.id} is not a stack node, and thus cannot be managed by ModuleB9PartSwitch");
                        continue;
                    }

                    nodes.Add(node);
                    partModifiers.Add(new AttachNodeToggler(node));
                }

                if (!foundNode)
                {
                    OnInitializationError($"No attach nodes matching '{nodeName}' found");
                }
            }

            if (HasTank)
            {
                volumeProvider = new SubtypeVolumeProvider(parent, volumeMultiplier, volumeAdded);
                foreach (TankResource resource in tankType)
                {
                    float            filledProportion = (resource.percentFilled ?? percentFilled ?? tankType.percentFilled ?? 100f) * 0.01f;
                    bool?            tweakable        = resourcesTweakable ?? tankType.resourcesTweakable;
                    ResourceModifier resourceModifier = new ResourceModifier(resource, volumeProvider, part, filledProportion, tweakable);
                    MaybeAddModifier(resourceModifier);
                }
            }

            transforms.Clear();
            foreach (var transformName in transformNames)
            {
                bool foundTransform = false;

                foreach (Transform transform in part.GetModelTransforms(transformName))
                {
                    foundTransform = true;
                    partModifiers.Add(new TransformToggler(transform, part));
                    transforms.Add(transform);
                }

                if (!foundTransform)
                {
                    OnInitializationError($"No transforms named '{transformName}' found");
                }
            }

            foreach (TransformModifierInfo transformModifierInfo in transformModifierInfos)
            {
                foreach (IPartModifier partModifier in transformModifierInfo.CreatePartModifiers(part, OnInitializationError))
                {
                    MaybeAddModifier(partModifier);
                }
            }

            if (!parent.subtypes.Any(subtype => subtype.Name == mirrorSymmetrySubtype))
            {
                OnInitializationError($"Cannot find subtype '{mirrorSymmetrySubtype}' for mirror symmetry subtype");
                mirrorSymmetrySubtype = Name;
            }

            if (errorString.IsNotNull())
            {
                SeriousWarningHandler.DisplaySeriousWarning(errorString);
            }
        }
예제 #11
0
 public FileTask003(IFileSystem fs, IVolumeProvider vp, IFileConditionFactory conditionFactory)
     : base(fs, vp)
 {
     this.conditionFactory = conditionFactory;
 }
예제 #12
0
 public AbstractFileTask(IFileSystem fileSystem, IVolumeProvider volumeProvider) {
     this.fs = fileSystem;
     this.vp = volumeProvider;
 }
예제 #13
0
        [NotNull] internal static DecoderPipeline GetDecoderPipeline(FrameFormat format, [NotNull] IVolumeProvider volume)
        {
            if (volume == null)
            {
                throw new ArgumentNullException("volume");
            }

            var pool     = GetPool(format);
            var pipeline = pool.Get();

            pipeline.Reset();

            pipeline.VolumeProvider = volume;

            return(pipeline);
        }
예제 #14
0
 public PlaybackPool(IPriorityManager priority, IVolumeProvider volume)
 {
     _priority = priority;
     _volume   = volume;
     _pool     = new Pool <VoicePlayback>(6, CreatePlayback);
 }
예제 #15
0
 public VolumeRampedFrameSource(IFrameSource source, IVolumeProvider volumeProvider)
 {
     _source         = source;
     _volumeProvider = volumeProvider;
 }
예제 #16
0
 public VolumeFileSystemDecorator(IFileSystem fsDelegate, IVolumeProvider volumeProvider)
 {
     this.fsDelegate     = fsDelegate;
     this.volumeProvider = volumeProvider;
 }
예제 #17
0
 public FileTask003(IFileSystem fs, IVolumeProvider vp, IFileConditionFactory conditionFactory)
     : base(fs, vp) {
         this.conditionFactory = conditionFactory;
 }
예제 #18
0
 public VolumeFileSystemDecorator(IFileSystem fsDelegate, IVolumeProvider volumeProvider) {
     this.fsDelegate = fsDelegate;
     this.volumeProvider = volumeProvider;
 }
예제 #19
0
 public AbstractFileTask(IFileSystem fileSystem, IVolumeProvider volumeProvider)
 {
     this.fs = fileSystem;
     this.vp = volumeProvider;
 }