示例#1
0
 public MetaInteraction(MetaGen component)
 {
     metagen_comp          = component;
     voiceInteraction      = new VoiceInteraction(metagen_comp);
     textInteraction       = new TextInteraction(metagen_comp);
     poseStreamInteraction = new PoseStreamInteraction(metagen_comp);
 }
        private void StartMetaGen(World world)
        {
            world.RunSynchronously(() =>
            {
                Slot metagen_slot = world.RootSlot.Find("5013598197metagen local slot");
                if (metagen_slot == null)
                {
                    metagen_slot = world.AddLocalSlot("5013598197metagen local slot");
                }
                MetaGen metagen = metagen_slot.GetComponent <MetaGen>();
                if (metagen == null)
                {
                    Action <MetaGen> beforeAttach = (MetaGen comp) =>
                    {
                        //comp.hearingRecorder = hearingRecorder;
                        comp.recording_hearing_user = recording_hearing_user;
                    };
                    metagen = metagen_slot.AttachComponent <MetaGen>(true, beforeAttach);
                }
                else
                {
                    //metagen.hearingRecorder = hearingRecorder;
                    metagen.recording_hearing_user = recording_hearing_user;
                    //metagen.StartRecording();
                }
                metagens[current_session_id] = metagen;
                metagen.admin_mode           = admin_mode;
                MetaMetaGen.current_metagen  = metagen;
                //hearingRecorder.metagen_comp = metagen;


                //attach BotLogic
                if (use_bot_ui)
                {
                    //Slot botLogicSlot = world.LocalUser.Root.Slot.AddLocalSlot("botlogic local slot");
                    Slot botLogicSlot            = world.RootSlot.AddLocalSlot("botlogic local slot");
                    BotLogic logicComp           = botLogicSlot.AttachComponent <BotLogic>();
                    logicComp.mg                 = current_metagen;
                    current_metagen.botComponent = logicComp;
                }

                current_metagen.silent_mode = use_silent_mode;
                current_metagen.dataBase    = dataBase;
                ResetHearingUser();
                current_metagen.record_local_user = default_record_local_user;
                current_metagen.Initialize();
                current_metagen.OnUserLeftCallback += MaybeResetHearingUserOnLeft;
                //current_metagen.OnUserJoinedCallback += MaybeResetHearingUserOnJoin;
                earsSlot = world.AddSlot("AudioListener");
                //world.LocalUser.LocalUserRoot.OverrideEars.Target = earsSlot;
                //hearingRecorder.earSlot = earsSlot;
                current_metagen.record_everyone   = record_everyone;
                current_metagen.recording_hearing = false;
                current_metagen.is_loaded         = true;
            });
        }
示例#3
0
        public void TestJitGen()
        {
            var jit = MetaGen.GenerateJit(ManglingCode).Invoke(Schema);

            jit
            .Take(2)
            .Each(
                for_each_type =>
                for_each_type.Item2
                .Take(2)
                .Each(x => $"{{Type: {x.DeclaringType.TypeName}; Verb: {x.Verb.ToString()}}}".By(Output.WriteLine))
                );
        }
示例#4
0
        public void TestSwigGen()
        {
            var swig = MetaGen.GenerateSwig(ManglingCode).Invoke(Schema);

            swig
            .Each(_ =>
                  _.Item2
                  .Each(swigCodeGetter =>
                        swigCodeGetter
                        .Item2
                        .Invoke("0x00")
                        .By(Output.WriteLine)));
        }
示例#5
0
        public void TestCSharpGen()
        {
            var csharp = MetaGen.GenerateCSharp(ManglingCode).Invoke(Schema);

            csharp
            .Take(2)
            .Each(
                _ => _.Item2.Take(2).Each(nested =>
            {
                var(fnName, Code) = nested;
                Output.WriteLine($"Get function address by calling this one: {fnName}");
                Output.WriteLine(Code);
            }));
        }
示例#6
0
        public void TestList()
        {
            var lst = new List <int> {
                1, 2, 3
            };

            var jit = MetaGen.GenerateJit(ManglingCode).Invoke(Schema);

            var fnDescs = jit.First(_ => _.Item1.TypeName.StartsWith("List"))
                          .By(type_and_fields => type_and_fields.Item2);

            var get_from_lst_int =
                fnDescs
                .First(v => v.Verb.Equals(Verbs.Verb.NewComposedVerb(Verbs.Verb.LGet, Verbs.Verb.BGet)))
                .By(_ => {
                Output.WriteLine(_.Verb.ToString());
                return(JitCompiler.CompileFunction(_));
            })
                .By(native =>
                    Marshal.GetDelegateForFunctionPointer(
                        native.CallSite, typeof(LBGet)));

            var count_lst_int =
                fnDescs
                .First(v => v.Verb.Equals(Verbs.Verb.LCount))
                .By(_ => {
                Output.WriteLine(_.Verb.ToString());
                return(JitCompiler.CompileFunction(_));
            })
                .By(native =>
                    Marshal.GetDelegateForFunctionPointer(
                        native.CallSite, typeof(LCount)));


            Helper.ListToNativeAndThen(
                lst,
                subject =>
            {
                var list_1   = (int)get_from_lst_int.DynamicInvoke(subject, 1);
                var list_len = (int)count_lst_int.DynamicInvoke(subject);

                Output.WriteLine("list[1]=" + list_1.ToString());
                Output.WriteLine("list length =" + list_len.ToString());

                Assert.Equal(list_1, lst[1]);
                Assert.Equal(list_len, lst.Count());
                return(0);
            });
        }
示例#7
0
        public void TestJitRun()
        {
            int _foo, foo = 1;

            var c1 = Global.LocalStorage.NewGenericCell(1, "C1");


            c1.SetField("foo", foo);
            Global.LocalStorage.SaveGenericCell(c1.CellId, c1);
            using (var s = Global.LocalStorage.UseGenericCell(c1.CellId))
            {
                Output.WriteLine(s.GetField <string>("foo"));
            }



            {
                var acc = Helper.LockCell(c1.CellId);
                var jit = MetaGen.GenerateJit(ManglingCode).Invoke(Schema);

                jit.Each(x =>
                         Output.WriteLine(
                             $"{x.Item1.TypeName}: {x.Item2.Select(fnDesc => fnDesc.Verb.ToString()).By(all => String.Join('\n', all))}"));

                var fnDescs =
                    jit
                    .Where(_ => _.Item1.TypeName.Equals("C1"))
                    .First()
                    .By(type_and_fields => type_and_fields.Item2);


                var get_foo_from_c1 =
                    fnDescs
                    .Where(v => v.Verb is Verbs.Verb.ComposedVerb)
                    .First()
                    .By(JitCompiler.CompileFunction)
                    .By(native =>
                        Marshal.GetDelegateForFunctionPointer(
                            native.CallSite, typeof(SBGet)));

                _foo = (int)get_foo_from_c1.DynamicInvoke(acc);

                Output.WriteLine(_foo.ToString());
            }
            Assert.Equal(_foo, foo);
        }
示例#8
0
        private void FocusedWorld(World world)
        {
            if (currentWorld != null && !is_in_VR_mode)
            {
                try
                {
                    if (currentWorld.IsAuthority)
                    {
                        Userspace.LeaveSession(currentWorld);
                    }
                    else
                    {
                        Userspace.EndSession(currentWorld);
                    }
                } catch (Exception e)
                {
                    UniLog.Log("Exception when leaving/ending session: " + e.Message);
                }
            }
            bool is_there_metagen_in_world = false;

            foreach (var item in metagens)
            {
                try
                {
                    MetaGen metagen = item.Value;
                    metagen.StopPlaying();
                    metagen.StopRecording();
                    //metagen.Destroy();
                    if (metagen.World == world)
                    {
                        is_there_metagen_in_world = true;
                    }
                } catch (Exception e)
                {
                    UniLog.Log("owo Exception when stopping the metagens when focusing a new world");
                    UniLog.Log("This could be because someone invited the bot while it was playing");
                }
            }
            current_session_id = world.SessionId;
            currentWorld       = world;
            if (!is_there_metagen_in_world)
            {
                AddWorld(world);
            }
        }
示例#9
0
        protected override void OnAttach()
        {
            base.OnAttach();
            //mg = this.Slot.GetComponent<BotLogic>().mg;
            mg = FrooxEngine.LogiX.MetaMetaGen.current_metagen;
            //float2 float2 = new float2(2300f, 8000f);
            float2 float2 = new float2(2300f, 6500f);

            this.CanvasSize             = float2 * 1.0f;
            this.PhysicalHeight         = this.Slot.Parent.LocalScaleToGlobal(0.3f);
            this.Panel.ShowHeader.Value = false;
            this.Panel.ShowHandle.Value = false;
            Slot holder = this.Slot.Parent.AddSlot("panel holder");

            panelSlot = holder;
            //holder.Tag = "Developer";
            holder.LocalPosition = new float3(0f, 1.5f, 1f);
            this.Slot.DestroyChildren();
            panel                          = holder.AttachComponent <NeosSwapCanvasPanel>();
            panel.CanvasSize               = float2 * 0.4f;
            panel.Slot.LocalScale          = new float3(2.5f, 2.5f, 2.5f);
            panel.PhysicalHeight           = panel.Slot.Parent.LocalScaleToGlobal(0.3f);
            panel.Panel.ShowHeader.Value   = false;
            panel.Panel.ShowHandle.Value   = false;
            interact_button_pressed.Target = holder.AttachComponent <ValueField <bool> >().Value;
            record_button_pressed.Target   = holder.AttachComponent <ValueField <bool> >().Value;
            play_button_pressed.Target     = holder.AttachComponent <ValueField <bool> >().Value;
            swapUI_button_pressed.Target   = holder.AttachComponent <ValueField <bool> >().Value;
            this.OpenConnectedPanel();
            //this._container.Target.SetParent(this.World.RootSlot);
            //var t = typeof(NeosPanel);
            //t.GetProperty("_contentSlot").SetValue(engine, compatibilityHash, null);
            //this._panel.Target.
            //this.Slot.SetParent(this.World.RootSlot);
            //this.Slot.LocalPosition = new float3(1.5f, 0.5f, 0f);
            //this.Slot.RemoveComponent(this);
        }
示例#10
0
 public FieldInteraction(MetaGen component)
 {
     metagen_comp = component;
 }
示例#11
0
 public TextInteraction(MetaGen component)
 {
     metagen_comp = component;
 }
示例#12
0
        public static string SwigGen(IStorageSchema schema, string ModuleName)
        {
            var codeGenerators = MetaGen.CodeGenSwigJit(ManglingCode, schema);

            return(codeGenerators.Invoke(ModuleName));
        }
示例#13
0
        public void TestSwigFileGen()
        {
            var codeGenerators = MetaGen.CodeGenSwigJit(ManglingCode, Schema);

            codeGenerators.Invoke("moduleName").By(Output.WriteLine);
        }
示例#14
0
 public VoiceInteraction(MetaGen component)
 {
     metagen_comp = component;
     this.buffer  = new float[metagen_comp.Engine.AudioSystem.BufferSize];
 }