public virtual bool Init(IMyRemoteControl rc = null) { Rc = rc ?? Term.GetBlocksOfType <IMyRemoteControl>(collect: x => x.IsFunctional).FirstOrDefault(); if (rc == null) { return(false); } DroneName = DroneNameProvider; Antennae = Term.GetBlocksOfType <IMyRadioAntenna>(collect: x => x.IsFunctional); bool hasSetup = ParseSetup(); if (!hasSetup) { return(false); } AiSessionCore.AddDamageHandler(Grid, (block, damage) => { OnDamaged?.Invoke(block, damage); }); Grid.OnBlockAdded += block => { OnBlockPlaced?.Invoke(block); }; _ownerFaction = Grid.GetOwnerFaction(true); BotOperable = true; return(true); }
public override bool Init(IMyRemoteControl rc = null) { if (!base.Init(rc)) { return(false); } Update |= MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; if (_fighterSetup.CallHelpOnDamage) { OnDamaged += DamageHandler; } if (rc != null) { rc.Name = DroneNameProvider; MyAPIGateway.Entities.SetEntityName(rc); } if (!_fighterSetup.DelayedAiEnable) { LoadKeenAi(); } return(true); }
public override bool Init(IMyRemoteControl rc = null) { if (!base.Init(rc)) { return(false); } OnDamaged += DamageHandler; OnBlockPlaced += BlockPlacedHandler; SetFlightPath(); Update |= MyEntityUpdateEnum.EACH_100TH_FRAME; return(true); }
public static BotTypeBase ReadBotType(IMyRemoteControl rc) { try { string customData = rc.CustomData.Trim().Replace("\r\n", "\n"); List <string> myCustomData = new List <string>(customData.Split('\n')); if (customData.IsNullEmptyOrWhiteSpace()) { return(BotTypeBase.None); } if (myCustomData.Count < 2) { if (Constants.AllowThrowingErrors) { throw new Exception("CustomData is invalid", new Exception("CustomData consists of less than two lines")); } return(BotTypeBase.Invalid); } if (myCustomData[0].Trim() != "[EEM_AI]") { if (Constants.AllowThrowingErrors) { throw new Exception("CustomData is invalid", new Exception($"AI tag invalid: '{myCustomData[0]}'")); } return(BotTypeBase.Invalid); } string[] bottype = myCustomData[1].Split(':'); if (bottype[0].Trim() != "Type") { if (Constants.AllowThrowingErrors) { throw new Exception("CustomData is invalid", new Exception($"Type tag invalid: '{bottype[0]}'")); } return(BotTypeBase.Invalid); } BotTypeBase botType = BotTypeBase.Invalid; // ReSharper disable once SwitchStatementMissingSomeCases switch (bottype[1].Trim()) { case "Fighter": botType = BotTypeBase.Fighter; break; case "Freighter": botType = BotTypeBase.Freighter; break; case "Carrier": botType = BotTypeBase.Carrier; break; case "Station": botType = BotTypeBase.Station; break; } return(botType); } catch (Exception scrap) { rc.CubeGrid.LogError("[STATIC]BotBase.ReadBotType", scrap); return(BotTypeBase.Invalid); } }