From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/PlayerTask.cs | 137 +++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 Client/Assembly-CSharp/PlayerTask.cs (limited to 'Client/Assembly-CSharp/PlayerTask.cs') 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 FindConsoles() + { + List list = new List(); + 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 FindObjectsPos() + { + List list = new List(); + 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 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; + } +} -- cgit v1.1-26-g67d0