diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/PlayerTask.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/PlayerTask.cs')
-rw-r--r-- | Client/Assembly-CSharp/PlayerTask.cs | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/PlayerTask.cs b/Client/Assembly-CSharp/PlayerTask.cs new file mode 100644 index 0000000..ddccafe --- /dev/null +++ b/Client/Assembly-CSharp/PlayerTask.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Text; +using UnityEngine; + +public abstract class PlayerTask : MonoBehaviour +{ + public int Index { get; internal set; } + + public uint Id { get; internal set; } + + public PlayerControl Owner { get; internal set; } + + public abstract int TaskStep { get; } + + public abstract bool IsComplete { get; } + + public Vector2 Location + { + get + { + this.LocationDirty = false; + return this.FindObjectPos().transform.position; + } + } + + public SystemTypes StartAt; + + public TaskTypes TaskType; + + public Minigame MinigamePrefab; + + public bool HasLocation; + + public bool LocationDirty = true; + + public abstract void Initialize(); + + public virtual void OnRemove() + { + } + + public abstract bool ValidConsole(global::Console console); + + public abstract void Complete(); + + public abstract void AppendTaskText(StringBuilder sb); + + internal static bool TaskIsEmergency(PlayerTask arg) + { + return arg is NoOxyTask || arg is HudOverrideTask || arg is ReactorTask || arg is ElectricTask; + } + + protected List<global::Console> FindConsoles() + { + List<global::Console> list = new List<global::Console>(); + global::Console[] allConsoles = ShipStatus.Instance.AllConsoles; + for (int i = 0; i < allConsoles.Length; i++) + { + if (this.ValidConsole(allConsoles[i])) + { + list.Add(allConsoles[i]); + } + } + return list; + } + + public static bool PlayerHasHudTask(PlayerControl localPlayer) + { + if (!localPlayer) + { + return true; + } + for (int i = 0; i < localPlayer.myTasks.Count; i++) + { + if (localPlayer.myTasks[i] is HudOverrideTask) + { + return true; + } + } + return false; + } + + protected List<Vector2> FindObjectsPos() + { + List<Vector2> list = new List<Vector2>(); + global::Console[] allConsoles = ShipStatus.Instance.AllConsoles; + for (int i = 0; i < allConsoles.Length; i++) + { + if (this.ValidConsole(allConsoles[i])) + { + list.Add(allConsoles[i].transform.position); + } + } + return list; + } + + protected global::Console FindSpecialConsole(Func<global::Console, bool> func) + { + global::Console[] allConsoles = ShipStatus.Instance.AllConsoles; + for (int i = 0; i < allConsoles.Length; i++) + { + if (func(allConsoles[i])) + { + return allConsoles[i]; + } + } + return null; + } + + protected global::Console FindObjectPos() + { + global::Console[] allConsoles = ShipStatus.Instance.AllConsoles; + for (int i = 0; i < allConsoles.Length; i++) + { + if (this.ValidConsole(allConsoles[i])) + { + return allConsoles[i]; + } + } + Debug.LogError("Couldn't find location for task: " + base.name); + return null; + } + + protected static bool AllTasksCompleted(PlayerControl player) + { + for (int i = 0; i < player.myTasks.Count; i++) + { + PlayerTask playerTask = player.myTasks[i]; + if (playerTask is NormalPlayerTask && !playerTask.IsComplete) + { + return false; + } + } + return true; + } +} |