private void SetUpDrone(IMyEntity entity) { IMyGridTerminalSystem gridTerminal = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid((IMyCubeGrid)entity); List<Sandbox.ModAPI.Ingame.IMyTerminalBlock> T = new List<Sandbox.ModAPI.Ingame.IMyTerminalBlock>(); gridTerminal.GetBlocksOfType<IMyTerminalBlock>(T); var droneType = GetDroneType(T); if (droneType.DroneType != DroneTypes.NotADrone) { try { switch (droneType.DroneType) { case DroneTypes.PlayerDrone: { PlayerDrone dro = new PlayerDrone(entity, droneType.Broadcasting); Util.GetInstance().Log("[ConquestMod.SetUpDrone] Found New Player Drone. id=" + dro.GetOwnerId()); pManager.AddDrone(dro); break; } case DroneTypes.MothershipDrone: { MothershipDrone dro = new MothershipDrone(entity, droneType.Broadcasting); entity.DisplayName = ""; ((IMyCubeGrid)entity).Name = ""; ((IMyCubeGrid)entity).ChangeGridOwnership(cManager.GetMothershipID(), MyOwnershipShareModeEnum.Faction); ((IMyCubeGrid)entity).UpdateOwnership(cManager.GetMothershipID(), true); Util.GetInstance().Log("[ConquestMod.SetUpDrone] found new conquest drone"); cManager.AddMothership(dro); break; } case DroneTypes.ConquestDrone: { ConquestDrone dro = new ConquestDrone(entity, droneType.Broadcasting); entity.DisplayName = ""; ((IMyCubeGrid)entity).Name = ""; ((IMyCubeGrid)entity).ChangeGridOwnership(cManager.GetMothershipID(), MyOwnershipShareModeEnum.Faction); ((IMyCubeGrid)entity).UpdateOwnership(cManager.GetMothershipID(), true); Util.GetInstance().Log("[ConquestMod.SetUpDrone] found new conquest drone"); cManager.AddDrone(dro); break; } default: { //Util.Notify("broken drone type"); break; } } } catch (Exception e) { //MyAPIGateway.Entities.RemoveEntity(entity); Util.GetInstance().LogError(e.ToString()); } } }
public void AddMothership(MothershipDrone dro) { dro.SetOwner(GetMothershipID()); _motherships.Add(dro); }
private void SetUpDrone(IMyEntity entity) { IMyGridTerminalSystem gridTerminal = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid((IMyCubeGrid)entity); List <Sandbox.ModAPI.Ingame.IMyTerminalBlock> T = new List <Sandbox.ModAPI.Ingame.IMyTerminalBlock>(); gridTerminal.GetBlocksOfType <IMyTerminalBlock>(T); var droneType = GetDroneType(T); if (droneType.DroneType != DroneTypes.NotADrone) { try { switch (droneType.DroneType) { case DroneTypes.PlayerDrone: { PlayerDrone dro = new PlayerDrone(entity, droneType.Broadcasting); Util.GetInstance().Log("[ConquestMod.SetUpDrone] Found New Player Drone. id=" + dro.GetOwnerId()); pManager.AddDrone(dro); break; } case DroneTypes.MothershipDrone: { MothershipDrone dro = new MothershipDrone(entity, droneType.Broadcasting); entity.DisplayName = ""; ((IMyCubeGrid)entity).Name = ""; ((IMyCubeGrid)entity).ChangeGridOwnership(cManager.GetMothershipID(), MyOwnershipShareModeEnum.Faction); ((IMyCubeGrid)entity).UpdateOwnership(cManager.GetMothershipID(), true); Util.GetInstance().Log("[ConquestMod.SetUpDrone] found new conquest drone"); cManager.AddMothership(dro); break; } case DroneTypes.ConquestDrone: { ConquestDrone dro = new ConquestDrone(entity, droneType.Broadcasting); entity.DisplayName = ""; ((IMyCubeGrid)entity).Name = ""; ((IMyCubeGrid)entity).ChangeGridOwnership(cManager.GetMothershipID(), MyOwnershipShareModeEnum.Faction); ((IMyCubeGrid)entity).UpdateOwnership(cManager.GetMothershipID(), true); Util.GetInstance().Log("[ConquestMod.SetUpDrone] found new conquest drone"); cManager.AddDrone(dro); break; } default: { //Util.Notify("broken drone type"); break; } } } catch (Exception e) { //MyAPIGateway.Entities.RemoveEntity(entity); Util.GetInstance().LogError(e.ToString()); } } }