public JediumSitMessage(Guid _clientId, Guid _localId, bool isOccupied) { ClientId = _clientId; LocalId = _localId; IsOccupied = isOccupied; _behType = TYPEBEHAVIOUR.GetTypeIndex("Sit"); }
public JediumCharacterControllerMessage(float v, float h, bool jump) { V = v; H = h; Jump = jump; _behType = TYPEBEHAVIOUR.GetTypeIndex("CharacterController"); }
public void SetBehaviourFromSnapshot(JediumBehaviourSnapshot snap) { var type = snap.BehaviourType; int index = TYPEBEHAVIOUR.GetTypeIndex(type); if (index == -1) //todo - log error { return; } if (_behaviours.ContainsKey(index)) { _behaviours[index].FromSnapshot(snap); } else { //adding new behaviour Type behType = BehaviourTypeRegistry.BehaviourTypes[snap.BehaviourType]; JediumBehaviour plugin_beh = (JediumBehaviour)Activator.CreateInstance(behType, this); plugin_beh.FromSnapshot(snap); _behaviours.Add(index, plugin_beh); } }
public JediumTakeMessage(Guid clientId, Guid localId, bool IsTaken) { ClientId = clientId; LocalId = localId; _behType = TYPEBEHAVIOUR.GetTypeIndex("Take"); this.IsTaken = IsTaken; }
public JediumTouchMessage(Guid clientId, float u, float v) { ClientId = clientId; U = u; V = v; _behType = TYPEBEHAVIOUR.GetTypeIndex("Touch"); }
public JediumUIMessage(string dllName, Guid bundleId, string xamlName, string archiveName) { this.dllName = dllName; this.bundleId = bundleId; this.xamlName = xamlName; this.archiveName = archiveName; _behType = TYPEBEHAVIOUR.GetTypeIndex("UI"); }
/// <summary> /// </summary> /// <param name="type"></param> /// <param name="nameParametr"></param> /// <param name="value"></param> /// <param name="isDirect">Setting the value directly, not tracking animator</param> /// <param name="dampTime"></param> /// <param name="deltaTime"></param> public JediumAnimatorMessage(JEDIUM_TYPE_ANIMATOR type, string nameParametr, object value, bool isDirect, float dampTime, float deltaTime) { Type = type; NameParameter = nameParametr; Value = value; IsDirectUpdate = isDirect; DampTime = dampTime; DeltaTime = deltaTime; _behType = TYPEBEHAVIOUR.GetTypeIndex("Animation"); }
public JediumTransformMessage(float x, float y, float z, float rotx, float roty, float rotz, float rotw, float scalex, float scaley, float scalez) { X = x; Y = y; Z = z; RotX = rotx; RotY = roty; RotZ = rotz; RotW = rotw; ScaleX = scalex; ScaleY = scaley; ScaleZ = scalez; _behType = TYPEBEHAVIOUR.GetTypeIndex("Transform"); }
public override bool ProcessUpdate(JediumBehaviourMessage message) { if (message == null) //empty update { return(false); } if (message.GetBehaviourType() != TYPEBEHAVIOUR.GetTypeIndex(GetComponentType())) { Debug.Log("WRONG MESSAGE TYPE:" + message.GetBehaviourType() + ";" + message.GetType()); return(false); } JediumTestBehaviourMessage tmsg = (JediumTestBehaviourMessage)message; Debug.Log("__GOT TEST MESSAGE:" + tmsg.SomeTestMessage); return(true); }
//Мы предполагаем, что компонент Transform есть всегда public JediumGameObject(IGameObjectSelfAccessor actor, List <JediumBehaviourSnapshot> behaviours, Dictionary <string, JediumBehaviourDBSnapshot> db_snaps, Guid ownerId, Guid localId) { Actor = actor; OwnerId = ownerId; LocalId = localId; _behaviours = new Dictionary <int, JediumBehaviour>(); foreach (var new_beh in db_snaps) { JediumBehaviour toAdd = null; if (BehaviourTypeRegistry.BehaviourTypes.ContainsKey(new_beh.Key)) { Type behType = BehaviourTypeRegistry.BehaviourTypes[new_beh.Key]; if (behType != null) { JediumBehaviour plugin_beh = (JediumBehaviour)Activator.CreateInstance(behType, this); plugin_beh.FromDBSnapshot(new_beh.Value); toAdd = plugin_beh; } } if (toAdd != null) { _behaviours.Add(TYPEBEHAVIOUR.GetTypeIndex(new_beh.Key), toAdd); } } //OLD DB if (behaviours != null) { foreach (var beh in behaviours) { if (BehaviourTypeRegistry.BehaviourTypes.ContainsKey(beh.GetBehaviourType())) { //loaded behaviour string bname = beh.GetBehaviourType(); Type behType = BehaviourTypeRegistry.BehaviourTypes[bname]; if (behType != null) { JediumBehaviour plugin_beh = (JediumBehaviour)Activator.CreateInstance(behType, this); plugin_beh.FromSnapshot(beh); _behaviours.Add(TYPEBEHAVIOUR.GetTypeIndex(bname), plugin_beh); } } } } //special - transform if (!_behaviours.ContainsKey(TYPEBEHAVIOUR.GetTypeIndex("Transform"))) { _behaviours.Add(TYPEBEHAVIOUR.GetTypeIndex("Transform"), new JediumTransform(this, JediumTransformSnapshot.Identity)); } }
public async Task DoLogin(string name, string password) { Username = name; Password = password; try { string serverHash = RootComponents.Instance.AssetLoader.GetServerHash(); if (serverHash != RootComponents.Instance.ClientHash) { MainUI.Instance.ShowMessageBox($"Client/server incompatibility: \n {serverHash} \n {RootComponents.Instance.ClientHash}", () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); return; } } catch (Exception e) { if (e is SocketException) { MainUI.Instance.ShowMessageBox($"Can't connect to server: {e.Message}", () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); return; } else { MainUI.Instance.ShowMessageBox($"Error: {e.Message}", () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); return; } } _log.Info($"Logging in, login {name}, password {password}"); try { IActorRef asel = AkkaSystem.ActorSelection(MainSettings.ServerUrl) .ResolveOne(TimeSpan.Zero).Result; MainServer = asel.Cast <ConnectionRef>(); Tuple <bool, string, ServerInfo> loginInfo = await MainServer.DoLogin(name, password); if (!loginInfo.Item1) { MainUI.Instance.ShowMessageBox(loginInfo.Item2, () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); return; } UserId = loginInfo.Item3._loggedInUserId; foreach (var atype in loginInfo.Item3.AdditionalRegisteredBehaviours) { _log.Info($"Adding behavior type from plugin: {atype.Value}"); /// TYPEBEHAVIOUR.AddRegisteredType(); TYPEBEHAVIOUR.AddRegisteredTypeAndIndex(atype.Key, atype.Value); } //now start the connection process _mainClient = AkkaSystem .ActorOf(Props.Create(() => new ClientConnection(MainServer, _clientId, Guid.Parse(MainSettings.InitialScene))), "ClientConnection") .Cast <ClientConnectionRef>(); //await _mainClient.RegisterConnection(Guid.Empty, ""); } catch (Exception e) { MainUI.Instance.ShowMessageBox(e.ToString(), () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); Debug.Log(e); // throw; } //start updates //if (MainSettings.UseUpdateThread) //{ // _updateInterval = MainSettings.UpdateThreadInterval; // _updateThread = new Thread(this.TickUpdaters); // _updateThread.Start(); //} }
public override int GetBehaviourIndex() { return(TYPEBEHAVIOUR.GetTypeIndex("Take")); }
public int GetBehaviourType() { return(TYPEBEHAVIOUR.GetTypeIndex("TestBehaviour")); }
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); }
public override int GetBehaviourIndex() { return(TYPEBEHAVIOUR.GetTypeIndex("CharacterController")); }
//TODO - optimize it!! public virtual int GetComponentTypeIndex() { return(TYPEBEHAVIOUR.GetTypeIndex(GetComponentType())); }