10 public static void CancelKeepPlaying()
15 AI_PlayMusic.keepPlaying =
false;
16 AI_PlayMusic.playingTool =
null;
22 public override bool ShowProgress
32 public override bool CancelWhenDamaged
46 if (this.tool !=
null && this.tool !=
EClass.pc.Tool)
55 public override IEnumerable<
AIAct.Status> Run()
57 if (this.tool ==
null)
59 this.tool = (this.owner.IsPC ? this.owner.Tool : this.owner.things.Find<
TraitToolMusic>());
61 if (this.tool ==
null && !this.owner.IsPCFaction &&
EClass.rnd(20) == 0)
63 this.tool = this.owner.AddThing(
ThingGen.Create(
"lute", -1, -1),
true, -1, -1);
65 if (this.tool ==
null)
67 yield
return this.Cancel();
69 if (this.tool.parent is
Zone)
71 yield
return base.DoGoto(this.tool.pos,
this.tool.pos.IsBlocked ? 1 : 0,
false,
null);
73 if (this.owner.IsPCC &&
EClass.game.config.preference.keepPlayingMusic)
75 AI_PlayMusic.keepPlaying =
true;
76 AI_PlayMusic.playingTool = this.tool;
77 EInput.Consume(
true, 10);
85 if (this.owner.IsPC &&
EClass.player.playingSong !=
null &&
EClass.player.playingSong.idTool ==
this.tool.id)
87 this.playing =
EClass.player.playingSong;
88 idSong =
EClass.player.playingSong.id;
89 song =
EClass.player.knownSongs[
EClass.player.playingSong.id];
91 if (this.playing ==
null)
93 string id = this.tool.id;
94 uint num = <PrivateImplementationDetails>.ComputeStringHash(
id);
95 if (num <= 3078472054U)
97 if (num <= 1172811742U)
99 if (num <= 390330866U)
101 if (num != 63985367U)
103 if (num != 390330866U)
107 if (!(
id ==
"harpsichord"))
111 idSong =
"harpsichord_goldberg";
116 if (!(
id ==
"taiko"))
124 else if (num != 773192040U)
126 if (num != 1172811742U)
130 if (!(
id ==
"piano"))
134 idSong =
"piano_kanon";
139 if (!(
id ==
"guitar_ash"))
143 idSong =
"guitar_caccini";
147 else if (num <= 2565162886U)
149 if (num != 2166422584U)
151 if (num != 2565162886U)
155 if (!(
id ==
"trumpet"))
159 idSong =
"trumpet_practice";
162 else if (!(
id ==
"instrument_violin"))
167 else if (num != 2938588943U)
169 if (num != 3078472054U)
173 if (!(
id ==
"guitar_efrond"))
177 idSong =
"guitar_dusk";
182 if (!(
id ==
"guitar"))
186 idSong =
"guitar_air";
190 else if (num <= 3559073827U)
192 if (num <= 3438029316U)
194 if (num != 3163500768U)
196 if (num != 3438029316U)
200 if (!(
id ==
"piano_gould"))
204 idSong =
"piano_gould";
213 idSong =
"mic_rachmaninoff";
217 else if (num != 3502455904U)
219 if (num != 3559073827U)
223 if (!(
id ==
"panty"))
234 idSong =
"harp_komori";
238 else if (num <= 3841196189U)
240 if (num != 3758837070U)
242 if (num != 3841196189U)
250 idSong =
"guitar_sad";
255 if (!(
id ==
"mokugyo"))
263 else if (num != 3981110062U)
265 if (num != 4124199536U)
267 if (num != 4156158084U)
271 if (!(
id ==
"piano2"))
275 idSong =
"piano_neko";
280 if (!(
id ==
"stradivarius"))
284 idSong =
"violin_furusato";
290 if (!(
id ==
"cello"))
294 idSong =
"cello_prelude";
297 idSong =
"violin_chaconne";
300 idSong =
"violin_chaconne";
302 if (this.owner.IsPC &&
EClass.player.knownSongs.ContainsKey(idSong))
304 song =
EClass.player.knownSongs[idSong];
311 EClass.player.knownSongs[idSong] = song;
317 idTool = this.tool.id
321 EClass.player.playingSong = this.playing;
326 (
EClass.Sound.GetData(
"Instrument/" + idSong) as BGMData).song.index = this.playing.index;
328 if (Application.isEditor &&
this.owner.IsPC)
333 List<Chara> reacted =
new List<Chara>();
337 cancelWhenMoved =
false,
338 showProgress =
false,
339 canProgress = (() => this.tool !=
null && !this.tool.isDestroyed),
340 onProgressBegin = delegate()
342 this.owner.Say(
"music_start", this.owner, this.tool,
null,
null);
343 this.owner.ShowEmo(Emo.happy, 3f,
false);
344 if (this.tool !=
null && this.tool.ExistsOnMap)
346 this.owner.LookAt(this.tool);
348 this.owner.PlayAnime(AnimeID.PlayMusic,
false);
352 if (this.playing.mistakes == 0 &&
this.playing.source &&
this.playing.source.isPlaying &&
this.playing.source.data.name == idSong)
354 SoundSource source = this.playing.source;
355 if (Mathf.Abs(source.source.time - (source.data as BGMData).song.parts[
this.playing.index].start) < 2f &&
this.playing.source.source.volume >= 0.1f)
359 Debug.Log(
"keep:" + source.source.time.ToString());
363 EClass.Sound.Stop(source.data, 0.1f);
365 Debug.Log(this.playing.source);
369 this.playing.source = this.owner.PlaySound(
"Instrument/" + idSong, 1f,
true);
370 Debug.Log(this.playing.source);
372 this.playing.bgm = (this.playing.source.data as BGMData);
373 BGMData.Part part = this.playing.bgm.song.parts[this.playing.index];
376 Util.Instantiate<
UISong>(
"UI/Util/UISong",
EClass.ui.rectDynamicEssential);
378 UISong.Instance.SetSong(this.playing.source,
this.playing.bgm, part);
379 if (
EClass.Sound.currentBGM !=
null)
381 float num2 = 0.5f - 0.1f * (float)this.playing.index;
386 if (
EClass.Sound.sourceBGM.volume >
EClass.Sound.currentBGM.data.volume * num2)
388 EClass.Sound.sourceBGM.DOFade(
EClass.Sound.currentBGM.data.volume * num2, 3f);
390 SoundManager.jingleTimer = part.duration / this.playing.bgm.pitch + this.playing.bgm.song.fadeIn + 2f;
396 Msg.SetColor(
Msg.colors.Ono);
397 this.owner.Say(Lang.GetList(
"music").RandomItem<
string>(),
null,
null);
399 if (
EClass.debug.enable &&
EClass.pc.job.id ==
"pianist")
403 if (p.progress > 2 && (
EClass.rnd(100 + 50 *
this.owner.Evalue(1405)) == 0 ||
EClass.rnd(4 + (
int)MathF.Max(0f, (
float)(song.lv -
this.playing.index * 25 -
this.playing.index *
this.playing.index / 2))) == 0))
405 this.playing.mistakes++;
408 base.<Run>g__LevelSong|0(2 + 2 *
EClass.rnd(this.owner.Evalue(1405) + 1));
410 if (this.playing.mistakes >= 10)
412 this.playing.index = 0;
417 foreach (
Chara chara
in EClass._map.ListCharasInCircle(
this.owner.pos, 4f,
true))
419 if (chara.conSleep !=
null && chara.ResistLv(957) <= 0)
421 chara.conSleep.Kill(
false);
422 chara.ShowEmo(Emo.angry, 0f,
true);
425 List<Chara> list = this.owner.pos.ListWitnesses(this.owner, 4, WitnessType.music,
null);
426 int num2 = this.owner.Evalue(241) * (100 + this.toolLv) / 100;
428 foreach (
Chara chara2
in list)
430 if (this.owner ==
null)
434 if (!reacted.Contains(chara2) &&
EClass.rnd(5) == 0)
436 if (this.owner.IsPCParty)
438 if (chara2.interest <= 0 || (
EClass._zone is
Zone_Music && (chara2.IsPCFaction || chara2.IsPCFactionMinion)))
442 chara2.interest -=
EClass.rnd(10);
443 if (chara2.interest < 0)
445 chara2.Talk(
"musicBored",
null,
null,
false);
449 if (
EClass.rnd(num3 * num3) <= 30)
451 bool isMinion = chara2.IsMinion;
452 if (num2 < chara2.LV &&
EClass.rnd(2) == 0)
457 this.score -= chara2.LV / 2 - 10;
461 chara2.Talk(
"musicBad",
null,
null,
false);
465 chara2.Say(
"musicBad", chara2, this.owner,
null,
null);
467 chara2.ShowEmo(Emo.sad, 0f,
true);
468 this.owner.elements.ModExp(241, 10,
false);
471 this.ThrowReward(chara2,
true);
475 else if (
EClass.rnd(num2 + 5) >
EClass.rnd(chara2.LV * 5 + 1))
480 this.score +=
EClass.rnd(chara2.LV / 2 + 5) + 5;
484 chara2.Talk(
"musicGood",
null,
null,
false);
488 chara2.Say(
"musicGood", chara2, this.owner,
null,
null);
490 chara2.ShowEmo(Emo.happy, 0f,
true);
491 chara2.renderer.PlayAnime((
EClass.rnd(2) == 0) ? AnimeID.Jump : AnimeID.Fishing,
default(Vector3),
false);
492 this.owner.elements.ModExp(241, 50,
false);
495 this.ThrowReward(chara2,
false);
502 if (this.owner !=
null && this.owner.IsPC &&
EClass.rnd(80) < num3)
504 this.owner.stamina.Mod(-1);
507 onProgressComplete = delegate()
511 base.<Run>g__LevelSong|0(2);
513 if (this.playing.bgm)
515 this.playing.index++;
516 this.playing.mistakes = 0;
517 if (this.playing.index >=
this.playing.bgm.song.parts.Count)
519 this.playing.index = 0;
521 this.playing.bgm.song.index = this.playing.index;
525 }.SetDuration(26, 2);
526 yield
return base.Do(seq,
null);
531 public void Evaluate()
535 int num = Mathf.Clamp(this.score / 20 + 1, 0, 9);
536 this.owner.Say(Lang.GetList(
"music_result")[num],
null,
null);
539 this.owner.Say(
"music_reward", this.owner, this.gold.ToString() ??
"",
null);
543 this.owner.stamina.Mod(-1);
546 if (questMusic !=
null)
548 questMusic.score += this.score;
549 questMusic.sumMoney += this.gold;
550 int num2 = num / 2 - 1;
553 SE.Play(
"clap" + num2.ToString());
560 public void ThrowReward(
Chara c,
bool punish)
567 text = ((
EClass.rnd(5) == 0) ?
"rock" :
"pebble");
568 if (!c.IsPCFactionOrMinion)
570 Thing thing2 = c.TryGetThrowable();
571 thing = ((thing2 !=
null) ? thing2.Split(1) :
null);
574 else if (
EClass.rnd(100) == 0)
579 text =
"casino_coin";
588 num = (
EClass.rnd(c.LV * 2 + 1) + 1) * (100 + this.toolLv * 2 + this.owner.Evalue(1405) * 10) / 100;
615 if (!this.owner.IsPCParty && !punish && text !=
"money")
621 thing =
ThingGen.Create(text, -1, -1).SetNum(num);
623 AI_PlayMusic.ignoreDamage =
true;
624 ActThrow.Throw(c, this.owner.pos, thing, punish ? ThrowMethod.Punish : ThrowMethod.Reward, 0f);
625 AI_PlayMusic.ignoreDamage =
false;
626 if (this.owner !=
null)
628 this.owner.TryPickGroundItem();
633 public override void OnCancel()
635 if (this.playing !=
null && this.playing.bgm)
637 this.playing.bgm.song.Fail(this.playing.source,
this.playing.bgm);
642 this.playing.source =
null;
643 SoundManager.jingleTimer = 1f;
650 public static bool keepPlaying;
653 public static Thing playingTool;
659 public static bool ignoreDamage;