public void AddDrone(PlayerDrone drone) { if (DroneOwners.Keys.Contains(drone.GetOwnerId())) { if (DroneOwners[drone.GetOwnerId()].DroneCount() < DronesPerPlayerSquad) { DroneOwners[drone.GetOwnerId()].AddDrone(drone); Util.GetInstance().Log("[PlayerDronemanager.AddDrone] squad existed: drone added!"); } } else { var sq = new PlayerDroneSquad(drone.GetOwnerId()); sq.SetOwner(drone.GetOwnerId()); sq.AddDrone(drone); Util.GetInstance().Log("[PlayerDronemanager.AddDrone] squad created: drone added!"); DroneOwners.Add(drone.GetOwnerId(), sq); } }
public void AddDrone(PlayerDrone drone) { if (DroneOwners.Keys.Contains(drone.GetOwnerId())) { if (DroneOwners[drone.GetOwnerId()].DroneCount() < DronesPerPlayerSquad) { DroneOwners[drone.GetOwnerId()].AddDrone(drone); Util.GetInstance().Log("[PlayerDronemanager.AddDrone] squad existed: drone added!"); } } else { var sq = new PlayerDroneSquad(drone.GetOwnerId()); sq.SetOwner(drone.GetOwnerId()); sq.AddDrone(drone); Util.GetInstance().Log("[PlayerDronemanager.AddDrone] squad created: drone added!"); DroneOwners.Add(drone.GetOwnerId(), sq); } }
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()); } } }
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()); } } }