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
|
using System;
using Assets.CoreScripts;
using UnityEngine;
public class Console : MonoBehaviour, IUsable
{
public float UsableDistance
{
get
{
return this.usableDistance;
}
}
public float PercentCool
{
get
{
return 0f;
}
}
public float usableDistance = 1f;
public int ConsoleId;
public bool onlyFromBelow;
public bool GhostsIgnored;
public SystemTypes Room;
public TaskTypes[] TaskTypes;
public TaskSet[] ValidTasks;
public SpriteRenderer Image;
public void SetOutline(bool on, bool mainTarget)
{
if (this.Image)
{
this.Image.material.SetFloat("_Outline", (float)(on ? 1 : 0));
this.Image.material.SetColor("_OutlineColor", Color.yellow);
this.Image.material.SetColor("_AddColor", mainTarget ? Color.yellow : Color.clear);
}
}
public float CanUse(GameData.PlayerInfo pc, out bool canUse, out bool couldUse)
{
float num = float.MaxValue;
PlayerControl @object = pc.Object;
couldUse = ((!pc.IsDead || (PlayerControl.GameOptions.GhostsDoTasks && !this.GhostsIgnored)) && @object.CanMove && !pc.IsImpostor && (!this.onlyFromBelow || @object.transform.position.y < base.transform.position.y) && this.FindTask(@object));
canUse = couldUse;
if (canUse)
{
num = Vector2.Distance(@object.GetTruePosition(), base.transform.position);
canUse &= (num <= this.UsableDistance);
}
return num;
}
private PlayerTask FindTask(PlayerControl pc)
{
for (int i = 0; i < pc.myTasks.Count; i++)
{
PlayerTask playerTask = pc.myTasks[i];
if (!playerTask.IsComplete && playerTask.ValidConsole(this))
{
return playerTask;
}
}
return null;
}
public void Use()
{
bool flag;
bool flag2;
this.CanUse(PlayerControl.LocalPlayer.Data, out flag, out flag2);
if (!flag)
{
return;
}
PlayerControl localPlayer = PlayerControl.LocalPlayer;
PlayerTask playerTask = this.FindTask(localPlayer);
if (playerTask.MinigamePrefab)
{
Minigame minigame = UnityEngine.Object.Instantiate<Minigame>(playerTask.MinigamePrefab);
minigame.transform.SetParent(Camera.main.transform, false);
minigame.transform.localPosition = new Vector3(0f, 0f, -50f);
minigame.Console = this;
minigame.Begin(playerTask);
DestroyableSingleton<Telemetry>.Instance.WriteUse(localPlayer.PlayerId, playerTask.TaskType, base.transform.position);
}
}
}
|