private void OnTransformStructureRequested(CSteamID instigator, byte x, byte y, uint instanceId, ref Vector3 point, ref byte angleX, ref byte angleY, ref byte angleZ, ref bool shouldAllow) { if (!StructureManager.tryGetRegion(x, y, out var region)) { return; } var index = region.structures.FindIndex(k => k.instanceID == instanceId); var data = region.structures[index]; var drop = region.drops[index]; var nativePlayer = Provider.clients.FirstOrDefault(cl => cl?.playerID.steamID == instigator)?.player; var player = nativePlayer == null ? null : new UnturnedPlayer(nativePlayer); var @event = new UnturnedStructureTransformingEvent( new UnturnedStructureBuildable(data, drop), player, instigator, point, Quaternion.Euler(angleX * 2, angleY * 2, angleZ * 2)); Emit(@event); shouldAllow = [email protected]; point = @event.Point; var eulerAngles = @event.Rotation.eulerAngles; angleX = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2); angleY = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2); angleZ = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2); }
private void OnTransformStructureRequested(CSteamID instigator, byte x, byte y, uint instanceID, ref Vector3 point, ref byte angle_x, ref byte angle_y, ref byte angle_z, ref bool shouldAllow) { StructureRegion region = StructureManager.regions[x, y]; int index = region.structures.FindIndex(k => k.instanceID == instanceID); StructureData data = region.structures[index]; StructureDrop drop = region.drops[index]; Player nativePlayer = Provider.clients.FirstOrDefault(x => x?.playerID.steamID == instigator)?.player; UnturnedPlayer player = nativePlayer == null ? null : new UnturnedPlayer(nativePlayer); UnturnedStructureTransformingEvent @event = new UnturnedStructureTransformingEvent( new UnturnedStructureBuildable(data, drop), player, instigator, point, Quaternion.Euler(angle_x * 2, angle_y * 2, angle_z * 2)); Emit(@event); shouldAllow = [email protected]; point = @event.Point; Vector3 eulerAngles = @event.Rotation.eulerAngles; angle_x = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2); angle_y = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2); angle_z = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2); }