示例#1
0
        public AgentConfig(VehicleData vehicleData)
        {
            Name       = vehicleData.Name;
            Connection = vehicleData.Bridge != null ? vehicleData.Bridge.ConnectionString : "";
            AssetGuid  = vehicleData.AssetGuid;
#if UNITY_EDITOR
            if (vehicleData.Id.EndsWith(".prefab"))
            {
                AssetBundle = vehicleData.Id;
                AssetGuid   = vehicleData.Id;
            }
            else
#endif
            {
                AssetBundle = Web.WebUtilities.GenerateLocalPath(vehicleData.AssetGuid, BundleConfig.BundleTypes.Vehicle);
            }
            Sensors = vehicleData.Sensors;

            //Load sensors from the configuration if no sensors are set
            if ((Sensors == null || Sensors.Length == 0) &&
                vehicleData.SensorsConfigurations != null && vehicleData.SensorsConfigurations.Length > 0)
            {
                Sensors = vehicleData.SensorsConfigurations[0].Sensors;
            }


            if (vehicleData.Bridge != null && !string.IsNullOrEmpty(vehicleData.Bridge.Type))
            {
                Bridge = BridgePlugins.Get(vehicleData.Bridge.Type);
                if (Bridge == null)
                {
                    throw new Exception($"Bridge {vehicleData.Bridge.Type} not found");
                }
            }
        }
示例#2
0
 public void Init(BridgePlugin plugin)
 {
     Bridge = new BridgeInstance(plugin);
 }