Code:
// Decompiled with JetBrains decompiler
// Type: maddox.game.world.Strategy
// Assembly location: <SteamLibrary>steamapps\common\IL-2 Sturmovik Cliffs of Dover Blitz\parts\core\Strategy.dll
// Compiler-generated code is shown
using maddox.GP;
using part;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace maddox.game.world;
public class Strategy : ABattle
{
internal List<Army> army;
private Hashtable lastDamagerMap;
[CompilerGenerated]
private static Strategy \u003CTHIS\u003Ek__BackingField;
private bool missionResult;
private Strategy.DamagerList damList;
private int curArmy;
public Dictionary<Player, int> logServer_lastPlayerArmy;
private ISectionFile cfg;
private int logLevelActorCreateAlly;
private int logLevelActorCreateEnemy;
private bool isAlly;
private bool isEnemy;
private bool isAll;
private List<Player> toAlly;
private List<Player> toEnemy;
public static Strategy THIS
{
[CompilerGenerated] get
{
return Strategy.\u003CTHIS\u003Ek__BackingField;
}
[CompilerGenerated] private set
{
Strategy.\u003CTHIS\u003Ek__BackingField = value;
}
}
public Strategy()
{
this.army = new List<Army>();
this.lastDamagerMap = new Hashtable();
this.damList = new Strategy.DamagerList();
this.logServer_lastPlayerArmy = new Dictionary<Player, int>();
this.toAlly = new List<Player>();
this.toEnemy = new List<Player>();
base.\u002Ector();
Strategy.THIS = this;
}
public override void OnEventGame(
GameEventId eventId,
object eventArg0,
object eventArg1,
int eventArgInt)
{
base.OnEventGame(eventId, eventArg0, eventArg1, eventArgInt);
AiActor aiActor = eventArg0 as AiActor;
switch (eventId)
{
case GameEventId.BattleInit:
StratRnd.Reset();
if (this.GamePlay.gpFrontExist())
{
foreach (int gpArmy in this.GamePlay.gpArmies())
{
Army army = new Army(this);
army.army = gpArmy;
this.army.Add(army);
}
break;
}
Army army1 = new Army(this);
this.army.Add(army1);
army1.army = this.army.IndexOf(army1);
Army army2 = new Army(this);
this.army.Add(army2);
army2.army = this.army.IndexOf(army2);
break;
case GameEventId.BattleStarted:
if (this.army.Count == 0)
break;
int count = this.army[0].transports.Count;
break;
case GameEventId.BattleStoped:
this.lastDamagerMap.Clear();
if (this.army.Count == 0)
break;
for (int index = 0; index < this.army.Count; ++index)
this.army[index].release();
break;
case GameEventId.ActorCreated:
if (aiActor == null || !aiActor.IsAlive() || this.army.Count == 0)
break;
int index1 = !this.GamePlay.gpFrontExist() ? aiActor.Army() - 1 : this.GamePlay.gpFrontArmy(aiActor.Pos().x, aiActor.Pos().y) - 1;
if (index1 < 0)
index1 = 0;
while (index1 >= this.army.Count)
{
Army army3 = new Army(this);
this.army.Add(army3);
army3.army = this.army.IndexOf(army3);
}
Army a = this.army[index1];
if (eventArg0 is AiAirGroup)
{
AiAirGroup ag = eventArg0 as AiAirGroup;
if (!a.own.Contains(ag))
a.own.Add(ag);
}
if (eventArg0 is AiAirport)
{
Airdrome tag = new Airdrome(a);
LocalAppDomainTag.setTag(aiActor, (object) tag);
tag.P = new Point2d(aiActor.Pos().x, aiActor.Pos().y);
a.warObjects.Add((WarObject) tag);
break;
}
if (!(eventArg0 is AiAIChief))
break;
AiAIChief aiAiChief = eventArg0 as AiAIChief;
if (aiAiChief.GroupType() != AiGroundGroupType.Town)
break;
AiActor[] items = aiAiChief.GetItems();
Port port = new Port(a);
LocalAppDomainTag.setTag(aiActor, (object) port);
port.R = aiAiChief.FieldR();
if (port.food >= 0)
port.resources[port.food].donor = true;
if (port.staff >= 0)
port.resources[port.staff].donor = true;
if (items != null)
{
Technics technics = new Technics((WarObject) port);
port.tech = port.resources.Count;
port.resources.Add((Resource) technics);
foreach (AiActor tech_instance in items)
{
if (tech_instance is AiGroundGroup aiGroundGroup)
technics.Add(aiGroundGroup.ID(), tech_instance);
else
technics.Add((string) null, tech_instance);
}
}
port.P = new Point2d(aiActor.Pos().x, aiActor.Pos().y);
a.warObjects.Add((WarObject) port);
break;
case GameEventId.ActorDestroyed:
if (aiActor == null || this.army.Count == 0)
break;
if (LocalAppDomainTag.getTag(aiActor) is Resource tag1 && tag1.Tag == aiActor)
tag1.Tag = (object) null;
WarObject tag2 = LocalAppDomainTag.getTag(aiActor) as WarObject;
break;
case GameEventId.ActorDamaged:
case GameEventId.AircraftDamaged:
case GameEventId.AircraftCutLimb:
AiDamageInitiator aiDamageInitiator1 = eventArg1 as AiDamageInitiator;
if (aiActor == aiDamageInitiator1.Actor || aiDamageInitiator1.Person == null)
break;
this.lastDamagerMap[(object) aiActor] = (object) aiDamageInitiator1.Person;
break;
case GameEventId.ActorDead:
if (aiActor == null)
break;
if (!(eventArg1 is AiDamageInitiator aiDamageInitiator2) || aiActor == aiDamageInitiator2.Actor || aiDamageInitiator2.Person == null)
aiDamageInitiator2 = this.lastDamagerMap[(object) aiActor] as AiDamageInitiator;
if (aiDamageInitiator2 != null && aiDamageInitiator2.Person == null)
aiDamageInitiator2.Person.SayNiceKill();
if (!this.lastDamagerMap.ContainsKey((object) aiActor))
break;
this.lastDamagerMap.Remove((object) aiActor);
break;
case GameEventId.ActorTaskCompleted:
if (aiActor == null || !(LocalAppDomainTag.getTag(aiActor) is Resource tag3))
break;
tag3.curVal = tag3.initVal;
tag3.Tag = (object) null;
break;
case GameEventId.AiAirNewEnemy:
AiAirEnemyElement aiAirEnemyElement = eventArg0 as AiAirEnemyElement;
AirGroupID ID = new AirGroupID(aiAirEnemyElement.agID, aiAirEnemyElement.army);
this.army[eventArgInt].updateEnemy(ID, (IDState) aiAirEnemyElement.state);
break;
}
}
public override void OnTickGame()
{
base.OnTickGame();
try
{
if (this.Time.tickCounter() % 64 /*0x40*/ != 0)
return;
this.updateArmies();
if (this.missionResult)
return;
bool? nullable1 = this.checkBattleGoal();
bool? nullable2 = nullable1;
bool flag = false;
if (nullable2.GetValueOrDefault() == flag & nullable2.HasValue)
{
this.GamePlay.gpHUDLogCenter("Mission failed.");
this.missionResult = true;
this.doSingleBattleSuccess(false);
}
else
{
if (!nullable1.GetValueOrDefault())
return;
this.GamePlay.gpHUDLogCenter("Mission succeeded.");
this.missionResult = true;
this.doSingleBattleSuccess(true);
}
}
catch (Exception ex)
{
}
}
public override bool? checkBattleGoal()
{
if (!this.GamePlay.gpIsServerSingle())
return new bool?();
if (this.GamePlay.gpPlayer().Place() is AiAircraft)
{
AiAirGroup aiAirGroup = (AiAirGroup) this.GamePlay.gpPlayer().Place().Group();
if (aiAirGroup.InitNOfAirc > 0)
{
if ((double) aiAirGroup.DiedAircrafts * 2.0 > (double) aiAirGroup.InitNOfAirc)
return new bool?(false);
foreach (AiWayPoint aiWayPoint in aiAirGroup.GetWay())
{
AiAirWayPoint aiAirWayPoint = aiWayPoint as AiAirWayPoint;
if (aiAirWayPoint.Action != AiAirWayPointType.NORMFLY && aiAirWayPoint.Action != AiAirWayPointType.TAKEOFF && aiAirWayPoint.Action != AiAirWayPointType.LANDING)
{
if (aiAirWayPoint.Action == AiAirWayPointType.ESCORT && aiAirWayPoint.Target is AiAirGroup)
{
AiAirGroup target = (AiAirGroup) aiAirWayPoint.Target;
if ((double) target.DiedAircrafts * 3.0 > (double) target.InitNOfAirc)
return new bool?(false);
}
if (aiAirWayPoint.Action == AiAirWayPointType.AATTACK_FIGHTERS && aiAirWayPoint.Target is AiAirGroup)
{
AiAirGroup target = (AiAirGroup) aiAirWayPoint.Target;
if ((double) target.DiedAircrafts * 3.0 > (double) target.InitNOfAirc)
return new bool?(true);
}
if (aiAirWayPoint.Action == AiAirWayPointType.AATTACK_BOMBERS && aiAirWayPoint.Target is AiAirGroup)
{
AiAirGroup target = (AiAirGroup) aiAirWayPoint.Target;
if ((double) target.DiedAircrafts * 3.0 > (double) target.InitNOfAirc)
return new bool?(true);
}
if (aiAirWayPoint.Action == AiAirWayPointType.HUNTING && aiAirWayPoint.Target is AiAirGroup && ((AiAirGroup) aiAirWayPoint.Target).DiedAircrafts > 2)
return new bool?(true);
if (aiAirWayPoint.Action == AiAirWayPointType.GATTACK_TARG && aiAirWayPoint.Target != null && !aiAirWayPoint.Target.IsAlive())
return new bool?(true);
break;
}
}
}
}
return new bool?();
}
public override ArrayList GetEnemyAirGroupIDs(Player player)
{
int num = player.Army();
if (num == 0 || num > this.army.Count)
return (ArrayList) null;
EnemyAirForceList enemy = this.army[num - 1].enemy;
ArrayList enemyAirGroupIds = new ArrayList(enemy.Count);
foreach (EnemyAirForce enemyAirForce in (List<EnemyAirForce>) enemy)
enemyAirGroupIds.Add((object) enemyAirForce.ID_);
return enemyAirGroupIds;
}
public override ArrayList GetDamageInitiators(AiActor victim)
{
ArrayList damageInitiators = new ArrayList();
int index = this.damList.victim.IndexOf(victim);
if (index >= 0)
{
foreach (DamagerScore damagerScore in this.damList.damagers[index])
{
if (victim != damagerScore.initiator.Actor)
damageInitiators.Add((object) damagerScore);
}
}
return damageInitiators;
}
public override ArrayList GetDamageVictims()
{
ArrayList damageVictims = new ArrayList(this.damList.victim.Count);
foreach (AiActor aiActor in this.damList.victim)
damageVictims.Add((object) aiActor);
return damageVictims;
}
public override double ComputePlayerScore(Player player, AiActor victim)
{
double playerScore = 0.0;
int index = this.damList.victim.IndexOf(victim);
if (index >= 0)
{
List<DamagerScore> damager = this.damList.damagers[index];
double num = 0.0;
foreach (DamagerScore damagerScore in damager)
{
if (victim != damagerScore.initiator.Actor)
num += damagerScore.score;
}
if (victim.IsAlive())
num *= 2.0;
foreach (DamagerScore damagerScore in damager)
{
if (damagerScore.initiator.Player == player && victim != damagerScore.initiator.Actor)
playerScore += damagerScore.score / num;
}
}
return playerScore;
}
public int AddScoreToInitiator(AiActor actor, AiDamageInitiator initiator, double score)
{
DamagerScore damagerScore = new DamagerScore(initiator, score, this.Time.current());
int index1 = this.damList.victim.IndexOf(actor);
if (index1 >= 0)
{
List<DamagerScore> damager = this.damList.damagers[index1];
int index2 = damager.IndexOf(damagerScore);
if (index2 >= 0)
{
damager[index2].score += score;
damager[index2].time = this.Time.current();
}
else
damager.Insert(0, damagerScore);
}
else
{
this.damList.victim.Insert(0, actor);
List<DamagerScore> damagerScoreList = new List<DamagerScore>();
damagerScoreList.Add(damagerScore);
this.damList.damagers.Insert(0, damagerScoreList);
index1 = 0;
}
return index1;
}
public override void OnActorDamaged(
int missionNumber,
string shortName,
AiActor actor,
AiDamageInitiator initiator,
NamedDamageTypes damageType)
{
switch (damageType)
{
case NamedDamageTypes.ChunkSmallDamage:
case NamedDamageTypes.PartSmallDamage:
case NamedDamageTypes.WeaponSmallDamage:
case NamedDamageTypes.EngineSmallDamage:
case NamedDamageTypes.LifeKeeperPartSmallDamage:
this.AddScoreToInitiator(actor, initiator, 0.1);
break;
case NamedDamageTypes.ChunkLargeDamage:
case NamedDamageTypes.PartLargeDamage:
case NamedDamageTypes.WeaponLargeDamage:
case NamedDamageTypes.EngineLargeDamage:
case NamedDamageTypes.LifeKeeperPartLargeDamage:
this.AddScoreToInitiator(actor, initiator, 0.2);
break;
}
foreach (AMission mission in this.missions)
{
if (mission.IsMissionListener(missionNumber))
mission.OnActorDamaged(missionNumber, shortName, actor, initiator, damageType);
}
}
public override void OnPersonHealth(
AiPerson person,
AiDamageInitiator initiator,
float deltaHealth)
{
this.AddScoreToInitiator((AiActor) person, initiator, (double) deltaHealth / (double) byte.MaxValue);
base.OnPersonHealth(person, initiator, deltaHealth);
}
public override void OnActorDead(
int missionNumber,
string shortName,
AiActor actor,
AiDamageInitiator initiator)
{
if (this.GamePlay.gpPlayer().Place() == actor && this.GamePlay.gpIsServerSingle())
this.GamePlay.gpHUDLogCenter("Press Esc to end mission.");
if (actor is AiPerson)
initiator = (AiDamageInitiator) null;
int index = initiator == null ? this.damList.victim.IndexOf(actor) : this.AddScoreToInitiator(actor, initiator, 0.5);
List<DamagerScore> damages = index < 0 ? new List<DamagerScore>() : this.damList.damagers[index];
foreach (AMission mission in this.missions)
{
if (mission.IsMissionListener(missionNumber))
mission.OnActorDead(missionNumber, shortName, actor, damages);
}
this.LogServer_ActorDead(missionNumber, shortName, actor, initiator);
}
public override void OnAircraftDamaged(
int missionNumber,
string shortName,
AiAircraft aircraft,
AiDamageInitiator initiator,
NamedDamageTypes damageType)
{
base.OnAircraftDamaged(missionNumber, shortName, aircraft, initiator, damageType);
this.AddScoreToInitiator((AiActor) aircraft, initiator, 0.1);
}
public override void OnAircraftLimbDamaged(
int missionNumber,
string shortName,
AiAircraft aircraft,
AiLimbDamage limbDamage)
{
base.OnAircraftLimbDamaged(missionNumber, shortName, aircraft, limbDamage);
this.AddScoreToInitiator((AiActor) aircraft, limbDamage.Initiator, 0.2);
}
private void updateArmies()
{
int count = this.army.Count;
if (count == 0)
return;
if (this.curArmy >= count)
this.curArmy = 0;
this.army[this.curArmy].update();
++this.curArmy;
}
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
if (this.GamePlay.gpPlayer().Place() == aircraft && this.GamePlay.gpIsServerSingle())
this.Timeout(20.0, new DoTimeout((object) this, __methodptr(\u003COnAircraftLanded\u003Eb__25_0)));
base.OnAircraftLanded(missionNumber, shortName, aircraft);
this.LogServer_AircraftLanded(missionNumber, shortName, aircraft);
}
public override void OnAircraftCrashLanded(
int missionNumber,
string shortName,
AiAircraft aircraft)
{
if (this.GamePlay.gpPlayer().Place() == aircraft && this.GamePlay.gpIsServerSingle())
this.Timeout(20.0, new DoTimeout((object) this, __methodptr(\u003COnAircraftCrashLanded\u003Eb__26_0)));
base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
this.LogServer_AircraftCrashLanded(missionNumber, shortName, aircraft);
}
public override void OnBattleStarted()
{
base.OnBattleStarted();
this.LogServer_BattleStarted();
}
public override void OnBattleStoped()
{
base.OnBattleStoped();
this.LogServer_BattleStoped();
}
public override void OnPlayerArmy(Player player, int army)
{
base.OnPlayerArmy(player, army);
this.LogServer_PlayerArmy(player, army);
}
public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);
this.LogServer_ActorCreated(missionNumber, shortName, actor);
}
public override void OnPersonMoved(AiPerson person, AiActor fromCart, int fromPlaceIndex)
{
base.OnPersonMoved(person, fromCart, fromPlaceIndex);
this.LogServer_PersonMoved(person, fromCart, fromPlaceIndex);
}
public override void OnPersonParachuteFailed(AiPerson person)
{
base.OnPersonParachuteFailed(person);
this.LogServer_PersonParachuteFailed(person);
}
public override void OnPersonParachuteLanded(AiPerson person)
{
base.OnPersonParachuteLanded(person);
this.LogServer_PersonParachuteLanded(person);
}
public virtual void LogServer_BattleStarted()
{
this.GamePlay.gpLogServer((Player[]) null, "Battle begins!", (object[]) null);
}
public virtual void LogServer_BattleStoped()
{
this.GamePlay.gpLogServer((Player[]) null, "The battle ends.", (object[]) null);
}
public virtual void LogServer_PlayerArmy(Player player, int army)
{
if (this.logServer_lastPlayerArmy.ContainsKey(player))
{
this.logServer_lastPlayerArmy[player] = army;
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} is now with the {1} army.");
break;
case 1:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} has defected as is now {1}.");
break;
case 2:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} may be a turncoat! He has switched to {1}.");
break;
}
}
else
{
this.logServer_lastPlayerArmy.Add(player, army);
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} joins the {1} army.");
break;
case 1:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} enlists in the {1} air force.");
break;
case 2:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} will fly for the {1} forces.");
break;
}
}
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) player
});
this.GamePlay.gpLogServerArg(true, this.GamePlay.gpArmyName(army), (object[]) null);
this.GamePlay.gpLogServerEnd();
}
private ISectionFile readConf()
{
ISectionFile sectionFile = this.GamePlay.gpConfigUserFile();
this.logLevelActorCreateAlly = sectionFile.get("MsgLevel", "ActorCreateAlly", 0);
this.logLevelActorCreateEnemy = sectionFile.get("MsgLevel", "ActorCreateEnemy", 0);
this.isAlly = this.logLevelActorCreateAlly != 0;
this.isEnemy = this.logLevelActorCreateEnemy != 0;
this.isAll = this.logLevelActorCreateAlly == this.logLevelActorCreateEnemy;
return sectionFile;
}
private string getActorCreateStr(int level)
{
int num = Strategy.LogServerRnd.nextInt(0, 2);
switch (level)
{
case 1:
switch (num)
{
case 0:
return "New {0} group of {1}x{2} spotted in sector {3}.";
case 1:
return "A group of {0} {1}x{2} just appeared in sector {3}.";
case 2:
return "A new group of {1} {0} aircraft identified as {2} was reported in sector {3}.";
}
break;
case 2:
switch (num)
{
case 0:
return "New {0} group of {1}x{2} spotted.";
case 1:
return "A group of {0} {1}x{2} just appeared.";
case 2:
return "A new group of {1} {0} aircraft identified as {2} was reported.";
}
break;
case 3:
switch (num)
{
case 0:
return "New {0} group of {1} spotted.";
case 1:
return "A group of {0} {1} just appeared.";
case 2:
return "A new group of {1} {0} aircraft was reported.";
}
break;
}
return "";
}
public virtual void LogServer_ActorCreated(int missionNumber, string shortName, AiActor actor)
{
if (this.cfg == null)
this.cfg = this.readConf();
if (!this.isAlly && !this.isEnemy || !this.GamePlay.gpBattleIsRun() || !(actor is AiAirGroup))
return;
AiAirGroup aiAirGroup = actor as AiAirGroup;
if (aiAirGroup.NOfAirc == 0)
return;
int army = aiAirGroup.Army();
if (!this.isAll)
{
this.toAlly.Clear();
this.toEnemy.Clear();
Player player = this.GamePlay.gpPlayer();
if (this.isAlly && player.Army() == army)
this.toAlly.Add(player);
if (this.isEnemy && player.Army() != army)
this.toEnemy.Add(player);
foreach (Player gpRemotePlayer in this.GamePlay.gpRemotePlayers())
{
if (gpRemotePlayer.Army() != 0)
{
if (this.isAlly && gpRemotePlayer.Army() == army)
this.toAlly.Add(gpRemotePlayer);
if (this.isEnemy && gpRemotePlayer.Army() != army)
this.toEnemy.Add(gpRemotePlayer);
}
}
}
if (this.isAll)
{
this.GamePlay.gpLogServerBegin((Player[]) null, this.getActorCreateStr(this.logLevelActorCreateAlly));
this.GamePlay.gpLogServerArg(true, this.GamePlay.gpArmyName(army), (object[]) null);
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) aiAirGroup.NOfAirc
});
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) aiAirGroup.GetItems()[0]
});
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) this.GamePlay.gpSectorName(aiAirGroup.Pos().x, aiAirGroup.Pos().y)
});
this.GamePlay.gpLogServerEnd();
}
else
{
if (this.isAlly && this.toAlly.Count > 0)
{
this.GamePlay.gpLogServerBegin(this.toAlly.ToArray(), this.getActorCreateStr(this.logLevelActorCreateAlly));
this.GamePlay.gpLogServerArg(true, this.GamePlay.gpArmyName(army), (object[]) null);
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) aiAirGroup.NOfAirc
});
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) aiAirGroup.GetItems()[0]
});
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) this.GamePlay.gpSectorName(aiAirGroup.Pos().x, aiAirGroup.Pos().y)
});
this.GamePlay.gpLogServerEnd();
}
if (!this.isEnemy || this.toEnemy.Count <= 0)
return;
this.GamePlay.gpLogServerBegin(this.toEnemy.ToArray(), this.getActorCreateStr(this.logLevelActorCreateEnemy));
this.GamePlay.gpLogServerArg(true, this.GamePlay.gpArmyName(army), (object[]) null);
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) aiAirGroup.NOfAirc
});
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) aiAirGroup.GetItems()[0]
});
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) this.GamePlay.gpSectorName(aiAirGroup.Pos().x, aiAirGroup.Pos().y)
});
this.GamePlay.gpLogServerEnd();
}
}
public virtual void LogServer_ActorDead(
int missionNumber,
string shortName,
AiActor actor,
AiDamageInitiator initiator)
{
switch (actor)
{
case AiAircraft _:
this.LogServer_AircraftDead(missionNumber, shortName, actor as AiAircraft);
break;
case AiPerson _:
this.LogServer_PersonDead(missionNumber, shortName, actor as AiPerson);
break;
case AiGroundActor _:
this.LogServer_GroundDead(missionNumber, shortName, actor as AiGroundActor);
break;
}
}
public virtual void LogServer_AircraftDead(
int missionNumber,
string shortName,
AiAircraft aircraft)
{
ArrayList damageInitiators = this.GetDamageInitiators((AiActor) aircraft);
Dictionary<DamagerScore, object> dictionary = new Dictionary<DamagerScore, object>();
List<AiDamageInitiator> list = new List<AiDamageInitiator>();
bool? nullable1 = new bool?();
for (int index = 0; index < damageInitiators.Count; ++index)
{
DamagerScore key = damageInitiators[index] as DamagerScore;
if (!dictionary.ContainsKey(key) && key.initiator.Actor != null)
{
if (!nullable1.GetValueOrDefault() && key.initiator.Actor != aircraft)
nullable1 = new bool?(key.initiator.Actor.Army() != aircraft.Army());
dictionary.Add(key, (object) null);
list.Add(key.initiator);
}
}
if (aircraft.IsAirborne())
{
if (!nullable1.HasValue)
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} crashed.");
break;
case 1:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} is no more.");
break;
case 2:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} collided with terrain.");
break;
}
}
else
{
bool? nullable2 = nullable1;
bool flag = false;
if (nullable2.GetValueOrDefault() == flag & nullable2.HasValue)
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} claimed a friendly kill: {0}.");
break;
case 1:
this.GamePlay.gpLogServerBegin((Player[]) null, "Friendly fire! {1} destroyed {0}.");
break;
case 2:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} destroyed a friendly {0}.");
break;
}
}
else if (nullable1.GetValueOrDefault())
{
switch (Strategy.LogServerRnd.nextInt(0, 4))
{
case 0:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} shot down {0}.");
break;
case 1:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} destroyed {0}.");
break;
case 2:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} claimed {0}.");
break;
case 3:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} was destroyed by {1}.");
break;
case 4:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} was shot down by {1}.");
break;
}
}
}
}
else if (!nullable1.HasValue)
{
if (Strategy.LogServerRnd.nextInt(0, 0) == 0)
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} crashed.");
}
else
{
switch (Strategy.LogServerRnd.nextInt(0, 1))
{
case 0:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} destroyed {0} on the ground.");
break;
case 1:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} was blown up by {1} before he could take off.");
break;
}
}
this.LogServer_VictimArg(true, aircraft, aircraft.Player(aircraft.Carter()));
if (nullable1.HasValue)
this.LogServer_InitiatorsArg(list);
this.GamePlay.gpLogServerEnd();
}
public virtual void LogServer_VictimArg(bool first, AiAircraft aircraft, Player player)
{
if (player != null)
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServerArg((first ? 1 : 0) != 0, "{0}’s {1}({2})", new object[3]
{
(object) player.Name(),
(object) aircraft,
(object) aircraft.TypedName()
});
break;
case 1:
this.GamePlay.gpLogServerArg((first ? 1 : 0) != 0, "{1}({2}) flown by {0}", new object[3]
{
(object) player.Name(),
(object) aircraft,
(object) aircraft.TypedName()
});
break;
case 2:
this.GamePlay.gpLogServerArg((first ? 1 : 0) != 0, "{0} in a {1}({2})", new object[3]
{
(object) player.Name(),
(object) aircraft,
(object) aircraft.TypedName()
});
break;
}
}
else
{
switch (Strategy.LogServerRnd.nextInt(0, 1))
{
case 0:
this.GamePlay.gpLogServerArg((first ? 1 : 0) != 0, "AI {0}({1})", new object[2]
{
(object) aircraft,
(object) aircraft.TypedName()
});
break;
case 1:
this.GamePlay.gpLogServerArg((first ? 1 : 0) != 0, "AI in a {0}({1})", new object[2]
{
(object) aircraft,
(object) aircraft.TypedName()
});
break;
}
}
}
public virtual void LogServer_InitiatorsArg(List<AiDamageInitiator> list)
{
bool first = true;
foreach (AiDamageInitiator aiDamageInitiator in list)
{
if (aiDamageInitiator.Actor is AiAircraft)
this.LogServer_VictimArg(first, aiDamageInitiator.Actor as AiAircraft, aiDamageInitiator.Player);
else
this.GamePlay.gpLogServerArg((first ? 1 : 0) != 0, "{0}", new object[1]
{
(object) aiDamageInitiator.Actor
});
first = false;
}
}
public virtual void LogServer_AircraftLanded(
int missionNumber,
string shortName,
AiAircraft aircraft)
{
Player player = aircraft.Player(aircraft.Carter());
if (player == null)
return;
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServer((Player[]) null, "{0} landed.", new object[1]
{
(object) player
});
break;
case 1:
this.GamePlay.gpLogServer((Player[]) null, "{0} returned to base.", new object[1]
{
(object) player
});
break;
case 2:
this.GamePlay.gpLogServer((Player[]) null, "{0} is safe on the ground.", new object[1]
{
(object) player
});
break;
}
}
public virtual void LogServer_AircraftCrashLanded(
int missionNumber,
string shortName,
AiAircraft aircraft)
{
Player player = aircraft.Player(aircraft.Carter());
if (player == null)
return;
this.GamePlay.gpLogServer((Player[]) null, "{0} crash landed.", new object[1]
{
(object) player
});
}
public virtual void LogServer_PersonMoved(AiPerson person, AiActor fromCart, int fromPlaceIndex)
{
if (person.Cart() != null || !(fromCart is AiAircraft) || !(fromCart as AiAircraft).IsAirborne())
return;
Player player = person.Player();
AiAircraft aiAircraft = fromCart as AiAircraft;
if (player == null)
{
if (aiAircraft.CrewFunctionPlace(fromPlaceIndex) != CrewFunction.Pilot)
return;
if (aiAircraft.Places() == 1)
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServer((Player[]) null, "{0}({1}) AI Pilot bailed out.", new object[2]
{
(object) aiAircraft,
(object) aiAircraft.TypedName()
});
break;
case 1:
this.GamePlay.gpLogServer((Player[]) null, "{0}({1}) AI Pilot had to jump.", new object[2]
{
(object) aiAircraft,
(object) aiAircraft.TypedName()
});
break;
case 2:
this.GamePlay.gpLogServer((Player[]) null, "{0}({1}) AI Pilot hit the silk.", new object[2]
{
(object) aiAircraft,
(object) aiAircraft.TypedName()
});
break;
}
}
else
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServer((Player[]) null, "{0}({1}) AI Crew bailed out.", new object[2]
{
(object) aiAircraft,
(object) aiAircraft.TypedName()
});
break;
case 1:
this.GamePlay.gpLogServer((Player[]) null, "{0}({1}) AI Crew had to jump.", new object[2]
{
(object) aiAircraft,
(object) aiAircraft.TypedName()
});
break;
case 2:
this.GamePlay.gpLogServer((Player[]) null, "{0}({1}) AI Crew hit the silk.", new object[2]
{
(object) aiAircraft,
(object) aiAircraft.TypedName()
});
break;
}
}
}
else if (aiAircraft.CrewFunctionPlace(fromPlaceIndex) == CrewFunction.Pilot)
{
if (aiAircraft.Places() == 1)
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServer((Player[]) null, "{0}({2}) {1} bailed out.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
case 1:
this.GamePlay.gpLogServer((Player[]) null, "{0}({2}) {1} had to jump.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
case 2:
this.GamePlay.gpLogServer((Player[]) null, "{0}({2}) {1} hit the silk.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
}
}
else
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServer((Player[]) null, "{0}({2}) {1} and crew bailed out.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
case 1:
this.GamePlay.gpLogServer((Player[]) null, "{0}({2}) {1} and crew had to jump.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
case 2:
this.GamePlay.gpLogServer((Player[]) null, "{0}({2}) {1} and crew hit the silk.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
}
}
}
else
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServer((Player[]) null, "{0} {1} bailed out.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
case 1:
this.GamePlay.gpLogServer((Player[]) null, "{0} {1} had to jump.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
case 2:
this.GamePlay.gpLogServer((Player[]) null, "{0} {1} hit the silk.", new object[3]
{
(object) aiAircraft,
(object) player,
(object) aiAircraft.TypedName()
});
break;
}
}
}
public virtual void LogServer_PersonDead(int missionNumber, string shortName, AiPerson person)
{
if (person.Cart() == null || !(person.Cart() is AiAircraft))
return;
ArrayList damageInitiators = this.GetDamageInitiators((AiActor) person);
Dictionary<DamagerScore, object> dictionary = new Dictionary<DamagerScore, object>();
List<AiDamageInitiator> list = new List<AiDamageInitiator>();
for (int index = 0; index < damageInitiators.Count; ++index)
{
DamagerScore key = damageInitiators[index] as DamagerScore;
if (!dictionary.ContainsKey(key) && key.initiator.Actor != null)
{
dictionary.Add(key, (object) null);
list.Add(key.initiator);
}
}
bool flag = list.Count == 0 || list.Count == 1 && person.Cart() == list[0].Actor;
if (flag)
{
if (Strategy.LogServerRnd.nextInt(0, 0) == 0)
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} is dead.");
}
else
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} dispatched {0}.");
break;
case 1:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} killed {0}.");
break;
case 2:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} is no more {1}.");
break;
}
}
if (person.Player() != null)
this.GamePlay.gpLogServerArg(true, "{0} {1}({3}) {2}", new object[4]
{
(object) person.Player(),
(object) person.Cart(),
(object) person,
(object) (person.Cart() as AiAircraft).TypedName()
});
else
this.GamePlay.gpLogServerArg(true, "AI {1}({2}) {0}", new object[3]
{
(object) person.Cart(),
(object) person,
(object) (person.Cart() as AiAircraft).TypedName()
});
if (!flag)
this.LogServer_InitiatorsArg(list);
this.GamePlay.gpLogServerEnd();
}
public virtual void LogServer_PersonParachuteLanded(AiPerson person)
{
if (person.Player() == null)
return;
this.GamePlay.gpLogServer((Player[]) null, "{0} parachute landed.", new object[1]
{
(object) person.Player()
});
}
public virtual void LogServer_PersonParachuteFailed(AiPerson person)
{
if (person.Player() == null)
return;
this.GamePlay.gpLogServer((Player[]) null, "{0} parachute failed.", new object[1]
{
(object) person.Player()
});
}
public virtual void LogServer_GroundDead(
int missionNumber,
string shortName,
AiGroundActor actor)
{
switch (actor.Type())
{
case AiGroundActorType.ShipMisc:
case AiGroundActorType.ShipTransport:
case AiGroundActorType.ShipSmallWarship:
case AiGroundActorType.ShipDestroyer:
case AiGroundActorType.ShipCruiser:
case AiGroundActorType.ShipBattleship:
case AiGroundActorType.ShipCarrier:
case AiGroundActorType.ShipSubmarine:
ArrayList damageInitiators = this.GetDamageInitiators((AiActor) actor);
Dictionary<DamagerScore, object> dictionary = new Dictionary<DamagerScore, object>();
List<AiDamageInitiator> list = new List<AiDamageInitiator>();
for (int index = 0; index < damageInitiators.Count; ++index)
{
DamagerScore key = damageInitiators[index] as DamagerScore;
if (!dictionary.ContainsKey(key) && key.initiator.Actor != null)
{
dictionary.Add(key, (object) null);
list.Add(key.initiator);
}
}
bool flag = list.Count == 0 || list.Count == 1 && actor == list[0].Actor;
if (flag)
{
if (Strategy.LogServerRnd.nextInt(0, 0) == 0)
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} was destroyed.");
}
else
{
switch (Strategy.LogServerRnd.nextInt(0, 2))
{
case 0:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} sank {0}.");
break;
case 1:
this.GamePlay.gpLogServerBegin((Player[]) null, "{0} goes down thanks to {1}.");
break;
case 2:
this.GamePlay.gpLogServerBegin((Player[]) null, "{1} destroyed {0}.");
break;
}
}
this.GamePlay.gpLogServerArg(true, "{0}", new object[1]
{
(object) actor
});
if (!flag)
this.LogServer_InitiatorsArg(list);
this.GamePlay.gpLogServerEnd();
break;
}
}
[CompilerGenerated]
private void \u003COnAircraftLanded\u003Eb__25_0()
{
this.GamePlay.gpHUDLogCenter("Press Esc to end mission.");
}
[CompilerGenerated]
private void \u003COnAircraftCrashLanded\u003Eb__26_0()
{
this.GamePlay.gpHUDLogCenter("Press Esc to end mission.");
}
public class DamagerList
{
public List<AiActor> victim;
public List<List<DamagerScore>> damagers;
public DamagerList()
{
this.victim = new List<AiActor>();
this.damagers = new List<List<DamagerScore>>();
base.\u002Ector();
}
}
public static class LogServerRnd
{
public static Random rnd;
public static int nextInt(int minVal, int maxVal)
{
int num = maxVal - minVal;
if (num < 0)
num = -num;
return minVal + Strategy.LogServerRnd.rnd.Next(num + 1);
}
public static double nextDouble(double minVal, double maxVal)
{
return minVal + (maxVal - minVal) * Strategy.LogServerRnd.rnd.NextDouble();
}
static LogServerRnd()
{
Strategy.LogServerRnd.rnd = new Random(0);
}
}
}
Bookmarks