forked from knah/VRCMods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Metadata.cs
62 lines (54 loc) · 2.61 KB
/
Metadata.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Globalization;
using LagFreeScreenshots.API;
using UnityEngine;
using VRC;
using VRC.Core;
namespace LagFreeScreenshots
{
[Obsolete("Use LagFreeScreenshots.API.MetadataV2")]
public class Metadata
{
public int ImageRotation;
public APIUser ApiUser;
public ApiWorldInstance WorldInstance;
public Vector3 Position;
public List<Tuple<Player, Vector3>> PlayerList;
public Metadata(int imageRotation, APIUser apiUser, ApiWorldInstance apiWorldInstance, Vector3 position, List<Tuple<Player, Vector3>> playerList)
{
ImageRotation = imageRotation;
ApiUser = apiUser;
WorldInstance = apiWorldInstance;
Position = position;
PlayerList = playerList;
}
public Metadata(MetadataV2 newMetadata) : this((int) newMetadata.ImageRotation, newMetadata.ApiUser,
newMetadata.WorldInstance, newMetadata.Position,
newMetadata.PlayerList.ConvertAll(it => Tuple.Create(it.Item1, it.Item2)))
{
}
public string ConvertToString()
{
var worldString = "null,0,Not in any world";
if (WorldInstance != null && WorldInstance.world != null)
worldString = WorldInstance.world.id + "," + WorldInstance.name + "," + WorldInstance.world.name;
var positionString = Position.x.ToString(CultureInfo.InvariantCulture) + "," + Position.y.ToString(CultureInfo.InvariantCulture) + "," + Position.z.ToString(CultureInfo.InvariantCulture);
return "lfs|2|author:"
+ ApiUser.id + "," + ApiUser.displayName
+ "|world:" + worldString
+ "|pos:" + positionString
+ (ImageRotation != -1 ? "|rq:" + ImageRotation : "")
+ "|players:" + string.Join(";", PlayerList.ConvertAll(new Converter<Tuple<Player, Vector3>, string>(PlayerListToString)));
}
private static string PlayerListToString(Tuple<Player, Vector3> playerData)
{
if (playerData.Item1 == null || playerData.Item1.prop_APIUser_0 == null) return "null,0,0,0,null";
return playerData.Item1.prop_APIUser_0.id + "," +
playerData.Item2.x.ToString("0.00", CultureInfo.InvariantCulture) + "," +
playerData.Item2.y.ToString("0.00", CultureInfo.InvariantCulture) + "," +
playerData.Item2.z.ToString("0.00", CultureInfo.InvariantCulture) + "," +
playerData.Item1.prop_APIUser_0.displayName;
}
}
}