-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStagData.cs
More file actions
116 lines (104 loc) · 3.79 KB
/
Copy pathStagData.cs
File metadata and controls
116 lines (104 loc) · 3.79 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using UnityEngine;
namespace MoreStags {
public class StagData {
public static List<StagData> allStags = new();
public static Dictionary<string, StagData> dataByRoom = new();
private static int posNum = 1;
public string name;
public string scene;
public string region;
public int cost;
public bool leftSide;
public bool isCursed = false;
public string returnScene;
public int positionNumber;
public JsonVector2 _bellCoords;
public float _transitionX;
public float _transitionY;
public JsonVector2 _stagCoords;
public Vector3 bellPosition;
public Vector3 transitionPosition;
public Vector3 stagPosition;
public JsonVector2 _markerPosition;
public Vector2 markerPosition;
public bool isVanilla = false;
public string[] objectsToRemove;
public string[] enemiesToRemove;
public string[] childrenToRemove;
public (string, float, float) pinInfo;
public JsonSffTuple _pinInfo;
public void translate() {
allStags.Add(this);
positionNumber = posNum++;
dataByRoom.Add(scene, this);
if(!isVanilla) {
bellPosition = new Vector3(_bellCoords.x, _bellCoords.y + 1.1327f, 0.009f);
transitionPosition = new Vector3(_transitionX, (_transitionY == default ? _bellCoords.y : _transitionY) - 0.26f, 0.2f);
stagPosition = new Vector3(_stagCoords.x, _stagCoords.y + 1.9f, 0.02f);
}
if(_markerPosition == null) {
_markerPosition = new JsonVector2() { x = 1860, y = 570 };
}
markerPosition = new Vector2(_markerPosition.x / 431f - 4.28f, -_markerPosition.y / 297f + 4.2f);
if(objectsToRemove == null)
objectsToRemove = [];
if(enemiesToRemove == null)
enemiesToRemove = [];
if(childrenToRemove == null)
childrenToRemove = [];
pinInfo = _pinInfo == default ? (scene, bellPosition.x, bellPosition.y) : (_pinInfo.s, _pinInfo.x, _pinInfo.y);
}
public bool isActive(LocalData ld) {
return ld.activeStags.Contains(this);
}
public override bool Equals(object obj) {
if(obj is StagData data) {
return name == data.name;
}
return false;
}
public override int GetHashCode() {
return Tuple.Create(name, scene, region, cost).GetHashCode();
}
}
public class ParseJson {
private readonly string _jsonFilePath;
private readonly Stream _jsonStream;
private bool isPath;
public ParseJson(string jsonFilePath) {
_jsonFilePath = jsonFilePath;
isPath = true;
}
public ParseJson(Stream jsonStream) {
_jsonStream = jsonStream;
isPath = false;
}
public List<T> parseFile<T>() {
if(isPath) {
using StreamReader reader = new(_jsonFilePath);
var json = reader.ReadToEnd();
List<T> values = JsonConvert.DeserializeObject<List<T>>(json);
return values;
}
else {
using StreamReader reader = new(_jsonStream);
var json = reader.ReadToEnd();
List<T> values = JsonConvert.DeserializeObject<List<T>>(json);
return values;
}
}
}
public class JsonVector2 {
public float x;
public float y;
}
public class JsonSffTuple {
public string s;
public float x;
public float y;
}
}