Elin Decompiled Documentation EA 23.348.1 Nightly
Loading...
Searching...
No Matches
ActorEx.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class ActorEx : Actor
5{
6 public enum Type
7 {
10 }
11
12 public static readonly List<ActorEx> instances = new List<ActorEx>();
13
14 public Type type;
15
16 public Card owner;
17
18 public bool alwaysOn;
19
20 public float outsideRoomVolume = 0.5f;
21
22 public float outsideLotVolume = 0.5f;
23
24 public int maxDistance;
25
26 public int minInterval = 1;
27
28 public int randomInterval;
29
30 private int next;
31
32 public AudioSource audioSource;
33
34 public SoundData data;
35
36 private int sameSoundCount = 1;
37
38 public void SetOwner(Card c)
39 {
40 owner = c;
41 if (type == Type.JukeBox)
42 {
43 data = EMono.core.refs.dictBGM.TryGetValue(owner.refVal);
44 }
45 if ((bool)audioSource && (bool)data)
46 {
47 audioSource.clip = data.clip;
48 audioSource.pitch = data.pitch * (1f + ((data.randomPitch == 0f) ? 0f : Rand.Range(0f - data.randomPitch, data.randomPitch)));
49 }
51 Refresh();
52 }
53
54 public float GetVolume()
55 {
57 {
58 return 0f;
59 }
60 Room room = EMono.pc.Cell.room;
61 Room room2 = owner.Cell.room;
62 bool flag = room2 == null || room2.data.atrium || !room2.HasRoof;
63 bool flag2 = room == room2 || (room2 == null && (room.data.atrium || !room.HasRoof));
64 bool num = flag2 || room?.lot == room2?.lot;
65 float num2 = ((alwaysOn || owner.isOn) ? 1f : 0f);
66 if (!num)
67 {
68 num2 *= outsideLotVolume;
69 }
70 if (!flag2 && room2 != null)
71 {
72 num2 *= outsideRoomVolume;
73 }
74 num2 /= (float)sameSoundCount;
75 if (num2 <= 0f)
76 {
77 return 0f;
78 }
79 if (type == Type.JukeBox)
80 {
81 num2 *= 0.5f + (flag ? 0.25f : 0f);
82 if (flag2)
83 {
84 int num3 = EMono.pc.Dist(owner);
85 if (num3 < 8)
86 {
87 float num4 = (float)(8 - num3) * SoundManager.current.jukeboxMod - 0.2f;
88 if (num4 < SoundManager.bgmDumpMod)
89 {
90 SoundManager.bgmDumpMod = num4;
91 }
92 }
93 }
94 }
95 return num2;
96 }
97
98 public void Refresh()
99 {
100 if (!data)
101 {
102 return;
103 }
105 {
106 Debug.LogWarning(owner);
107 return;
108 }
109 next--;
110 if (next > 0)
111 {
112 return;
113 }
115 if (maxDistance != 0)
116 {
117 int num = EMono.pc.Dist(owner);
118 if (base.gameObject.activeSelf)
119 {
120 if (num > maxDistance)
121 {
122 base.gameObject.SetActive(value: false);
123 return;
124 }
125 }
126 else
127 {
128 if (num > maxDistance)
129 {
130 return;
131 }
132 base.gameObject.SetActive(value: true);
133 }
134 }
135 float volume = GetVolume();
136 if (maxDistance != 0)
137 {
138 base.gameObject.SetActive(volume > 0f);
139 }
140 if ((bool)audioSource)
141 {
142 audioSource.volume = data.volume * volume;
143 if (!audioSource.isPlaying && volume > 0f)
144 {
145 audioSource.Play();
146 }
147 }
148 if (!(volume <= 0f))
149 {
150 Vector3 vector = owner.pos.PositionCenter();
151 vector.z = 0f;
152 vector.x -= 0.64f;
153 if ((bool)audioSource)
154 {
155 base.transform.position = vector;
156 }
157 else
158 {
159 SoundManager.current.Play(data, vector, volume);
160 }
161 }
162 }
163
164 public void Kill()
165 {
166 Object.Destroy(base.gameObject);
167 }
168
169 private void OnEnable()
170 {
171 if (!instances.Contains(this))
172 {
173 instances.Add(this);
174 }
176 }
177
178 private void OnDisable()
179 {
180 instances.Remove(this);
182 }
183
184 private void RefreshNearbyCounts()
185 {
186 foreach (ActorEx instance in instances)
187 {
188 if ((bool)instance)
189 {
190 instance.UpdateSameSoundCount();
191 }
192 }
193 }
194
195 private void UpdateSameSoundCount()
196 {
197 sameSoundCount = 1;
198 if (!audioSource || !audioSource.clip)
199 {
200 return;
201 }
202 sameSoundCount = 0;
203 float num = 4f;
204 AudioClip clip = audioSource.clip;
205 Vector3 position = base.transform.position;
206 foreach (ActorEx instance in instances)
207 {
208 if ((bool)instance && (bool)instance.audioSource && !(instance.audioSource.clip != clip) && !((instance.transform.position - position).sqrMagnitude > num))
209 {
211 }
212 }
213 sameSoundCount = Mathf.Max(1, sameSoundCount);
214 }
215}
void SetOwner(Card c)
Definition: ActorEx.cs:38
void Refresh()
Definition: ActorEx.cs:98
int next
Definition: ActorEx.cs:30
Type
Definition: ActorEx.cs:7
AudioSource audioSource
Definition: ActorEx.cs:32
void RefreshNearbyCounts()
Definition: ActorEx.cs:184
int randomInterval
Definition: ActorEx.cs:28
Card owner
Definition: ActorEx.cs:16
SoundData data
Definition: ActorEx.cs:34
static readonly List< ActorEx > instances
Definition: ActorEx.cs:12
float outsideRoomVolume
Definition: ActorEx.cs:20
int minInterval
Definition: ActorEx.cs:26
float GetVolume()
Definition: ActorEx.cs:54
bool alwaysOn
Definition: ActorEx.cs:18
int sameSoundCount
Definition: ActorEx.cs:36
void UpdateSameSoundCount()
Definition: ActorEx.cs:195
void Kill()
Definition: ActorEx.cs:164
int maxDistance
Definition: ActorEx.cs:24
void OnEnable()
Definition: ActorEx.cs:169
Type type
Definition: ActorEx.cs:14
float outsideLotVolume
Definition: ActorEx.cs:22
void OnDisable()
Definition: ActorEx.cs:178
Definition: Actor.cs:2
Definition: Card.cs:11
ICardParent parent
Definition: Card.cs:56
Point pos
Definition: Card.cs:60
int refVal
Definition: Card.cs:209
bool IsInstalled
Definition: Card.cs:2451
int Dist(Card c)
Definition: Card.cs:8205
bool isOn
Definition: Card.cs:545
Cell Cell
Definition: Card.cs:2107
Room room
Definition: Cell.cs:122
Zone currentZone
Definition: Chara.cs:259
Dictionary< int, BGMData > dictBGM
Definition: CoreRef.cs:388
CoreRef refs
Definition: Core.cs:51
bool keepAmbientBGM
Definition: DramaManager.cs:83
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static Chara pc
Definition: EMono.cs:13
static Zone _zone
Definition: EMono.cs:19
static LayerDrama Instance
Definition: LayerDrama.cs:20
DramaManager drama
Definition: LayerDrama.cs:28
ref Vector3 PositionCenter()
Definition: Point.cs:592
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:49
static int rnd(int max)
Definition: Rand.cs:59
Definition: Room.cs:4
bool HasRoof
Definition: Room.cs:29
Lot lot
Definition: Room.cs:21
bool isStarted
Definition: Zone.cs:76