bool TryInitializeShipCommandManager()
        {
            CommandedSubmarine = character.Submarine;

            if (CommandedSubmarine == null)
            {
                DebugConsole.ThrowError("TryInitializeShipCommandManager failed: CommandedSubmarine was null for character " + character);
                return(false);
            }

            EnemySubmarine = Submarine.MainSubs[0] == CommandedSubmarine ? Submarine.MainSubs[1] : Submarine.MainSubs[0];

            if (EnemySubmarine == null)
            {
                DebugConsole.ThrowError("TryInitializeShipCommandManager failed: EnemySubmarine was null for character " + character);
                return(false);
            }

            timeUntilRam = RamTimerMax * Rand.Range(0.9f, 1.1f);

            ShipIssueWorkers.Clear();

            // could have support for multiple reactors, todo m61
            if (CommandedSubmarine.GetItems(false).Find(i => i.HasTag("reactor") && !i.NonInteractable)?.GetComponent <Reactor>() is Reactor reactor)
            {
                ShipIssueWorkers.Add(new ShipIssueWorkerPowerUpReactor(this, Order.GetPrefab("operatereactor"), reactor.Item, reactor, "powerup"));
            }

            if (CommandedSubmarine.GetItems(false).Find(i => i.HasTag("navterminal") && !i.NonInteractable) is Item nav && nav.GetComponent <Steering>() is Steering steeringComponent)
            {
                steering = steeringComponent;
                ShipIssueWorkers.Add(new ShipIssueWorkerSteer(this, Order.GetPrefab("steer"), nav, steeringComponent, "navigatetactical"));
            }

            foreach (Item item in CommandedSubmarine.GetItems(true).FindAll(i => i.HasTag("turret")))
            {
                ShipIssueWorkers.Add(new ShipIssueWorkerOperateWeapons(this, Order.GetPrefab("operateweapons"), item, item.GetComponent <Turret>()));
            }

            int crewSizeModifier = 2;
            // these issueworkers revolve around a singular, shared issue, which is injected into them to prevent redundant calculations
            ShipGlobalIssueFixLeaks shipGlobalIssueFixLeaks = new ShipGlobalIssueFixLeaks(this);

            for (int i = 0; i < crewSizeModifier; i++)
            {
                ShipIssueWorkers.Add(new ShipIssueWorkerFixLeaks(this, Order.GetPrefab("fixleaks"), shipGlobalIssueFixLeaks));
            }
            shipGlobalIssues.Add(shipGlobalIssueFixLeaks);

            ShipGlobalIssueRepairSystems shipGlobalIssueRepairSystems = new ShipGlobalIssueRepairSystems(this);

            for (int i = 0; i < crewSizeModifier; i++)
            {
                ShipIssueWorkers.Add(new ShipIssueWorkerRepairSystems(this, Order.GetPrefab("repairsystems"), shipGlobalIssueRepairSystems));
            }
            shipGlobalIssues.Add(shipGlobalIssueRepairSystems);

            return(true);
        }
Beispiel #2
0
 public ShipIssueWorkerFixLeaks(ShipCommandManager shipCommandManager, Order order, ShipGlobalIssueFixLeaks shipGlobalIssueFixLeaks) : base(shipCommandManager, order, shipGlobalIssueFixLeaks)
 {
 }