diff --git a/Assets/Scripts/Api/Commands/GetBridgeType.cs b/Assets/Scripts/Api/Commands/GetBridgeType.cs new file mode 100644 index 000000000..991b1370e --- /dev/null +++ b/Assets/Scripts/Api/Commands/GetBridgeType.cs @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2021 LG Electronics, Inc. + * + * This software contains code licensed as described in LICENSE. + * + */ + +using SimpleJSON; +using UnityEngine; +using Simulator.Bridge; +using Simulator.Components; + +namespace Simulator.Api.Commands +{ + class GetBridgeType : ICommand + { + public string Name => "vehicle/bridge/type"; + + public void Execute(JSONNode args) + { + var uid = args["uid"].Value; + var api = ApiManager.Instance; + + if (api.Agents.TryGetValue(uid, out GameObject obj)) + { + var bridge = obj.GetComponentInChildren(); + if (bridge == null) + { + api.SendError(this, $"Agent '{uid}' is missing bridge client"); + } + else + { + var result = bridge.Bridge.Plugin.GetBridgeNameAttribute().Type; + api.SendResult(this, result); + } + } + else + { + api.SendError(this, $"Agent '{uid}' not found"); + } + } + } +} diff --git a/Assets/Scripts/Api/Commands/GetBridgeType.cs.meta b/Assets/Scripts/Api/Commands/GetBridgeType.cs.meta new file mode 100644 index 000000000..b0fbcd273 --- /dev/null +++ b/Assets/Scripts/Api/Commands/GetBridgeType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 958810dd048c7d7a890ab3ac940ac5bc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: