Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitEffect.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using UnityEngine;
3
4public class TraitEffect : TraitItem
5{
6 public class Data
7 {
8 [JsonProperty]
9 public int sprite;
10
11 [JsonProperty]
12 public float interval;
13
14 [JsonProperty]
15 public float delay;
16
17 [JsonProperty]
18 public SerializableColor color = new SerializableColor(0, 0, 0, 0);
19 }
20
21 public float timer;
22
23 public Data _data;
24
25 public float Interval
26 {
27 get
28 {
29 if (data.interval != 0f)
30 {
31 return data.interval;
32 }
33 return 3f;
34 }
35 }
36
37 public int id
38 {
39 get
40 {
41 return owner.refVal;
42 }
43 set
44 {
45 owner.refVal = value;
46 }
47 }
48
50
51 public virtual string Path => "";
52
53 public override bool UseExtra => owner.isOn;
54
55 public Data data
56 {
57 get
58 {
59 if (_data == null)
60 {
61 _data = owner.GetObj<Data>(7);
62 if (_data == null)
63 {
64 _data = new Data();
65 owner.SetObj(7, _data);
66 }
67 }
68 return _data;
69 }
70 set
71 {
72 owner.SetObj(7, value);
73 }
74 }
75
76 public void Proc(Vector3 v = default(Vector3))
77 {
78 Effect effect = Effect.Get(Path);
79 if (data.color.Get().a != 0f)
80 {
82 }
83 if (data.sprite != 0)
84 {
85 Sprite sprite = effect.sprites[data.sprite % effect.sprites.Length];
86 ParticleSystem[] componentsInChildren = effect.GetComponentsInChildren<ParticleSystem>();
87 for (int i = 0; i < componentsInChildren.Length; i++)
88 {
89 ParticleSystem.ShapeModule shape = componentsInChildren[i].shape;
90 if (shape.shapeType == ParticleSystemShapeType.Sprite && (bool)shape.sprite)
91 {
92 shape.sprite = sprite;
93 shape.texture = sprite.texture;
94 }
95 }
96 }
97 if (effect.dirs.Length != 0)
98 {
99 effect.transform.localEulerAngles = effect.dirs[owner.dir % effect.dirs.Length];
100 }
101 effect.Play((!(v == default(Vector3))) ? v : ((owner.parent == EClass._zone) ? owner.renderer.position : EClass.pc.renderer.position));
102 }
103
104 public override void TrySetAct(ActPlan p)
105 {
106 base.TrySetAct(p);
107 if (p.input != ActInput.AllAction)
108 {
109 return;
110 }
111 if (Effect.sprites.Length != 0)
112 {
113 p.TrySetAct("actChangeSymbol", delegate
114 {
115 UIContextMenu uIContextMenu4 = EClass.ui.CreateContextMenuInteraction();
116 uIContextMenu4.AddSlider("adjustment", (float a) => ((int)a).ToString() ?? "", data.sprite, delegate(float b)
117 {
118 data.sprite = (int)b;
119 }, 0f, Effect.sprites.Length - 1, isInt: true, hideOther: false);
120 uIContextMenu4.Show();
121 return false;
122 }, owner);
123 }
124 if (Effect.systems.Length != 0)
125 {
126 p.TrySetAct("actChangeColor", delegate
127 {
128 EClass.ui.AddLayer<LayerColorPicker>().SetColor(data.color.Get(), new Color(0f, 0f, 0f, 0f), delegate(PickerState state, Color _c)
129 {
130 data.color.Set(_c);
131 });
132 return false;
133 }, owner);
134 }
135 p.TrySetAct("actChangeInterval", delegate
136 {
137 UIContextMenu uIContextMenu3 = EClass.ui.CreateContextMenuInteraction();
138 uIContextMenu3.AddSlider("adjustment", (float a) => (0.01f * (float)(int)(a * 10f)).ToString() ?? "", data.interval * 10f, delegate(float b)
139 {
140 data.interval = b * 0.1f;
141 }, 0f, 200f, isInt: true, hideOther: false);
142 uIContextMenu3.Show();
143 return false;
144 }, owner);
145 p.TrySetAct("actChangeDelay", delegate
146 {
147 UIContextMenu uIContextMenu2 = EClass.ui.CreateContextMenuInteraction();
148 uIContextMenu2.AddSlider("adjustment", (float a) => (0.01f * (float)(int)(a * 10f)).ToString() ?? "", data.delay * 10f, delegate(float b)
149 {
150 data.delay = b * 0.1f;
151 }, 0f, 200f, isInt: true, hideOther: false);
152 uIContextMenu2.Show();
153 return false;
154 }, owner);
155 if (!EClass.debug.enable)
156 {
157 return;
158 }
159 p.TrySetAct("actChangeType", delegate
160 {
161 UIContextMenu uIContextMenu = EClass.ui.CreateContextMenuInteraction();
162 uIContextMenu.AddSlider("adjustment", (float a) => a.ToString() ?? "", id, delegate(float b)
163 {
164 id = (int)b;
165 Proc();
166 }, 0f, EClass.core.refs.fireworks.Count - 1, isInt: true, hideOther: false);
167 uIContextMenu.Show();
168 return false;
169 }, owner);
170 }
171
172 public override int CompareTo(Card b)
173 {
174 return b.refVal - owner.refVal;
175 }
176}
ActInput
Definition: ActInput.cs:2
PickerState
Definition: PickerState.cs:2
ActInput input
Definition: ActPlan.cs:151
bool TrySetAct(string lang, Func< bool > onPerform, Card tc, CursorInfo cursor=null, int dist=1, bool isHostileAct=false, bool localAct=true, bool canRepeat=false)
Definition: ActPlan.cs:344
void SetObj(int id, object o)
Definition: BaseCard.cs:91
Vector3 position
Definition: CardRenderer.cs:21
Definition: Card.cs:11
int refVal
Definition: Card.cs:190
bool isOn
Definition: Card.cs:514
CardRenderer renderer
Definition: Card.cs:57
bool enable
Definition: CoreDebug.cs:285
List< Effect > fireworks
Definition: CoreRef.cs:347
CoreRef refs
Definition: Core.cs:51
Definition: EClass.cs:5
static Core core
Definition: EClass.cs:6
static Zone _zone
Definition: EClass.cs:20
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
static UI ui
Definition: EClass.cs:16
Definition: Effect.cs:7
Vector3[] dirs
Definition: Effect.cs:32
ParticleSystem[] systems
Definition: Effect.cs:30
Sprite[] sprites
Definition: Effect.cs:42
static Effect Get(Effect original)
Definition: Effect.cs:85
void Play(float delay, Point from, float fixY=0f, Point to=null, Sprite sprite=null)
Definition: Effect.cs:100
Effect SetParticleColor(Color c)
Definition: Effect.cs:289
SerializableColor Set(Color color)
SerializableColor color
Definition: TraitEffect.cs:18
override bool UseExtra
Definition: TraitEffect.cs:53
override void TrySetAct(ActPlan p)
Definition: TraitEffect.cs:104
virtual string Path
Definition: TraitEffect.cs:51
void Proc(Vector3 v=default(Vector3))
Definition: TraitEffect.cs:76
override int CompareTo(Card b)
Definition: TraitEffect.cs:172
float Interval
Definition: TraitEffect.cs:26
float timer
Definition: TraitEffect.cs:21
Card owner
Definition: Trait.cs:26
void Show(UIItem i)
UIContextMenuItem AddSlider(string text, Func< float, string > textFunc, float value, Action< float > action, float min=0f, float max=1f, bool isInt=false, bool hideOther=true, bool useInput=false)