public static void Request_Entity_Teleport(IdPositionRotation arg, Action callback = null, Action <ErrorInfo> onError = null) { Action <CmdId, object> wiredCallback = null; if (callback != null) { wiredCallback = (_, val) => callback(); } var apiCmd = new GenericAPICommand( CmdId.Request_Entity_Teleport, arg, wiredCallback, onError ?? noOpErrorHandler ); Broker.Execute(apiCmd); }
public void TestPosRotX() { var M = new IdPositionRotation() { id = 1, pos = new PVector3(), rot = new PVector3(45, 0, 0) }; var A = new IdPositionRotation() { id = 1, pos = new PVector3(20, 20, 20), rot = new PVector3() }; var R = EmpyrionBaseAlign.ExecAlign(M, A, Vector3.Zero, Vector3.Zero); Assert.AreEqual(19.799, Math.Round(R.pos.x, 3)); Assert.AreEqual(19.799, Math.Round(R.pos.y, 3)); Assert.AreEqual(20, Math.Round(R.pos.z, 3)); Assert.AreEqual(45, R.rot.x); Assert.AreEqual(0, R.rot.y); Assert.AreEqual(0, R.rot.z); }
public void TestAlignedPosRot() { var M = new IdPositionRotation() { id = 1, pos = new PVector3(), rot = new PVector3() }; var A = new IdPositionRotation() { id = 1, pos = new PVector3(20, 20, 20), rot = new PVector3() }; var R = EmpyrionBaseAlign.ExecAlign(M, A, Vector3.Zero, Vector3.Zero); Assert.AreEqual(20, R.pos.x); Assert.AreEqual(20, R.pos.y); Assert.AreEqual(20, R.pos.z); Assert.AreEqual(0, R.rot.x); Assert.AreEqual(0, R.rot.y); Assert.AreEqual(0, R.rot.z); }
public static IdPositionRotation ExecAlign(IdPositionRotation aMainBase, IdPositionRotation aBaseToAlign, Vector3 aShiftVector, Vector3 aRotateVector) { var posHomeBase = GetVector3(aMainBase.pos); var posAlignBase = GetVector3(aBaseToAlign.pos); var posHomeBaseRotBack = GetMatrix4x4(GetVector3(aMainBase.rot)); var posHomeBaseRot = posHomeBaseRotBack.Transpose(); var posNormAlignBaseTrans = posAlignBase - posHomeBase; var posNormAlignBaseRot = Vector3.Transform(posNormAlignBaseTrans, posHomeBaseRot); posNormAlignBaseRot = new Vector3(((int)Math.Round(posNormAlignBaseRot.X + 1)) / 2 * 2, ((int)Math.Round(posNormAlignBaseRot.Y + 1)) / 2 * 2, ((int)Math.Round(posNormAlignBaseRot.Z + 1)) / 2 * 2); var posNormAlignBaseRotBack = Vector3.Transform(posNormAlignBaseRot + aShiftVector, posHomeBaseRotBack); var posNormAlignBaseRotBackTans = posNormAlignBaseRotBack + posHomeBase; return(new IdPositionRotation() { id = aBaseToAlign.id, pos = GetVector3(posNormAlignBaseRotBackTans), rot = GetVector3(GetVector3(aMainBase.rot) + aRotateVector) }); }
private void EmpyrionBaseAlign_Event_Entity_PosAndRot(IdPositionRotation aData) { if (aData.id == CurrentAlignData.MainBaseId) { MainBase = aData; } if (aData.id == CurrentAlignData.BaseToAlignId) { BaseToAlign = aData; } if ((MainBase == null && CurrentAlignData.MainBaseId != 0) || BaseToAlign == null || WithinAlign) { return; } WithinAlign = true; if (!OriginalPosRot.ContainsKey(BaseToAlign.id)) { OriginalPosRot.Add(BaseToAlign.id, BaseToAlign); } var AlignResult = BaseToAlign = OriginalPosRot[BaseToAlign.id]; if (CurrentAlignData.MainBaseId != 0) { Log($"**HandleEmpyrionBaseAlign:ExecAlign {MainBase.id} pos= {MainBase.pos.x},{MainBase.pos.y},{MainBase.pos.z} rot= {MainBase.rot.x},{MainBase.rot.y},{MainBase.rot.z} Align: {BaseToAlign.id} pos= {BaseToAlign.pos.x},{BaseToAlign.pos.y},{BaseToAlign.pos.z} rot= {BaseToAlign.rot.x},{BaseToAlign.rot.y},{BaseToAlign.rot.z} Shift={CurrentAlignData.ShiftVector.X},{CurrentAlignData.ShiftVector.Y},{CurrentAlignData.ShiftVector.Z} Rotate={CurrentAlignData.RotateVector.X},{CurrentAlignData.RotateVector.Y},{CurrentAlignData.RotateVector.Z}", LogLevel.Message); PlayerLastAlignData[CurrentAlignData.PlayerId] = CurrentAlignData; AlignResult = ExecAlign(MainBase, BaseToAlign, CurrentAlignData.ShiftVector, CurrentAlignData.RotateVector); } Log($"**HandleEmpyrionBaseAlign:Align {(CurrentAlignData.MainBaseId == 0 ? "UNDO" : "")} setposition {BaseToAlign.id} {BaseToAlign.pos.x},{BaseToAlign.pos.y},{BaseToAlign.pos.z} setrotation {BaseToAlign.id} {BaseToAlign.rot.x},{BaseToAlign.rot.y},{BaseToAlign.rot.z} -> \n" + $"setposition {BaseToAlign.id} {AlignResult.pos.x},{AlignResult.pos.y},{AlignResult.pos.z} setrotation {BaseToAlign.id} {AlignResult.rot.x},{AlignResult.rot.y},{AlignResult.rot.z}", LogLevel.Message); GameAPI.Game_Request(CmdId.Request_Entity_Teleport, 1, AlignResult); WithinAlign = false; }
private void ProcessEvent_Entity_PosAndRot(IdPositionRotation idPos) { // from Request_Entity_PosAndRot ? DebugLog("Event_Entity_PosAndRot - Entity with id {0} position {1}, {2}, {3} rotation {4}, {5}, {6}", idPos.id, idPos.pos.x, idPos.pos.y, idPos.pos.z, idPos.rot.x, idPos.rot.y, idPos.rot.z); }
public async Task <bool> Request_Entity_Teleport(IdPositionRotation arg, CancellationToken ct) { return(await Broker.SendRequestAsync(CmdId.Request_Entity_Teleport, arg, ct)); }
public void HandleTeleportCommand(ChatInfo data, Dictionary <string, string> args) { this.Request_Player_Info(new Id(data.playerId), (info) => { if (info.permission < (int)PermissionType.GameMaster) { MessagePlayer(data.playerId, "You have insufficient permissions to teleport"); return; } var requesterName = playerInfoCache[data.playerId].playerName; var targetName = args["targetName"]; var destinationName = args["destinationName"]; var targetPlayerInfo = targetName == "me" ? info : VocallyGetCachedPlayerInfoFromName(targetName, data.playerId); var destinationPlayerInfo = destinationName == "me" ? info : VocallyGetCachedPlayerInfoFromName(destinationName, data.playerId); Action execute = () => { var msg = $@"{requesterName} is teleporting you to the location of {destinationPlayerInfo.playerName}"; MessagePlayer(targetPlayerInfo.entityId, msg); if (targetPlayerInfo.playfield != destinationPlayerInfo.playfield) { var teleportArg = new IdPlayfieldPositionRotation( targetPlayerInfo.entityId, destinationPlayerInfo.playfield, destinationPlayerInfo.pos, destinationPlayerInfo.rot ); this.Request_Player_ChangePlayerfield(teleportArg); } else { var teleportArg = new IdPositionRotation( targetPlayerInfo.entityId, destinationPlayerInfo.pos, destinationPlayerInfo.rot ); this.Request_Entity_Teleport(teleportArg); } }; this.Request_Player_Info(new Id(targetPlayerInfo.entityId), (result) => { targetPlayerInfo = result; this.Request_Player_Info(new Id(destinationPlayerInfo.entityId), result2 => { destinationPlayerInfo = result2; execute(); }); }); }); }
public void Request_Entity_Teleport(IdPositionRotation arg, Action callback = null, Action <ErrorInfo> onError = null) { Broker.Request_Entity_Teleport(arg, callback, onError); }
public static Task <object> Request_Entity_Teleport(IdPositionRotation param) { return(Broker.CreateCommandWithArgAndReturn <IdPositionRotation, object>(CmdId.Request_Entity_Teleport, param)); }
public static Task <object> Request_Entity_Teleport(IdPositionRotation param, Action callback, Action <ErrorInfo> onError = null) { return(Broker.CreateCommandWithArgAndReturn <IdPositionRotation, object>(CmdId.Request_Entity_Teleport, param, callback, onError)); }