void Update() { if (service == null) { return; } if (!initialized) { return; } ExEntityLink link = GetComponent <ExEntityLink>(); timer += Time.unscaledDeltaTime; if (timer >= service.server.tickRate / 1000.0f) { timer -= service.server.tickRate / 1000.0f; Vector3 pos = transform.position; Quaternion rot = transform.rotation; if (link != null && ((pos - lastPos).magnitude > distanceThreshold) || (Quaternion.Angle(lastRot, rot) > angleThreshold)) { service.server.localClient.Call(mservice.RequestMove, Pack.Base64(link.id), Pack.Base64(pos), Pack.Base64(rot.eulerAngles)); lastRot = transform.rotation; lastPos = pos; } } }
public static void OnNameplateRemoved(Nameplate nameplate, ExEntityLink link) { NameplateHook hook = link.GetComponent <NameplateHook>(); if (hook != null) { NameplateHook.Destroy(hook); } }
public static void OnDisplayChanged(Ex.Typed comp, ExEntityLink link) { TypedHook hook = link.Require <TypedHook>(); if (hook.type == null || hook.type != comp.type) { link.gameObject.name = $"{comp.type}:{link.id}"; hook.type = comp.type; } }
public void On(EntityService.EntitySpawned spawn) { daemon.RunOnMainThread(() => { Guid id = spawn.id; GameObject gob = new GameObject("" + id); ExEntityLink link = gob.AddComponent <ExEntityLink>(); link.id = id; link.daemon = daemon; links[id] = link; }); }
public static void OnDisplayRemoved(Ex.Typed display, ExEntityLink link) { TypedHook hook = link.GetComponent <TypedHook>(); if (hook != null) { if (hook.type != null) { link.gameObject.name = "" + link.id; } DisplayHook.Destroy(hook); } }
public static void OnDisplayRemoved(Ex.Display display, ExEntityLink link) { DisplayHook hook = link.GetComponent <DisplayHook>(); if (hook != null) { if (hook.child != null) { GameObject.Destroy(hook.child.gameObject); } DisplayHook.Destroy(hook); } }
public static void OnNameplateChanged(Nameplate nameplate, ExEntityLink link) { NameplateHook hook = link.Require <NameplateHook>(); if (hook.name3d == null) { var prefab = Resources.Load <TextMeshPro>("Nameplate"); hook.name3d = Instantiate(prefab, hook.transform.position, hook.transform.rotation); hook.name3d.transform.SetParent(hook.transform); } if (hook.nname != nameplate.name) { hook.nname = nameplate.name; hook.name3d.text = hook.nname; } }
public static void OnDisplayChanged(Ex.Display display, ExEntityLink link) { DisplayHook hook = link.Require <DisplayHook>(); if (hook.child == null || hook.prefab != display.prefab) { if (hook.child != null) { GameObject.Destroy(hook.child.gameObject); } hook.prefab = display.prefab; Transform prefab = SafeLoad <Transform>(display.prefab, "Models/Error"); Transform copy = GameObject.Instantiate(prefab, link.transform); hook.child = copy; } hook.child.localPosition = display.position; hook.child.localRotation = Quaternion.Euler(display.rotation); }
public void Connect() { while (true) { TcpClient tcp = null; try { tcp = new TcpClient(targetHost, targetPort); Client client = new Client(tcp); client.AddService <DebugService>(); client.AddService <LoginService>(); client.AddService <EntityService>(); client.AddService <MapService>(); client.AddService <SyncService>(); //* // client.AddService<ExPlayerLink.>().Bind(this); client.AddService <ExEntityLink.ExEntityLinkService>().Bind(this); ExEntityLink.AutoRegisterComponentChangeCallbacks(); // ExEntityLink.Register<Ex.Terrain>(TerrainGenerator) //*/ client.ConnectSlave(); this.client = client; RunOnMainThread(() => { BroadcastMessage("OnExConnected", SendMessageOptions.DontRequireReceiver); }); } catch (Exception e) { Debug.LogWarning($"Error on connection: {e}"); if (tcp != null) { tcp.Dispose(); } } break; } }