Quellcode durchsuchen

fix users, beacons, zones

Виктор Шейко vor 4 Jahren
Ursprung
Commit
87855e96e8

+ 24 - 0
Assets/Scenes/Player.unity

@@ -5253,6 +5253,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 1525842414}
 --- !u!64 &200088482
@@ -5988,6 +5990,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 983703545}
 --- !u!64 &237993246
@@ -14048,6 +14052,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 1887821042}
 --- !u!64 &582083568
@@ -18592,6 +18598,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 1231341829}
 --- !u!64 &797767377
@@ -21084,6 +21092,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 1753594915}
 --- !u!64 &912165926
@@ -21607,6 +21617,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 2138739182}
 --- !u!64 &930698232
@@ -24143,6 +24155,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 161352806}
 --- !u!64 &1033498603
@@ -31160,6 +31174,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 280834745}
 --- !u!64 &1306056571
@@ -34512,6 +34528,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 110446093}
 --- !u!64 &1445987674
@@ -36212,6 +36230,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 1983633785}
 --- !u!64 &1506505215
@@ -37033,6 +37053,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 1871284746}
 --- !u!64 &1544664506
@@ -40014,6 +40036,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: f24c09c9ff5328246910630f90eea753, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  id: 0
+  name_zone: 
   ZoneColor: 1
   TextMesh: {fileID: 1559362896}
 --- !u!64 &1624499007

+ 1 - 1
Assets/Scripts/Components/WallCreate.cs

@@ -272,7 +272,7 @@ public class WallCreate : MonoBehaviour
         if(z == null) z = new Zone { id= Convert.ToUInt32(4000000000 + Zones[location_id].Count), location_id= location_id };   
         else
         {
-            zone.transform.position = new Vector3(Mathf.Abs(z.start_width), 0.05f, Mathf.Abs(z.start_height));
+            zone.transform.position = new Vector3(z.start_width, 0.05f, z.start_height);
             zone.transform.localScale = new Vector3(Mathf.Abs(z.end_width), 1, Mathf.Abs(z.end_height));
             zone.name = $"Zone_{z.id}";
             company.LocationZones.AddZone(z);

+ 1 - 1
Assets/Scripts/Components/ZoneInfo.cs

@@ -30,7 +30,7 @@ public class ZoneInfo : MonoBehaviour
             var user_name = Instantiate(text);
             user_name.fontSize = 12;
             user_name.transform.parent = scrollRect.content.transform;
-            user_name.text = user.name;
+            user_name.text = user.name_user;
             users[user.id] = user_name.gameObject;
         }
     }

+ 15 - 23
Assets/Scripts/Controllers/CompanyController.cs

@@ -22,6 +22,7 @@ public class CompanyController : MonoBehaviour
     public Dictionary<uint, Load> load_location_elements = new Dictionary<uint, Load>(); // флаги загрузки элементов локации
     public bool load_location = false;
     public Dictionary<uint, Location> locations; // список локаций
+    public Dictionary<uint, Dictionary<uint, User>> users; // список локаций
     public List<uint> locations_index; // сопоставление id с dropdown
                                        //public List<Marker> markers;
     public LocationZones LocationZones;
@@ -71,9 +72,7 @@ public class CompanyController : MonoBehaviour
 
                 BeaconsOnOff();
                 ZonesOnOff();
-            }
-
-        
+            }        
 
         if (load_location)
         {
@@ -128,7 +127,7 @@ public class CompanyController : MonoBehaviour
             if (l.Value.id < (uint)int.MaxValue)
             {
                 Destroy(l.Value.location);
-                foreach (var b in l.Value.beacons)
+                foreach (var b in l.Value.beacons.Values)
                     Destroy(b.panel_button);
                 foreach (var z in l.Value.zones)
                 {
@@ -141,16 +140,19 @@ public class CompanyController : MonoBehaviour
         }
 
         active_company = DropdownCompany.value;
-        Client.instance.company_id = (uint)(active_company + 1);       
+            
         if (player.users != null)
             foreach (var m in player.users)
             {
                 Destroy(m.Value.marker.gameObject);
                 Destroy(m.Value.marker_line.gameObject);
                 Destroy(m.Value.toggle_user);
-            } 
+                //m.Value.UserCompany();
+            }
+        Client.instance.company_id = (uint)(active_company + 1);
         User.SendGetUsers();
         player.users = new Dictionary<uint, User>();
+        //player.users = users[];
         Location.LocationsRequest(0);
     }
 
@@ -195,9 +197,6 @@ public class CompanyController : MonoBehaviour
             if (load_location_elements[location.id].walls)
             {
                 load_location_elements[location.id].walls = false;
-                //var walls = location.Walls ?? new GameObject();
-                //walls.name = "Walls";
-                //walls.transform.SetParent(location.location.transform);
 
                 var walls = location.location.transform.GetChild(1);
                 foreach (var w in location.walls)
@@ -210,15 +209,12 @@ public class CompanyController : MonoBehaviour
             }
 
             if (!editor.Beacons.ContainsKey(location.id))
-                editor.Beacons[location.id] = new List<Beacon>();
+                editor.Beacons[location.id] = new Dictionary<uint, Beacon>();
             if (load_location_elements[location.id].beacons)
             {
                 load_location_elements[location.id].beacons = false;
-                //var beacons = location.Beacons ?? new GameObject();
-                //beacons.name = "Beacons";
-                //beacons.transform.SetParent(location.location.transform);
 
-                foreach (var b in location.beacons)
+                foreach (var b in location.beacons.Values)
                 {
                     editor.AddBeacon(this, b);
                     if (ModeController.editor == true) b.beacon.GetComponent<BeaconController>().mode = BeaconController.Mode.Editor;
@@ -227,11 +223,7 @@ public class CompanyController : MonoBehaviour
             }
             if (load_location_elements[location.id].zones)
             {
-                load_location_elements[location.id].zones = false;
-                //var zones = location.Zones ?? new GameObject();               
-                //zones.name = "Zones";
-                //zones.transform.SetParent(location.location.transform);                
-
+                load_location_elements[location.id].zones = false;         
                
                 foreach (var z in location.zones)
                     z.go = Cursor.AddZone(Dialog, this, ZonesScroll, z);
@@ -241,10 +233,10 @@ public class CompanyController : MonoBehaviour
 
     public Location GetActiveLocation()
     {
-        //if (locations.Count > 0 && locations_index.Count > 0 && locations_index.Contains((uint)active_location))
-        //    if (locations.ContainsKey(locations_index[active_location]))
+        if(active_location >= 0)
         return locations[locations_index[active_location]];
-        //return null;
+        else
+        return null;
     }
 
     public Location GetLocation(uint id)
@@ -265,7 +257,7 @@ public class CompanyController : MonoBehaviour
     {
         if (beacons_view != ToggleBeacons.isOn)
         {
-            foreach (var b in locations[locations_index[active_location]].beacons)
+            foreach (var b in locations[locations_index[active_location]].beacons.Values)
                 b.beacon.SetActive(ToggleBeacons.isOn);
             beacons_view = ToggleBeacons.isOn;
         }

+ 9 - 6
Assets/Scripts/Controllers/EditorController.cs

@@ -34,7 +34,7 @@ public class EditorController : MonoBehaviour
 
     public Location newLocation;
 
-    public Dictionary<uint, List<Beacon>> Beacons = new Dictionary<uint, List<Beacon>>();
+    public Dictionary<uint, Dictionary<uint, Beacon>> Beacons = new Dictionary<uint, Dictionary<uint, Beacon>>(); // маяки локации
 
     CompanyController company;
     ModeController mode;
@@ -85,7 +85,7 @@ public class EditorController : MonoBehaviour
                 location = NewLocation,
                 walls = new List<Wall>(),
                 zones = new List<Zone>(),
-                beacons = new List<Beacon>(),
+                beacons = new Dictionary<uint, Beacon>(),
                 plane = plane,
                 texture_url = ""
             };
@@ -153,14 +153,17 @@ public class EditorController : MonoBehaviour
             if (WallCreate.Zones.ContainsKey(EditLocation.id)) location.zones = WallCreate.Zones[EditLocation.id];
             if (Beacons.ContainsKey(EditLocation.id))
             {
-                foreach(var b in Beacons[EditLocation.id])
+                foreach(var b in Beacons[EditLocation.id].Values)
                 {
                     var go = b.beacon;
                     b.x = go.transform.position.x;
                     b.y = go.transform.position.z;
                     b.z = go.transform.position.y;
+
+                    if (location.beacons.ContainsKey(b.id))
+                        location.beacons[b.id] = b;
                 }
-                location.beacons.AddRange(Beacons[EditLocation.id]);
+                //location.beacons.Add(Beacons[EditLocation.id]);
             }
 
             company.DropdownLocation.options.Last().text = location.name;
@@ -267,7 +270,7 @@ public class EditorController : MonoBehaviour
         {
             Destroy(beacon);
             Destroy(panel_button);
-            Beacons[location.id].Remove(b);
+            Beacons[location.id].Remove(b.id);
             if (PanelBeaconEdit.activeSelf) PanelBeaconEdit.SetActive(false);
         });
 
@@ -275,7 +278,7 @@ public class EditorController : MonoBehaviour
         b.beacon = beacon;
         b.panel_button = panel_button;
        
-        Beacons[location.id].Add(b);       
+        Beacons[location.id][b.id]=b;       
     }
 
     void BeaconEdit(Beacon b, string name_beacon)

+ 2 - 2
Assets/Scripts/Controllers/ModeController.cs

@@ -72,7 +72,7 @@ public class ModeController : MonoBehaviour
     {
         var company = Company.GetComponent<CompanyController>();
         var l = company.locations[company.locations_index[company.active_location]];
-        foreach (var b in l.beacons)
+        foreach (var b in l.beacons.Values)
             b.beacon.GetComponent<BeaconController>().mode = BeaconController.Mode.Player;
         company.LocationZones.gameObject.SetActive(true);
         company.UsersView.SetActive(true);
@@ -149,7 +149,7 @@ public class ModeController : MonoBehaviour
         if (company.active_location >= 0)
         {
             var l = company.locations[company.locations_index[company.active_location]];
-            foreach (var b in l.beacons)
+            foreach (var b in l.beacons.Values)
                 b.beacon.GetComponent<BeaconController>().mode = BeaconController.Mode.Editor;
         }
         company.LocationZones.gameObject.SetActive(false);

+ 36 - 102
Assets/Scripts/Controllers/PlayerController.cs

@@ -14,7 +14,6 @@ public class PlayerController : MonoBehaviour
     public static PlayerController instance;
     public Dictionary<uint, List<Structure>> Workers = new Dictionary<uint, List<Structure>>();
     public List<Structure> TestStructures = new List<Structure>();
-    //public List<Beacon> Beacons = new List<Beacon>();
 
     public GameObject WorkersList; // scroll content
 
@@ -27,17 +26,13 @@ public class PlayerController : MonoBehaviour
     public GameObject EndSec;
     public GameObject StartStopButton;
     public LocationZones locationZones;
-    //public GameObject ErrorDialog;
     public Dropdown DropdownMode;
     public Toggle ToggleLine;
     public Toggle ToggleDisappearance;
 
     public GameObject DatePicker;
     Camera camera;
-    //public Toggle projection;
 
-
-    //public GameObject LocationGameObject;
     public GameObject UserInfo;
 
     public GameObject Editor;
@@ -48,7 +43,6 @@ public class PlayerController : MonoBehaviour
     public enum Mode { RealTime = 0, History = 1, Stop = 2 };
     public static Mode active_mode = Mode.Stop;
     int mode = 0;
-    //public GameObject Time;
 
     Client client;
     CompanyController company;
@@ -60,9 +54,7 @@ public class PlayerController : MonoBehaviour
     Dictionary<uint, MarkerMoving> moving = new Dictionary<uint, MarkerMoving>(); // флаги начала движения
 
     const float INTERPOLATION_PERIOD = 0.1f;
-    //float time_realtime = 0;
     float time_draw = 0;
-    //public List<User> users = new List<User>();
     public bool users_load = false;
     public bool beacons_load = false;
 
@@ -82,36 +74,21 @@ public class PlayerController : MonoBehaviour
         company = CompanyController.instance;
         editor = Editor.GetComponent<EditorController>();
         camera = Camera.main;
-        users = new Dictionary<uint, User>();
+        //users = new Dictionary<uint, User>();
 
         Date = DatePicker.GetComponent<DateTimePicker>();
-        //locations.Add(new Location { id = 1, name = "1 Братск" });
-        //locations.Add(new Location { id = 22, name = "22 Офис Ижевск" });
-        //locations.Add(new Location { id = 25, name = "25" });
-        //locations.Add(new Location { id = 26, name = "26 Братское (вагрант)" });
-        //foreach (var l in locations)
-        //    DropdownLocation.options.Add(new Dropdown.OptionData(l.name));
-
-        //for (int i = 0; i < Locations.transform.childCount; i++)
-        //    maps.Add(Locations.transform.GetChild(i).gameObject);
-
-
-
         //Client.LocationsRequest();
 
         var broadcast_stop = UserInfo.transform.GetChild(1).GetChild(1).GetComponent<Button>();
         broadcast_stop.onClick.AddListener(() => BroadcastStop());
     }
 
-
-
     // Update is called once per frame
     void Update()
     {
         if (DropdownMode.value != mode)
             СhangeMode();
 
-
         time_draw += Time.deltaTime;
         if (time_draw >= INTERPOLATION_PERIOD)
         {
@@ -119,63 +96,37 @@ public class PlayerController : MonoBehaviour
             time_draw -= INTERPOLATION_PERIOD;
         }
 
-        //if (active_mode == Mode.RealTime && !starting)
-        //{
-        //    foreach (var m in markers)
-        //    {
-        //        if (m.toggle.isOn)
-        //        {
-        //            Debug.LogWarning($"send {m.acc_id}");
-        //            var index = company.locations_index[company.active_location];
-        //            client.CoordinatesRequest(0, 0, 1, company.locations[index].id, m.acc_id);
-        //            //end_send[m.acc_id] = false;
-        //        }
-        //    }
-        //    starting = true;
-        //}\\\\\
-
-        if (ToggleLine.isOn)
-        {
-            foreach (var u in users)
-                u.Value.marker_line.gameObject.SetActive(true);
-            ToggleDisappearance.interactable = true;
-        }
-        else
+        if (users != null)
         {
-            foreach (var u in users)
+            if (ToggleLine.isOn)
             {
-                u.Value.marker_line.gameObject.SetActive(false);
-                u.Value.marker_line.positionCount = 0;
+                foreach (var u in users)
+                    u.Value.marker_line.gameObject.SetActive(true);
+                ToggleDisappearance.interactable = true;
+            }
+            else
+            {
+                foreach (var u in users)
+                {
+                    u.Value.marker_line.gameObject.SetActive(false);
+                    u.Value.marker_line.positionCount = 0;
+                }
+                ToggleDisappearance.interactable = false;
             }
-            ToggleDisappearance.interactable = false;
-        }
 
-        if (users_load)
-        {
-            users_load = false;
-            foreach (var u in users.OrderBy(u => u.Value.id))
+            if (users_load)
             {
-                //u.Value.WorkerMarker(u.Value, Color.green, WorkersList, BroadcastStart);
-                //u.Value.toggle_user.transform.SetParent(WorkersList.transform);
-                u.Value.SetParam(BroadcastStart);
+                users_load = false;
+                foreach (var u in users.OrderBy(u => u.Value.id))
+                {
+                    u.Value.SetParam(BroadcastStart);
 
-                if (DropdownMode.value == 0) u.Value.toggle_user.SetActive(u.Value.online);
-                else u.Value.toggle_user.SetActive(true);
+                    if (DropdownMode.value == 0) u.Value.toggle_user.SetActive(u.Value.online);
+                    else u.Value.toggle_user.SetActive(true);
+                }
             }
         }
-
-        //LoadMaps(DropdownLocation, Locations);
-
-
-
-        //if (locations.Any() && AuthorizationController.success)
-        //{
-        //    active_location = DropdownLocation.value;
-        //    LoadLocation(locations[active_location]);
-        //}
-    }
-
-  
+    }  
 
     /// <summary>
     /// Смена положения маркера
@@ -207,8 +158,6 @@ public class PlayerController : MonoBehaviour
         }
     }
 
-
-
     /// <summary>
     /// Запуск отрисовки
     /// </summary>
@@ -270,8 +219,6 @@ public class PlayerController : MonoBehaviour
         }
     }
 
-
-
     public void StopProgress()
     {
         StartStopButton.transform.GetChild(0).GetComponent<Text>().text = "Отобразить";
@@ -371,17 +318,17 @@ public class PlayerController : MonoBehaviour
     /// Отображение маяков
     /// </summary>
     /// <param name="b"></param>
-    public static void AddBeacon(Beacon b)
-    {
-        var beacon = Instantiate(Resources.Load("GameObjects/Beacon", typeof(GameObject))) as GameObject;
-        beacon.transform.position = new Vector3(b.x, 0.5f, b.y);
-        beacon.name = $"BeaconButton_{b.id}";
-        beacon.GetComponent<BeaconController>().info = false;
-        beacon.transform.SetParent(GameObject.Find("Beacons").transform);
-        beacon.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent<Text>().text = $"{b.id}\nuuid={b.uuid}\nmajor={b.major}\nminor={b.minor}";
-
-        b.beacon = beacon;
-    }
+    //public static void AddBeacon(Beacon b)
+    //{
+    //    var beacon = Instantiate(Resources.Load("GameObjects/Beacon", typeof(GameObject))) as GameObject;
+    //    beacon.transform.position = new Vector3(b.x, 0.5f, b.y);
+    //    beacon.name = $"BeaconButton_{b.id}";
+    //    beacon.GetComponent<BeaconController>().info = false;
+    //    beacon.transform.SetParent(GameObject.Find("Beacons").transform);
+    //    beacon.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent<Text>().text = $"{b.id}\nuuid={b.uuid}\nmajor={b.major}\nminor={b.minor}";
+
+    //    b.beacon = beacon;
+    //}
 
     void OnGUI()
     {
@@ -455,19 +402,6 @@ public class PlayerController : MonoBehaviour
         }
     }
 
-    /// <summary>
-    /// Загрузка объектов локации
-    /// </summary>
-    /// <param name="location"></param>
-    //public void LoadLocation(Location location)
-    //{
-    //    print("PlayerController.LoadLocation");
-    //    if (load_location_elements.ContainsKey(location.id))
-    //    {
-    //        location.Load();
-    //    }
-    //}
-
     public void BroadcastStart(uint id)
     {
         if (user_broadcast.HasValue)
@@ -482,7 +416,7 @@ public class PlayerController : MonoBehaviour
             client.ImageStreamStartSend(id);
             user_broadcast = id;
             var name = UserInfo.transform.GetChild(1).GetChild(0).GetComponent<Text>();
-            name.text = $"{id} {users[id].name}";
+            name.text = $"{id} {users[id].name_user}";
             name.GetComponent<RectTransform>().sizeDelta = new Vector2(name.preferredWidth, 30);
 
             var camera_button = users[id].toggle_user.transform.GetChild(1).GetComponent<Button>();

+ 2 - 0
Assets/Scripts/Controllers/ZoneController.cs

@@ -5,6 +5,8 @@ using UnityEngine.UI;
 
 public class ZoneController : MonoBehaviour
 {
+    public uint id;
+    public string name_zone;
     public bool ZoneColor = true;
     public TextMesh TextMesh;
 

+ 2 - 0
Assets/Scripts/Controllers/ZonesEditorController.cs

@@ -57,6 +57,8 @@ public class ZonesEditorController : MonoBehaviour
         var zone = Instantiate(Resources.Load("GameObjects/Zone", typeof(GameObject))) as GameObject;
         zone.transform.SetParent(transform);
         var zoneController = zone.GetComponent<ZoneController>();
+        zoneController.id = z.id;
+        zoneController.name_zone = z.name;
         zoneController.Rename($"Zone_{Zones.Count + 1}", z.name);
 
         if (z != null)

+ 3 - 2
Assets/Scripts/Models/Beacon.cs

@@ -97,7 +97,8 @@ public class Beacon
             read += 80;
 
             //PlayerController.Beacons.Add(new Beacon { id = id, location_id = lid, uuid = uuid, x = x, y = y, z = z, minor = minor, major = major, enabled = enabled == 1 ? true : false });
-            company.locations[lid].beacons.Add(new Beacon { vagrant_label = label, id = id, location_id = lid, uuid = uuid, x = x, y = y, z = z, minor = minor, major = major, mac = mac, enabled = enabled == 1 ? true : false });
+            if(company.locations[lid].beacons.ContainsKey(id))
+            company.locations[lid].beacons[id]=new Beacon { vagrant_label = label, id = id, location_id = lid, uuid = uuid, x = x, y = y, z = z, minor = minor, major = major, mac = mac, enabled = enabled == 1 ? true : false };
             location_id = lid;
         }
         Debug.Log("Beacons loaded: " + num);
@@ -112,7 +113,7 @@ public class Beacon
         //{            
         //    return;
         //}
-        CompanyController.instance.locations[locationId].beacons = new List<Beacon>();
+        CompanyController.instance.locations[locationId].beacons = new Dictionary<uint, Beacon>();
         Client.SendFourByteParamPacket(48, locationId);
     }
 }

+ 3 - 3
Assets/Scripts/Models/Location.cs

@@ -12,7 +12,7 @@ public class Location
     public uint id { get; set; }
     public string name { get; set; }
     public List<Wall> walls { get; set; }
-    public List<Beacon> beacons { get; set; }
+    public Dictionary<uint, Beacon> beacons { get; set; }
     public GameObject plane { get; set; }
     public string texture_url { get; set; }
     public List<Zone> zones { get; set; }
@@ -71,7 +71,7 @@ public class Location
         {
             z.Save();
         }
-        Beacon.Save(beacons);
+        Beacon.Save(beacons.Values.ToList());
     }
 
     public void Load()
@@ -144,7 +144,7 @@ public class Location
     {
         location.SetActive(active);
         if (beacons != null)
-            foreach (var b in beacons)
+            foreach (var b in beacons.Values)
                 if (b.panel_button != null)
                     b.panel_button.SetActive(active);
         if (zones != null)

+ 20 - 7
Assets/Scripts/Models/User.cs

@@ -10,7 +10,8 @@ public class User
 {
     enum GetUserFlags { CompanyID, UserID };
     public uint id { get; set; }
-    public string name { get; set; }
+    public uint company_id { get; set; }
+    public string name_user { get; set; }
     public bool online { get; set; }
 
     public Toggle toggle { get; set; }
@@ -36,8 +37,9 @@ public class User
             var name = Encoding.UTF8.GetString(bytedata, read + 6, lenname);
             read += 6 + lenname;
             Debug.Log($"user received id {id} lenname {lenname} name {name} online {online} companyId {companyId}");
-            player.users.Add(id, new User { id = id, name = name, online = online!=0 });
+            player.users.Add(id, new User { id = id, name_user = name, online = online!=0, company_id=companyId });
             WorkerMarker(player.users[id], Color.green);
+
         }
         player.users_load = true;
     }
@@ -88,8 +90,9 @@ public class User
         }
         else
         {
-            Debug.LogError($"LogInOut accid {accid} not found");
-            SendGetUser(accid);
+            //Debug.LogError($"LogInOut accid {accid} not found");
+            Debug.Log($"LogInOut accid {accid} not found in company");
+            //SendGetUser(accid);
         }
 
         Debug.Log($"LogInOut accid {accid} cmd {cmd}");
@@ -139,13 +142,12 @@ public class User
         var toggle_user = UnityEngine.Object.Instantiate(Resources.Load("GameObjects/ToggleUser", typeof(GameObject))) as GameObject;
         toggle_user.name = $"{user.id}";
         var toggle = toggle_user.transform.GetChild(0).GetComponent<Toggle>();
-        toggle.transform.GetChild(1).gameObject.GetComponent<Text>().text = $"{user.id} {user.name}";
+        toggle.transform.GetChild(1).gameObject.GetComponent<Text>().text = $"{user.id} {user.name_user}";
         //toggle_user.transform.SetParent(WorkersList.transform);
         toggle.isOn = false;
         //var camera_button = toggle_user.transform.GetChild(1).GetComponent<Button>();
         //camera_button.onClick.AddListener(() => BroadcastStart(user.id));
 
-
         var marker = UnityEngine.Object.Instantiate(Resources.Load("GameObjects/Capsule", typeof(GameObject))) as GameObject;
         marker.name = $"marker_{user.id}";
         marker.transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).GetComponent<Text>().text = $"{user.id}";
@@ -155,6 +157,7 @@ public class User
 
         marker.GetComponent<Renderer>().material.color = color; // UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
         marker.GetComponent<LabelObjectScript>().UserId = user.id;
+
         var color_line = UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
         var marker_line = UnityEngine.Object.Instantiate(Resources.Load("GameObjects/Line", typeof(LineRenderer))) as LineRenderer;
         marker_line.name = $"marker_line_{user.id}";
@@ -176,5 +179,15 @@ public class User
     {        
         var camera_button = toggle_user.transform.GetChild(1).GetComponent<Button>();
         camera_button.onClick.AddListener(() => BroadcastStart(id));
-    }    
+    }
+
+    /// <summary>
+    /// Отображение пользователей текущей компании
+    /// </summary>
+    public void UserCompany()
+    {
+        var active = CompanyController.instance.active_location + 1 == company_id;
+        toggle_user.SetActive(active);
+        marker.SetActive(active);
+    }
 }

+ 1 - 1
Assets/Scripts/Net/Client.cs

@@ -191,7 +191,7 @@ public class Client : MonoBehaviour
 
                 var user = User.Find(remoteScript_.SessionCallerId);
                 if (user != null)
-                    remoteScript_.callerName_.text = $"Звонок от [{ user.id }] { user.name} Проблема с командой: [{taskId}] {name}";
+                    remoteScript_.callerName_.text = $"Звонок от [{ user.id }] { user.name_user} Проблема с командой: [{taskId}] {name}";
                 else
                     remoteScript_.callerName_.text = $"Звонок от сотрудника  [ID: { remoteScript_.SessionCallerId }] Проблема с командой: [{taskId}]  {name}";
                 break;

+ 1 - 1
Assets/Scripts/RemoteAssist/RemoteClickAction.cs

@@ -182,7 +182,7 @@ public class RemoteClickAction : MonoBehaviour, IVideoCallSession
         callCanvas_.SetActive(true);
         var user = User.Find(callerID);
         if (user != null)
-            callerName_.text = "Звонок от [" + callerID + "] "+ user.name;
+            callerName_.text = "Звонок от [" + callerID + "] "+ user.name_user;
         else
             callerName_.text = "Звонок от сотрудника  [ID: " + callerID + "]";
     }