using Arcen.AIW2.Core;
using System;
using System.Collections.Generic;
using System.Text;
using Arcen.Universal;
using Arcen.AIW2.External;
using UnityEngine;
namespace Arcen.AIW2.ExternalVisualization
{
public static class UtilityMethodsFor_GalaxyMapDisplayMode
{
public static void BasePickGalaxyMapOtherThingsToShow(Planet planet, GameEntity_Squad EntityToSkip, GameEntity_Squad[] ArrayToFill, GameEntity_Squad.EvaluatorDelegate evaluator)
{
bool canSeeEnemies = planet.HumansHaveCurrentBroadIntel;
int newOtherGimbalIndex = 0;
planet.DoForEntities( EntityRollupType.DrawsInGalaxyView, delegate( GameEntity_Squad entity )
{
if ( EntityToSkip != null )
{
if ( entity == EntityToSkip )
return DelReturn.Continue;
}
if ( !evaluator( entity ) )
return DelReturn.Continue;
if ( !canSeeEnemies )
{
if ( entity.PlanetFaction == null )
return DelReturn.Continue;
if ( entity.PlanetFaction.Faction.GetIsHostileToLocalFaction() )
return DelReturn.Continue;
}
ArrayToFill[newOtherGimbalIndex] = entity;
newOtherGimbalIndex++;
if ( newOtherGimbalIndex >= ArrayToFill.Length )
return DelReturn.Break;
return DelReturn.Continue;
} );
}
}
public abstract class BaseGalaxyMapDisplayMode : IGalaxyMapDisplayModeImplementation
{
public virtual Color GetColorForLinkBetweenPlanets(Planet FirstPlanet, Planet SecondPlanet)
{
ProjectedMultiPathData pathData = SpecialFaction_Human.NonSim_PlanetsInvolvedInPathToCurrentHoverPlanet_LocalFactionOnly;
if ( pathData != null && pathData.GetAreConnected( FirstPlanet, SecondPlanet ) )
return World_AIW2.Instance.GetLocalPlayerFaction().TeamCenterColor.TeamColorHighlighted;
Faction FirstFaction = FirstPlanet.GetFactionWithSpecialInfluenceHere();
if ( FirstFaction.Type == FactionType.NaturalObject )
FirstFaction = FirstPlanet.GetControllingFaction();
Faction SecondFaction = SecondPlanet.GetFactionWithSpecialInfluenceHere();
if ( SecondFaction.Type == FactionType.NaturalObject )
SecondFaction = SecondPlanet.GetControllingFaction();
if ( FirstFaction == SecondFaction )
return FirstFaction.TeamCenterColor.TeamColor;
else if ( FirstFaction.GetIsFriendlyTowards( SecondFaction ) )
return Color.blue;
else if ( FirstFaction.GetIsHostileTowards( SecondFaction ) )
return Color.red;
else
return Color.gray;
}
public virtual void WriteNameText( Planet planet, ArcenDoubleCharacterBuffer buffer )
{
if ( planet == null )
{
ArcenDebugging.ArcenDebugLog( "Warning: WriteNameText found planet == null", Verbosity.ShowAsInfo );
return;
}
Faction faction = planet.GetFactionWithSpecialInfluenceHere();
if ( faction == null )
{
ArcenDebugging.ArcenDebugLog( "Warning: WriteNameText found faction == null", Verbosity.ShowAsInfo );
return;
}
if ( faction.TeamCenterColor == null )
{
ArcenDebugging.ArcenDebugLog( "Warning: WriteNameText found faction.TeamColor == null", Verbosity.ShowAsInfo );
return;
}
if ( faction.Type == FactionType.NaturalObject )
faction = planet.GetControllingFaction();
bool haveIntelAndNotSetup = planet.HumansHaveCurrentBroadIntel && !World_AIW2.Instance.InSetupPhase;
if ( haveIntelAndNotSetup || faction.Type == FactionType.Player )
buffer.Add( "" );
buffer.Add( planet.Name );
if ( World_AIW2.Instance.InSetupPhase )
{
List controllingPlayers = planet.GetControllingFaction().ControlledByPlayerAccounts;
if ( controllingPlayers != null && controllingPlayers.Count > 0 && controllingPlayers[0] < World.Instance.AllPlayerAccounts.Count )
buffer.Add( "\n" ).Add( World.Instance.AllPlayerAccounts[controllingPlayers[0]].Username );
}
if ( haveIntelAndNotSetup || faction.Type == FactionType.Player )
buffer.Add( "" );
if ( haveIntelAndNotSetup &&
faction.Type == FactionType.AI &&
!Engine_AIW2.Instance.IsTestChamber )
buffer.Add( " " ).Add( planet.MarkLevel.MapDisplayWithColor );
}
public virtual float GetThicknessMultiplierForLinkBetweenPlanets(Planet FirstPlanet, Planet SecondPlanet)
{
ProjectedMultiPathData localFactionOnly = SpecialFaction_Human.NonSim_PlanetsInvolvedInPathToCurrentHoverPlanet_LocalFactionOnly;
if (localFactionOnly != null && localFactionOnly.GetAreConnected(FirstPlanet, SecondPlanet))
return 3f;
return 1.0f;
}
public virtual void WriteLeftRightText( Planet planet, ArcenDoubleCharacterBuffer LeftBuffer, ArcenDoubleCharacterBuffer RightBuffer )
{
if ( World_AIW2.Instance.InSetupPhase )
return;
int threatStrengthInt, hostileStrengthMinusThreatInt, myTotalStrength, myMobileStrength, myAndAlliedTotalStrength, myAndAlliedMobileStrength;
Faction hostileFaction;
string myOrAlliedColor;
Window_InGameHoverPlanetInfo.GetPlanetFactionalData( planet, out threatStrengthInt, out hostileStrengthMinusThreatInt, out myTotalStrength, out myMobileStrength,
out myAndAlliedTotalStrength, out myAndAlliedMobileStrength, out myOrAlliedColor, out hostileFaction, false );
//LEFT
if ( myAndAlliedTotalStrength > 0 )
{
LeftBuffer.StartColor( myOrAlliedColor );
LeftBuffer.Add( ArcenExternalUIUtilities.StrengthTextIcon );
ArcenExternalUIUtilities.WriteRoundedNumberWithSuffix( LeftBuffer, myAndAlliedMobileStrength, true, true );
LeftBuffer.Add( "\n" ).Add( ArcenExternalUIUtilities.StrengthTextIcon );
ArcenExternalUIUtilities.WriteRoundedNumberWithSuffix( LeftBuffer, myAndAlliedTotalStrength - myAndAlliedMobileStrength, true, true );
}
//RIGHT LINE 1
if ( hostileStrengthMinusThreatInt > 0 )
{
if ( hostileFaction != null )
RightBuffer.StartColor( hostileFaction.TeamCenterColor.ColorHexLinearBrighter );
else
RightBuffer.StartColor( "ffffff" );
RightBuffer.Add( ArcenExternalUIUtilities.StrengthTextIcon );
ArcenExternalUIUtilities.WriteRoundedNumberWithSuffix( RightBuffer, hostileStrengthMinusThreatInt, true, true );
if ( threatStrengthInt > 0 )
RightBuffer.Add( "\n" );
}
//RIGHT LINE 2
if ( threatStrengthInt > 0 )
{
if ( hostileFaction != null )
RightBuffer.StartColor( ( hostileStrengthMinusThreatInt > 0 ? hostileFaction.TeamBorderColor : hostileFaction.TeamCenterColor ).ColorHexLinearBrighter );
else
RightBuffer.StartColor( "ffffff" );
RightBuffer.Add( ArcenExternalUIUtilities.StrengthTextIcon );
ArcenExternalUIUtilities.WriteRoundedNumberWithSuffix( RightBuffer, threatStrengthInt, true, true );
}
}
public abstract void PickOtherThingsToShow(Planet planet, GameEntity_Squad EntityToSkip, GameEntity_Squad[] ArrayToFill);
public void WriteEntityPlanetViewText( GameEntity_Base entity, ArcenDoubleCharacterBuffer Buffer)
{
int debugLine = 0;
try
{
debugLine = 1;
bool debug = false;
if ( entity == null )
return;
debugLine = 2;
if ( entity.TypeData.OtherSpecialType != OtherSpecialEntityType.Wormhole )
return;
GameEntity_Other wormhole = (GameEntity_Other)entity;
debugLine = 3;
Planet currentPlanet = entity.Planet;
debugLine = 4;
Planet wormholeDestPlanet = wormhole.GetLinkedPlanet();
debugLine = 5;
if ( wormholeDestPlanet == null )
return;
debugLine = 6;
bool shouldBeSelectedColorOnText = entity == GameEntity_Base.CurrentlyHoveredOver;
debugLine = 6;
Faction faction = wormholeDestPlanet.GetControllingFaction();
debugLine = 7;
if ( debug ) ArcenDebugging.ArcenDebugLogSingleLine( "currentPlanet " + currentPlanet.Name + " wormhole to " + wormholeDestPlanet.Name + " figuring out colour", Verbosity.DoNotShow );
debugLine = 8;
if ( faction != null && faction.Type != FactionType.NaturalObject && wormholeDestPlanet.HumansHaveCurrentBroadIntel )
{
debugLine = 9;
bool isWaveIncomingThroughWormhole = false;
debugLine = 10;
Faction controllingFaction = currentPlanet.GetControllingFaction();
debugLine = 1001;
if ( controllingFaction != null && controllingFaction.Type == FactionType.Player && faction.Type == FactionType.AI )
{
debugLine = 11;
//check whether this wormhole has a wave going to come through it,
//and if so then show that
if ( faction.Type == FactionType.AI )
{
debugLine = 12;
List localList = faction.GetWaveList();
debugLine = 13;
for ( int i = 0; i < localList.Count; i++ )
{
debugLine = 14;
PlannedWave wave = localList[i];
debugLine = 15;
if ( wave.playerBeingAlerted )
{
debugLine = 16;
Planet warpGatePlanet = World_AIW2.Instance.GetPlanetByIndex( wave.planetWithWarpGateIdx );
debugLine = 17;
Planet targetPlanet = World_AIW2.Instance.GetPlanetByIndex( wave.targetPlanetIdx );
debugLine = 18;
if ( targetPlanet == currentPlanet && wormholeDestPlanet == warpGatePlanet )
{
debugLine = 19;
isWaveIncomingThroughWormhole = true;
debugLine = 20;
i = localList.Count;
debugLine = 21;
}
}
}
}
}
debugLine = 22;
if ( isWaveIncomingThroughWormhole ) //not a AI wave coming, so just show the faction team colour
{
debugLine = 23;
if ( debug ) ArcenDebugging.ArcenDebugLogSingleLine( "currentPlanet " + currentPlanet.Name + " wormhole to " + wormholeDestPlanet.Name + " showing incoming wave colour", Verbosity.DoNotShow );
debugLine = 24;
Color incomingWaveColour = ColorMath.Red;
debugLine = 25;
Color colorToShow = ColorMath.GetTimeLerpedColor( incomingWaveColour, faction.TeamCenterColor.TeamColor, 3000 );
debugLine = 26;
Buffer.Add( "" );
debugLine = 27;
}
else
{
debugLine = 28;
if ( debug ) ArcenDebugging.ArcenDebugLogSingleLine( "currentPlanet " + currentPlanet.Name + " wormhole to " + wormholeDestPlanet.Name + " showing faction colour " + faction.TeamCenterColor, Verbosity.DoNotShow );
debugLine = 29;
Buffer.Add( "" );
debugLine = 30;
}
}
else
{
debugLine = 31;
if ( debug ) ArcenDebugging.ArcenDebugLogSingleLine( "currentPlanet " + currentPlanet.Name + " wormhole to " + wormholeDestPlanet.Name + " showing showing no owner", Verbosity.DoNotShow );
debugLine = 32;
Buffer.Add( "" );
debugLine = 33;
}
debugLine = 34;
Buffer.Add( wormholeDestPlanet.Name );
debugLine = 35;
Buffer.Add( "" );
debugLine = 36;
}
catch ( Exception e )
{
ArcenDebugging.ArcenDebugLog( "Warning: WriteEntityPlanetViewText encountered exception on debugLine==" + debugLine + "\n" + e.ToString(), Verbosity.ShowAsInfo );
}
}
}
public class GalaxyMapDisplayMode_Normal : BaseGalaxyMapDisplayMode
{
public override void PickOtherThingsToShow(Planet planet, GameEntity_Squad EntityToSkip, GameEntity_Squad[] ArrayToFill)
{
// UtilityMethodsFor_GalaxyMapDisplayMode.BasePickGalaxyMapOtherThingsToShow( planet, EntityToSkip, ArrayToFill,
// delegate(GameEntity_Squad entity) { return ArcenStrings.ListContains( entity.TypeData.Tags, "ShowsOnNormalDisplayMode" ); } );
//As a stopgap during the UI upheaval, "Normal" now just does the most critical gameplay elements
UtilityMethodsFor_GalaxyMapDisplayMode.BasePickGalaxyMapOtherThingsToShow( planet, EntityToSkip, ArrayToFill,
delegate( GameEntity_Squad entity )
{
return ArcenStrings.ListContains( entity.TypeData.Tags, "ShowsOnNormalDisplayMode" ) || ArcenStrings.ListContains( entity.TypeData.Tags, "ProgressReducer" ) || ArcenStrings.ListContains( entity.TypeData.Tags, "Capturable" );
} );
}
}
}