public FactionFleet(long facId, GridOwner.OWNER_TYPE ownerType) { //if (s_Settings == null) { // s_Settings = ConquestSettings.getInstance(); //} if (s_Rules == null) { s_Rules = ConquestSettings.getInstance().HullRules; } if (s_Logger == null) { s_Logger = new Logger("Static", "FactionFleet"); } log("start", "ctr", Logger.severity.TRACE); m_FactionId = facId; m_OwnerType = ownerType; // = init count holders m_TotalCount = 0; int classCount = Enum.GetValues(typeof(HullClass.CLASS)).Length; m_Counts = new uint[classCount]; m_SupportedGrids = new Dictionary <long, GridEnforcer> [classCount]; for (int i = 0; i < classCount; i++) { m_SupportedGrids[i] = new Dictionary <long, GridEnforcer>(); } m_UnsupportedGrids = new Dictionary <long, GridEnforcer> [classCount]; for (int i = 0; i < classCount; i++) { m_UnsupportedGrids[i] = new Dictionary <long, GridEnforcer>(); } m_Maximums = new uint[classCount]; if (ownerType == GridOwner.OWNER_TYPE.FACTION) { for (int i = 0; i < classCount; i++) { m_Maximums[i] = (uint)s_Rules[i].MaxPerFaction; } } else if (ownerType == GridOwner.OWNER_TYPE.PLAYER) { for (int i = 0; i < classCount; i++) { m_Maximums[i] = (uint)s_Rules[i].MaxPerSoloPlayer; } } else { for (int i = 0; i < classCount; i++) { m_Maximums[i] = 0; } } }
/// <summary> /// Returns the fleet for the fleet id. If no fleet yet recorded creates a new one. /// </summary> /// <param name="factionId"></param> /// <returns></returns> public FactionFleet getFleet(long fleetId, GridOwner.OWNER_TYPE ownerType) { switch (ownerType) { case GridOwner.OWNER_TYPE.FACTION: if (!m_Fleets.ContainsKey(fleetId)) { m_Fleets.Add(fleetId, new FactionFleet(fleetId, ownerType)); } return(m_Fleets[fleetId]); case GridOwner.OWNER_TYPE.PLAYER: if (!m_PlayerFleets.ContainsKey(fleetId)) { m_PlayerFleets.Add(fleetId, new FactionFleet(fleetId, ownerType)); } return(m_PlayerFleets[fleetId]); case GridOwner.OWNER_TYPE.UNOWNED: default: if (!m_PlayerFleets.ContainsKey(UNOWNED_FLEET_ID)) { m_PlayerFleets.Add(UNOWNED_FLEET_ID, new FactionFleet(fleetId, ownerType)); } return(m_PlayerFleets[fleetId]); } }
private string buildFleetInfoTitle(GridOwner.OWNER_TYPE ownerType) { string fleetInfoTitle = ""; switch (ownerType) { case GridOwner.OWNER_TYPE.FACTION: fleetInfoTitle = "Your Faction's Fleet:"; break; case GridOwner.OWNER_TYPE.PLAYER: fleetInfoTitle = "Your Fleet:"; break; } return(fleetInfoTitle); }
public FactionFleet(long facId, GridOwner.OWNER_TYPE ownerType) { //if (s_Settings == null) { // s_Settings = ConquestSettings.getInstance(); //} if (s_Rules == null) { s_Rules = ConquestSettings.getInstance().HullRules; } if (s_Logger == null) { s_Logger = new Logger("Static", "FactionFleet"); } log("start", "ctr", Logger.severity.TRACE); m_FactionId = facId; m_OwnerType = ownerType; // = init count holders m_TotalCount = 0; int classCount = Enum.GetValues(typeof(HullClass.CLASS)).Length; m_Counts = new uint[classCount]; m_SupportedGrids = new Dictionary<long, GridEnforcer>[classCount]; for (int i = 0; i < classCount; i++) { m_SupportedGrids[i] = new Dictionary<long, GridEnforcer>(); } m_UnsupportedGrids = new Dictionary<long, GridEnforcer>[classCount]; for (int i = 0; i < classCount; i++) { m_UnsupportedGrids[i] = new Dictionary<long, GridEnforcer>(); } m_Maximums = new uint[classCount]; if (ownerType == GridOwner.OWNER_TYPE.FACTION) { for (int i = 0; i < classCount; i++) { m_Maximums[i] = (uint)s_Rules[i].MaxPerFaction; } } else if (ownerType == GridOwner.OWNER_TYPE.PLAYER) { for (int i = 0; i < classCount; i++) { m_Maximums[i] = (uint)s_Rules[i].MaxPerSoloPlayer; } } else { for (int i = 0; i < classCount; i++) { m_Maximums[i] = 0; } } }
public void removeFleetIfEmpty(long fleetId, GridOwner.OWNER_TYPE ownerType) { switch (ownerType) { case GridOwner.OWNER_TYPE.FACTION: if (m_Fleets.ContainsKey(fleetId)) { if (m_Fleets[fleetId].TotalCount == 0) { m_Fleets.Remove(fleetId); } } return; case GridOwner.OWNER_TYPE.PLAYER: if (m_PlayerFleets.ContainsKey(fleetId)) { if (m_PlayerFleets[fleetId].TotalCount == 0) { m_PlayerFleets.Remove(fleetId); } } return; case GridOwner.OWNER_TYPE.UNOWNED: default: if (m_PlayerFleets.ContainsKey(fleetId)) { if (m_PlayerFleets[fleetId].TotalCount == 0) { m_PlayerFleets.Remove(fleetId); } } return; } }
public void eventCleanupTimerEnd(GridEnforcer ge, DerelictTimer.COMPLETION c) { //log("start", "eventCleanupTimerEnd", Logger.severity.TRACE); if (ge == null) { return; } //log("grid exists, getting owner", "eventCleanupTimerEnd", Logger.severity.TRACE); GridOwner owner = ge.Owner; //log("grid exists, getting owner type", "eventCleanupTimerEnd", Logger.severity.TRACE); GridOwner.OWNER_TYPE owner_type = owner.OwnerType; //log("grid exists, getting faction", "eventCleanupTimerEnd", Logger.severity.TRACE); long gridFactionID = ge.Owner.FactionID; //log("determining destinations", "eventCleanupTimerEnd", Logger.severity.TRACE); BaseResponse.DEST_TYPE destType = BaseResponse.DEST_TYPE.NONE; List <long> Destinations = new List <long>(); string message = ""; if (owner_type == GridOwner.OWNER_TYPE.FACTION) { destType = BaseResponse.DEST_TYPE.FACTION; Destinations.Add(gridFactionID); message += "Your faction's "; } else if (owner_type == GridOwner.OWNER_TYPE.PLAYER) { destType = BaseResponse.DEST_TYPE.PLAYER; Destinations.Add(ge.Owner.PlayerID); message += "Your "; } else { List <long> nearbyPlayers = ge.Grid.getPlayerIDsWithinPlacementRadius(); if (nearbyPlayers.Count > 0) { destType = BaseResponse.DEST_TYPE.PLAYER; Destinations = nearbyPlayers; message += "Nearby "; } else { return; } } log("building message", "eventCleanupTimerEnd", Logger.severity.TRACE); MyFontEnum font = MyFontEnum.Red; if (c == DerelictTimer.COMPLETION.CANCELLED) { message += "grid " + ge.Grid.DisplayName + " is now within limits."; font = MyFontEnum.Green; } else if (c == DerelictTimer.COMPLETION.ELAPSED) { message += "grid " + ge.Grid.DisplayName + " had some of its offending blocks removed."; font = MyFontEnum.Red; } log("Sending message", "eventDerelictEnd"); NotificationResponse noti = new NotificationResponse() { NotificationText = message, Time = Constants.NotificationMillis, Font = font, Destination = Destinations, DestType = destType }; m_MailMan.send(noti); }
public void eventCleanupTimerStart(GridEnforcer ge, int secondsRemaining) { if (ge == null) { return; } GridOwner owner = ge.Owner; GridOwner.OWNER_TYPE owner_type = owner.OwnerType; long gridFactionID = ge.Owner.FactionID; BaseResponse.DEST_TYPE destType = BaseResponse.DEST_TYPE.NONE; List <long> Destinations = new List <long>(); string message = ""; if (owner_type == GridOwner.OWNER_TYPE.FACTION) { destType = BaseResponse.DEST_TYPE.FACTION; Destinations.Add(gridFactionID); message += "Your faction's "; } else if (owner_type == GridOwner.OWNER_TYPE.PLAYER) { destType = BaseResponse.DEST_TYPE.PLAYER; Destinations.Add(ge.Owner.PlayerID); message += "Your "; } else { List <long> nearbyPlayers = ge.Grid.getPlayerIDsWithinPlacementRadius(); if (nearbyPlayers.Count > 0) { destType = BaseResponse.DEST_TYPE.PLAYER; Destinations = nearbyPlayers; message += "Nearby "; } else { return; } } log("msg details built", "eventCleanupTimerStart", Logger.severity.TRACE); // build notification message += "grid " + ge.Grid.DisplayName + " will have some of its offending blocks removed in " + Utility.prettySeconds(secondsRemaining); log("msg built, building noti", "eventDerelictStart"); NotificationResponse noti = new NotificationResponse() { NotificationText = message, Time = Constants.NotificationMillis, Font = MyFontEnum.Red, Destination = Destinations, DestType = destType }; log("notification built, sending message", "eventDerelictStart"); m_MailMan.send(noti); log("Msg sent", "eventDerelictStart"); }
public void eventCleanupViolation(GridEnforcer ge, List <GridEnforcer.VIOLATION> violations) { log("Start", "eventCleanupViolation"); if (ge == null) { return; } log("Determine destination", "eventCleanupViolation"); GridOwner owner = ge.Owner; GridOwner.OWNER_TYPE owner_type = owner.OwnerType; long gridFactionID = ge.Owner.FactionID; BaseResponse.DEST_TYPE destType = BaseResponse.DEST_TYPE.NONE; List <long> Destinations = new List <long>(); string message = ""; if (owner_type == GridOwner.OWNER_TYPE.FACTION) { destType = BaseResponse.DEST_TYPE.FACTION; Destinations.Add(gridFactionID); message += "Your faction's "; } else if (owner_type == GridOwner.OWNER_TYPE.PLAYER) { destType = BaseResponse.DEST_TYPE.PLAYER; Destinations.Add(ge.Owner.PlayerID); message += "Your "; } else { List <long> nearbyPlayers = ge.Grid.getPlayerIDsWithinPlacementRadius(); if (nearbyPlayers.Count > 0) { destType = BaseResponse.DEST_TYPE.PLAYER; Destinations = nearbyPlayers; message += "Nearby unowned "; } else { return; } } message += "grid '" + ge.Grid.DisplayName + "' "; log("Build violations message", "eventCleanupViolation"); if (violations != null) { message += "is violating: "; foreach (GridEnforcer.VIOLATION violation in violations) { message += violation.Name + ": " + violation.Count + "/" + violation.Limit + " "; } message += " and "; } log("Build time message", "eventCleanupViolation"); int secondsUntilCleanup = ge.TimeUntilCleanup; message += "will have some blocks removed in " + Utility.prettySeconds(secondsUntilCleanup); // send log("Sending message", "eventDerelictStart"); NotificationResponse noti = new NotificationResponse() { NotificationText = message, Time = Constants.NotificationMillis, Font = MyFontEnum.Red, Destination = Destinations, DestType = destType }; m_MailMan.send(noti); }
public void eventPlacementViolation(GridEnforcer ge, GridEnforcer.VIOLATION_TYPE v) { log("hit", "eventGridViolation"); // Check for players within the vicinity of the grid, since there's no // built-in way to tell who just placed the block List <long> players = ge.Grid.getPlayerIDsWithinPlacementRadius(); if (players.Count <= 0) { return; } string message = ""; if (v == GridEnforcer.VIOLATION_TYPE.TOTAL_BLOCKS) { message = "No more blocks allowed for this Class"; } else if (v == GridEnforcer.VIOLATION_TYPE.BLOCK_TYPE) { message = "No more blocks of this type allowed for this Class"; } else if (v == GridEnforcer.VIOLATION_TYPE.TOO_MANY_CLASSIFIERS) { message = "Only one Hull Classifier allowed"; } else if (v == GridEnforcer.VIOLATION_TYPE.SHOULD_BE_STATIC) { message = "This classifier is only allowed on Stations"; } else if (v == GridEnforcer.VIOLATION_TYPE.TOO_MANY_OF_CLASS) { // Hopefully the first person in the immediate vicinity is the // same ownertype as the person trying to place the block. // We could pass the owner of the block up with the violation, // but it would required more sophistication in the way we pass // violations in BlockAdded GridOwner.OWNER localOwner = GridOwner.ownerFromPlayerID(players[0]); GridOwner.OWNER_TYPE owner_type = localOwner.OwnerType; if (owner_type == GridOwner.OWNER_TYPE.UNOWNED) { message = "Take ownership of this grid or it will eventually be removed."; } else if (owner_type == GridOwner.OWNER_TYPE.PLAYER) { message = "No more ships of this class allowed in this player's fleet. " + "Try joining a faction."; } else if (owner_type == GridOwner.OWNER_TYPE.FACTION) { message = "No more ships of this class allowed in this faction's fleet. "; } } log("Sending message", "eventPlacementViolation"); NotificationResponse noti = new NotificationResponse() { NotificationText = message, Time = Constants.NotificationMillis, Font = MyFontEnum.Red, Destination = players, DestType = BaseResponse.DEST_TYPE.PLAYER }; m_MailMan.send(noti); }
public override void deserialize(VRage.ByteStream stream) { base.deserialize(stream); OwnerType = (GridOwner.OWNER_TYPE)stream.getUShort(); FleetData = new List <GridEnforcer.GridData>(FactionFleet.deserialize(stream)); }
public override void deserialize(VRage.ByteStream stream) { base.deserialize(stream); OwnerType = (GridOwner.OWNER_TYPE)stream.getUShort(); FleetData = new List<GridEnforcer.GridData>(FactionFleet.deserialize(stream)); }
private string buildFleetInfoBody(GridOwner.OWNER_TYPE ownerType) { log("Building Fleet Info Body", "buildFleetInfoBody"); string fleetInfoBody = ""; List <GridEnforcer.GridData> gdList; for (int i = 0; i < m_Counts.Length; ++i) { if (m_Counts[i] > 0) { fleetInfoBody += (HullClass.CLASS)i + ": " + m_Counts[i] + " / "; if (ownerType == GridOwner.OWNER_TYPE.FACTION) { fleetInfoBody += ServerSettings.HullRules[i].MaxPerFaction + "\n"; } else if (ownerType == GridOwner.OWNER_TYPE.PLAYER) { fleetInfoBody += ServerSettings.HullRules[i].MaxPerSoloPlayer + "\n"; } else { fleetInfoBody += "0\n"; } if (m_SupportedGrids[i].Count > 0) { gdList = m_SupportedGrids[i]; for (int j = 0; j < gdList.Count; ++j) { fleetInfoBody += " " + (j + 1) + ". " + gdList[j].shipName + " - " + gdList[j].blockCount + " blocks\n"; if (gdList[j].displayPos) { fleetInfoBody += " GPS: " + gdList[j].shipPosition.X + ", " + gdList[j].shipPosition.Y + ", " + gdList[j].shipPosition.Z + "\n"; } else { fleetInfoBody += " GPS: Unavailable - Must own the Main Cockpit\n"; } } } if (m_UnsupportedGrids[i].Count > 0) { gdList = m_UnsupportedGrids[i]; int offset = m_SupportedGrids[i].Count; fleetInfoBody += "\n Unsupported:\n"; for (int j = 0; j < gdList.Count; ++j) { //Some code logic to continue the numbering of entries where m_SupportedGrid leaves off fleetInfoBody += " " + (j + offset + 1) + ". " + gdList[j].shipName + " - " + gdList[j].blockCount + " blocks\n"; if (gdList[j].displayPos) { fleetInfoBody += " GPS: " + gdList[j].shipPosition.X + ", " + gdList[j].shipPosition.Y + ", " + gdList[j].shipPosition.Z + "\n"; } else { fleetInfoBody += " GPS: Unavailable - Must own the Main Cockpit\n"; } } } fleetInfoBody += "\n"; } } return(fleetInfoBody); }