public async Task <object> Post(string nameSpace, string className, string methodName) { string commandName = String.Format("{0}.{1}", nameSpace, className); Type commandType = Utilities.LoadType(commandName); if (commandType == null) { throw new InvalidOperationException(commandName + "在服务端未定义"); } if (!commandType.IsPublic) { throw new InvalidOperationException(commandName + "在服务端未公开"); } Dictionary <string, object> body = Utilities.JsonDeserialize <Dictionary <string, object> >(await Request.ReadBodyAsStringAsync()); foreach (MethodInfo methodInfo in commandType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public)) { if (String.CompareOrdinal(methodInfo.Name, methodName) == 0) { ParameterInfo[] parameterInfos = methodInfo.GetParameters(); if (parameterInfos.Length == body.Count) { List <object> args = new List <object>(parameterInfos.Length); try { foreach (ParameterInfo parameterInfo in parameterInfos) { if (body.TryGetValue(parameterInfo.Name, out object value)) { args.Add(Utilities.ChangeType(value, parameterInfo.ParameterType)); } } } catch { continue; } if (args.Count != parameterInfos.Length) { continue; } ControllerRole controllerRole = ControllerRole.Fetch(commandType.GetTypeInfo(), methodInfo); await controllerRole.CheckValidityAsync(User.Identity, Request.HttpContext); return(controllerRole.MethodInfo.Invoke(null, args.ToArray())); } } } throw new NotImplementedException(String.Format("{0}.{1}.{2}", nameSpace, className, methodName)); }
public IList <string> Get() { List <string> result = new List <string>(); foreach (ControllerRole controllerRole in ControllerRole.FetchAll(Database.Default)) { foreach (string role in controllerRole.Roles) { foreach (string s in role.Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (!result.Contains(s)) { result.Add(s); } } } } return(result); }
public static void LMUAdd(MatrixD?leftMult, MatrixD origin, ControllerRole role, int reference) { LMUEntries.Remove(reference); LMUEntries.Add(reference, new LMUEntry(leftMult, origin, role)); }
public static void LMUAdd(MatrixD?leftMult, MatrixD origin, ControllerRole role, int reference) { }
public LMUEntry(MatrixD?leftMult, MatrixD matrix, ControllerRole role) { LeftMult = leftMult; origin = matrix; assignedController = role; }
private void SwitchWeapon(ref IMyHandheldGunObject<MyDeviceBase> weapon, ref MyVRWeaponInfo weaponInfo, List<MyVRWeaponInfo> weapons, ControllerRole role, Vector2? touchpadPos) { int currentIndex = -1; if (weapon != null) { for (int i = 0; i < weapons.Count; ++i) { var info = weapons[i]; if (info.DefinitionId == weapon.DefinitionId) { currentIndex = i; break; } } } int nextIndex = 0; if (touchpadPos != null) { Vector2 pos = touchpadPos.Value; if (touchpadPos != Vector2.Zero) { pos.Normalize(); float anglePerWeaponSector = 360f / weapons.Count; float dot = Vector2.Dot(Vector2.UnitX, pos); float angle = (float)Math.Acos(Math.Abs(dot)); if (pos.Y >= 0) { if (dot < 0) angle = 180 - angle; } else { if (dot < 0) angle = 180 + angle; else angle = 360 - angle; } nextIndex = (int)Math.Floor(angle / anglePerWeaponSector); Debug.Assert(nextIndex < weapons.Count); } } if (nextIndex == currentIndex) return; if (weapon != null) { weapon.OnControlReleased(); MyEntity weaponEntity = (MyEntity)weapon; weaponEntity.Close(); weapon = null; } { weaponInfo = weapons[nextIndex]; weapon = CreateWeapon(weaponInfo.DefinitionId, weaponInfo.Reference); weapon.OnControlAcquired(null); MyEntity weaponEntity = (MyEntity)weapon; } var gunBase = weapon.GunBase as MyGunBase; Matrix holdingMatrix = gunBase != null ? gunBase.m_holdingDummyMatrix : Matrix.Identity; MyOpenVR.LMUAdd(holdingMatrix, m_worldMatrixOriginal, role, weaponInfo.Reference); }
public LMUEntry(MatrixD? leftMult, MatrixD matrix, ControllerRole role) { LeftMult = leftMult; origin = matrix; assignedController = role; }
public static void LMUAdd( MatrixD? leftMult, MatrixD origin, ControllerRole role, int reference) { LMUEntries.Remove(reference); LMUEntries.Add(reference, new LMUEntry(leftMult, origin, role)); }
public static void LMUAdd(MatrixD? leftMult, MatrixD origin, ControllerRole role, int reference) { }
private void SwitchWeapon(ref IMyHandheldGunObject <MyDeviceBase> weapon, ref MyVRWeaponInfo weaponInfo, List <MyVRWeaponInfo> weapons, ControllerRole role, Vector2?touchpadPos) { int currentIndex = -1; if (weapon != null) { for (int i = 0; i < weapons.Count; ++i) { var info = weapons[i]; if (info.DefinitionId == weapon.DefinitionId) { currentIndex = i; break; } } } int nextIndex = 0; if (touchpadPos != null) { Vector2 pos = touchpadPos.Value; if (touchpadPos != Vector2.Zero) { pos.Normalize(); float anglePerWeaponSector = 360f / weapons.Count; float dot = Vector2.Dot(Vector2.UnitX, pos); float angle = (float)Math.Acos(Math.Abs(dot)); if (pos.Y >= 0) { if (dot < 0) { angle = 180 - angle; } } else { if (dot < 0) { angle = 180 + angle; } else { angle = 360 - angle; } } nextIndex = (int)Math.Floor(angle / anglePerWeaponSector); Debug.Assert(nextIndex < weapons.Count); } } if (nextIndex == currentIndex) { return; } if (weapon != null) { weapon.OnControlReleased(); MyEntity weaponEntity = (MyEntity)weapon; weaponEntity.Close(); weapon = null; } { weaponInfo = weapons[nextIndex]; weapon = CreateWeapon(weaponInfo.DefinitionId, weaponInfo.Reference); weapon.OnControlAcquired(null); MyEntity weaponEntity = (MyEntity)weapon; } var gunBase = weapon.GunBase as MyGunBase; Matrix holdingMatrix = gunBase != null ? gunBase.m_holdingDummyMatrix : Matrix.Identity; MyOpenVR.LMUAdd(holdingMatrix, m_worldMatrixOriginal, role, weaponInfo.Reference); }
public static TrackedDevice GetController(ControllerRole type) { uint index = OpenVR.System.GetTrackedDeviceIndexForControllerRole((ETrackedControllerRole)(int)type); return(new TrackedDevice(index)); }