Esempio n. 1
0
        public static bool StartSample(SubSustainer __instance)
        {
            ResolvedGrain resolvedGrain = __instance.subDef.RandomizedResolvedGrain();

            if (resolvedGrain == null)
            {
                Log.Error(string.Concat(new object[]
                {
                    "SubSustainer for ",
                    __instance.subDef,
                    " of ",
                    __instance.parent.def,
                    " could not resolve any grains."
                }), false);
                __instance.parent.End();
                return(false);
            }
            float num;

            if (__instance.subDef.sustainLoop)
            {
                num = __instance.subDef.sustainLoopDurationRange.RandomInRange;
            }
            else
            {
                num = resolvedGrain.duration;
            }
            float num2 = Time.realtimeSinceStartup + num;

            nextSampleStartTime(__instance) = num2 + __instance.subDef.sustainIntervalRange.RandomInRange;
            if (nextSampleStartTime(__instance) < Time.realtimeSinceStartup + 0.01f)
            {
                nextSampleStartTime(__instance) = Time.realtimeSinceStartup + 0.01f;
            }
            if (resolvedGrain is ResolvedGrain_Silence)
            {
                return(false);
            }

            SampleSustainer sampleSustainer = SampleSustainer.TryMakeAndPlay(__instance, ((ResolvedGrain_Clip)resolvedGrain).clip, num2);

            if (sampleSustainer != null)
            {
                if (__instance.subDef.sustainSkipFirstAttack && Time.frameCount == __instance.creationFrame)
                {
                    sampleSustainer.resolvedSkipAttack = true;
                }
                lock (__instance)
                {
                    samples(__instance).Add(sampleSustainer);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public static bool StartSample(SubSustainer __instance)
        {
            ResolvedGrain resolvedGrain = __instance.subDef.RandomizedResolvedGrain();

            if (resolvedGrain == null)
            {
                Log.Error(string.Concat(new object[]
                {
                    "SubSustainer for ",
                    __instance.subDef,
                    " of ",
                    __instance.parent.def,
                    " could not resolve any grains."
                }), false);
                __instance.parent.End();
                return(false);
            }
            float num;

            if (__instance.subDef.sustainLoop)
            {
                num = __instance.subDef.sustainLoopDurationRange.RandomInRange;
            }
            else
            {
                num = resolvedGrain.duration;
            }
            float num2 = Time.realtimeSinceStartup + num;

            nextSampleStartTime(__instance) = num2 + __instance.subDef.sustainIntervalRange.RandomInRange;
            if (nextSampleStartTime(__instance) < Time.realtimeSinceStartup + 0.01f)
            {
                nextSampleStartTime(__instance) = Time.realtimeSinceStartup + 0.01f;
            }
            if (resolvedGrain is ResolvedGrain_Silence)
            {
                return(false);
            }

            int tID = Thread.CurrentThread.ManagedThreadId;

            if (Ticklist_Patch.eventWaitStarts.TryGetValue(tID, out EventWaitHandle eventWaitStart))
            {
                Ticklist_Patch.tryMakeAndPlayRequests.TryAdd(tID, new object[] { __instance, ((ResolvedGrain_Clip)resolvedGrain).clip, num2 });
                Ticklist_Patch.mainThreadWaitHandle.Set();
                eventWaitStart.WaitOne();
            }
            return(false);
        }
Esempio n. 3
0
        public static bool StartSample(SubSustainer __instance)
        {
            ResolvedGrain resolvedGrain = __instance.subDef.RandomizedResolvedGrain();

            if (resolvedGrain == null)
            {
                Log.Error(string.Concat(new object[]
                {
                    "SubSustainer for ",
                    __instance.subDef,
                    " of ",
                    __instance.parent.def,
                    " could not resolve any grains."
                }), false);
                __instance.parent.End();
                return(false);
            }
            float num;

            if (__instance.subDef.sustainLoop)
            {
                num = __instance.subDef.sustainLoopDurationRange.RandomInRange;
            }
            else
            {
                num = resolvedGrain.duration;
            }
            float num2 = Time.realtimeSinceStartup + num;

            nextSampleStartTime(__instance) = num2 + __instance.subDef.sustainIntervalRange.RandomInRange;
            if (nextSampleStartTime(__instance) < Time.realtimeSinceStartup + 0.01f)
            {
                nextSampleStartTime(__instance) = Time.realtimeSinceStartup + 0.01f;
            }
            if (resolvedGrain is ResolvedGrain_Silence)
            {
                return(false);
            }

            SampleSustainer sampleSustainer = SampleSustainer.TryMakeAndPlay(__instance, ((ResolvedGrain_Clip)resolvedGrain).clip, num2);

            if (sampleSustainer != null)
            {
                if (__instance.subDef.sustainSkipFirstAttack && Time.frameCount == __instance.creationFrame)
                {
                    sampleSustainer.resolvedSkipAttack = true;
                }
                samples(__instance).Add(sampleSustainer);
            }

            /*
             * int tID = Thread.CurrentThread.ManagedThreadId;
             * if (RimThreaded.mainRequestWaits.TryGetValue(tID, out EventWaitHandle eventWaitStart))
             * {
             *      RimThreaded.tryMakeAndPlayRequests.TryAdd(tID, new object[] { __instance, ((ResolvedGrain_Clip)resolvedGrain).clip, num2 });
             *      RimThreaded.mainThreadWaitHandle.Set();
             *      eventWaitStart.WaitOne();
             * }
             */
            return(false);
        }