Ejemplo n.º 1
0
 public override void FromSnapshot(JediumBehaviourSnapshot snap)
 {
     if (snap.GetBehaviourType() != "Animation")
     {
         _log.Warn($"Wrong snapshot type: {snap.GetBehaviourType()}");
     }
 }
Ejemplo n.º 2
0
 public override void FromSnapshot(JediumBehaviourSnapshot snap)
 {
     if (snap.GetBehaviourType() != "CharacterController")
     {
         _log.Warn($"Wrong snapshot type: {snap.GetBehaviourType()}");
     }
 }
Ejemplo n.º 3
0
        public override void FromSnapshot(JediumBehaviourSnapshot snap)
        {
            if (snap.GetBehaviourType() != "UI")
            {
                Log.Warn($"Wrong snapshot type: {snap.GetBehaviourType()}");
            }

            JediumUISnapshot UISnap = (JediumUISnapshot)snap;

            this.dllName     = UISnap.dllName;
            this._bundleId   = UISnap.bundleId;
            this.xamlName    = UISnap.xamlName;
            this.archiveName = UISnap.archiveName;
        }
Ejemplo n.º 4
0
        public override void FromSnapshot(JediumBehaviourSnapshot snap)
        {
            if (snap.GetBehaviourType() != "Take")
            {
                Log.Warn($"Wrong snapshot type: {snap.GetBehaviourType()}");
            }

            JediumTakeSnapshot takeSnap = (JediumTakeSnapshot)snap;

            posX = takeSnap.X;
            posY = takeSnap.Y;
            posZ = takeSnap.Z;
            RotX = takeSnap.RotX;
            RotY = takeSnap.RotY;
            RotZ = takeSnap.RotZ;
            RotW = takeSnap.RotW;
        }
Ejemplo n.º 5
0
        public override void FromSnapshot(JediumBehaviourSnapshot snap)
        {
            if (snap.GetBehaviourType() != "Transform")
            {
                _log.Warn($"Wrong snapshot type: {snap.GetBehaviourType()}");
                return;
            }

            JediumTransformSnapshot tsnap = (JediumTransformSnapshot)snap;

            _posX   = tsnap.X;
            _posY   = tsnap.Y;
            _posZ   = tsnap.Z;
            _quatX  = tsnap.RotX;
            _quatY  = tsnap.RotY;
            _quatZ  = tsnap.RotZ;
            _quatW  = tsnap.RotW;
            _scaleX = tsnap.ScaleX;
            _scaleY = tsnap.ScaleY;
            _scaleZ = tsnap.ScaleZ;
        }
Ejemplo n.º 6
0
        public static int LoadBehaviours(string path)
        {
            int ret = 0;

            _log.Info("-----------Start loading behaviour plugins---------------");
            _log.Info($"Path:{path}");

            List <Assembly> assemblies = new List <Assembly>();

            foreach (string dll in Directory.GetFiles(path, "*.dll"))
            {
                if (!dll.Contains("Jedium.Behaviours.Shared"))
                {
                    AssemblyName an       = AssemblyName.GetAssemblyName(dll);
                    Assembly     assembly = Assembly.Load(an);
                    assemblies.Add(assembly);
                    _log.Info($"Loaded assembly:{dll}");
                }
            }

            Type behaviourType = typeof(JediumBehaviour);

            //load behaviours first
            foreach (var assembly in assemblies)
            {
                try
                {
                    List <Type> types = assembly.GetLoadableTypes().ToList();



                    foreach (Type t in types)
                    {
                        if (t.IsAbstract || t.IsInterface)
                        {
                            continue;
                        }
                        else
                        {
                            if (t.BaseType == behaviourType)
                            {
                                // JediumBehaviour jb = (JediumBehaviour)Activator.CreateInstance(t, new object[] { null }); //not possible - behaviour
                                GameObject go    = new GameObject();
                                var        jb    = (JediumBehaviour)go.AddComponent(t);
                                string     btype = jb.GetComponentType();
                                GameObject.DestroyImmediate(go);
                                BehaviourTypeRegistry.RegisteredBehaviourTypes.Add(btype, t);

                                _log.Info($"Added behaviour:{btype},{t}");
                                ret++;
                            }
                        }
                    }
                }
                catch (ReflectionTypeLoadException e)
                {
                    var    loaderExceptions = e.LoaderExceptions;
                    string estr             = "";
                    for (int i = 0; i < loaderExceptions.Length; i++)
                    {
                        estr = estr + loaderExceptions[i].Message;
                    }
                    Debug.LogError(estr);
                    throw;
                }
            }

            //then snapshots
            Type snapshotType = typeof(JediumBehaviourSnapshot);

            foreach (var assembly in assemblies)
            {
                Type[] types = assembly.GetTypes();

                foreach (Type t in types)
                {
                    if (t.IsAbstract || t.IsInterface)
                    {
                        continue;
                    }
                    else
                    {
                        if (t.BaseType == snapshotType)
                        {
                            JediumBehaviourSnapshot jb = (JediumBehaviourSnapshot)Activator.CreateInstance(t);
                            string btype = jb.GetBehaviourType();
                            BehaviourTypeRegistry.RegisteredSnapshotTypes.Add(btype, t);

                            _log.Info($"Added snapshot:{btype},{t}");
                        }
                    }
                }
            }

            _log.Info("-----------Finished loading behaviour plugins---------------");

            return(ret);
        }
Ejemplo n.º 7
0
        static void LoadPluginFromManifest(BehaviourPluginManifest man, string path)
        {
            if (!File.Exists(Path.Combine(path, man.ServerDLL)) || !File.Exists(Path.Combine(path, man.SharedDLL)))
            {
                _log.Warn($"Can't find DLLs for plugin {man.Name}");
                return;
            }

            AssemblyName san = AssemblyName.GetAssemblyName(Path.Combine(path, man.ServerDLL));

            Assembly sas = Assembly.Load(san);

            Type behaviourType = typeof(JediumBehaviour);

            Type dbType = typeof(JediumBehaviourDBSnapshot);

            Type[] types = sas.GetTypes();

            foreach (Type t in types)
            {
                if (t.IsAbstract || t.IsInterface)
                {
                }
                else
                {
                    if (t.BaseType == behaviourType)
                    {
                        JediumBehaviour jb    = (JediumBehaviour)Activator.CreateInstance(t, new object[] { null });
                        string          btype = jb.GetBehaviourType();
                        BehaviourTypeRegistry.BehaviourTypes.Add(btype, t);
                        //we also need to add type to TYPEBEHAVOUR
                        TYPEBEHAVIOUR.AddRegisteredType(btype);
                        _log.Info($"Added behaviour:{btype},{t}");
                    }

                    if (t.BaseType == dbType)
                    {
                        BehaviourTypeRegistry.DBTypes.Add(t);
                        _log.Info($"Registered DB snapshot type:{t}");
                    }
                }
            }

            AssemblyName shan = AssemblyName.GetAssemblyName(Path.Combine(path, man.SharedDLL));

            Assembly shas = Assembly.Load(shan);

            Type snapshotType = typeof(JediumBehaviourSnapshot);

            types = shas.GetTypes();

            Type messageType = typeof(JediumBehaviourMessage);

            foreach (Type t in types)
            {
                if (t.IsAbstract || t.IsInterface)
                {
                }
                else
                {
                    if (t.BaseType == snapshotType)
                    {
                        JediumBehaviourSnapshot jb = (JediumBehaviourSnapshot)Activator.CreateInstance(t);
                        string btype = jb.GetBehaviourType();
                        RegisteredSnapshotTypes.Add(btype, t);

                        _log.Info($"Added snapshot:{btype},{t}");
                    }

                    if (t.GetInterface(messageType.FullName) != null)
                    {
                        RegisteredMessageTypes.Add(t);


                        _log.Info($"Added message:{t}");
                    }
                }
            }

            _log.Info("Finished loading behaviour plugin " + man.Name + " ,v. " + man.Version);
        }