Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public override IEnumerable<Gizmo> CompGetGizmosExtra()

public override string CompInspectStringExtra()
{
string ret = "";
var ret = new StringBuilder();

if(controller != null)
ret += "ATPP_RemotelyControlledBy".Translate(controller.LabelShortCap) + "\n";
ret.AppendLine("ATPP_RemotelyControlledBy".Translate(controller.LabelShortCap));

return ret.TrimEnd('\r', '\n') + base.CompInspectStringExtra();
return ret.TrimEnd().Append(base.CompInspectStringExtra()).ToString();
}

public override void PostDeSpawn(Map map)
Expand Down
10 changes: 4 additions & 6 deletions Source/Androids For RW1.3/Components/CompSkyCloudCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public bool isOnline()
public override IEnumerable<Gizmo> CompGetGizmosExtra()
{
//If no minds stored
if (storedMinds.Count() == 0 || !isOnline() || !Booted())
if (storedMinds.Count == 0 || !isOnline() || !Booted())
{
yield break;
}
Expand Down Expand Up @@ -606,7 +606,7 @@ public override IEnumerable<Gizmo> CompGetGizmosExtra()
};
}

if (getNbMindsConnectedToSurrogate() != 0 || controlledTurrets.Count() != 0)
if (getNbMindsConnectedToSurrogate() != 0 || controlledTurrets.Count != 0)
{
yield return new Command_Action
{
Expand Down Expand Up @@ -956,7 +956,7 @@ public string getName()
public float getPowerConsumed()
{
CompPowerTrader cpt = Utils.getCachedCPT((Building)this.parent);
return (storedMinds.Count()*Settings.powerConsumedByStoredMind) + cpt.Props.basePowerConsumption;
return (storedMinds.Count*Settings.powerConsumedByStoredMind) + cpt.Props.basePowerConsumption;
}


Expand Down Expand Up @@ -1026,10 +1026,8 @@ public void stopRemotelyControlledTurret(Pawn mind)

private void disconnectAllRemotelyControlledTurrets()
{
List<KeyValuePair<Pawn, Building>> list = controlledTurrets.FastToList();
for (int i = 0; i < list.Count; i++)
foreach(var e in controlledTurrets)
{
KeyValuePair<Pawn, Building> e = list[i];
stopRemotelyControlledTurret(e.Key);
}
}
Expand Down
21 changes: 11 additions & 10 deletions Source/Androids For RW1.3/Components/CompSurrogateOwner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public override void CompTick()
{
sum += sr.levelInt;
}
average = (int)((float)sum / (float)currentPawn.skills.skills.Count());
average = (int)((float)sum / (float)currentPawn.skills.skills.Count);

int nbp = (int)((float)((float)average / (float)20) * Rand.Range(1000, 5000));

Expand Down Expand Up @@ -958,7 +958,7 @@ public void disconnectControlledSurrogate(Pawn surrogate, bool externalControlle

public override string CompInspectStringExtra()
{
string ret = "";
var ret = new StringBuilder();
try
{
if (parent.Map == null)
Expand All @@ -977,7 +977,7 @@ public override string CompInspectStringExtra()
{
p = p = Math.Min(1.0f, (float)(Find.TickManager.TicksGame - permuteStartGT) / (float)(permuteEndingGT - permuteStartGT));
}
ret += "ATPP_PermutationPercentage".Translate(((int)(p * (float)100)).ToString()) + "\n";
ret.AppendLine("ATPP_PermutationPercentage".Translate(((int)(p * (float)100)).ToString()));
}


Expand All @@ -994,7 +994,7 @@ public override string CompInspectStringExtra()
{
p = p = Math.Min(1.0f, (float)(Find.TickManager.TicksGame - duplicateStartGT) / (float)(duplicateEndingGT - duplicateStartGT));
}
ret += "ATPP_DuplicationPercentage".Translate(((int)(p * (float)100)).ToString()) + "\n";
ret.AppendLine("ATPP_DuplicationPercentage".Translate(((int)(p * (float)100)).ToString()));
}

if (uploadToSkyCloudEndingGT != -1)
Expand All @@ -1003,7 +1003,7 @@ public override string CompInspectStringExtra()
float p;

p = p = Math.Min(1.0f, (float)(Find.TickManager.TicksGame - uploadToSkyCloudStartGT) / (float)(uploadToSkyCloudEndingGT - uploadToSkyCloudStartGT));
ret += "ATPP_UploadSkyCloudPercentage".Translate(((int)(p * (float)100)).ToString()) + "\n";
ret.AppendLine("ATPP_UploadSkyCloudPercentage".Translate(((int)(p * (float)100)).ToString()));
}

if (downloadFromSkyCloudEndingGT != -1)
Expand All @@ -1012,7 +1012,7 @@ public override string CompInspectStringExtra()
float p;

p = p = Math.Min(1.0f, (float)(Find.TickManager.TicksGame - downloadFromSkyCloudStartGT) / (float)(downloadFromSkyCloudEndingGT - downloadFromSkyCloudStartGT));
ret += "ATPP_DownloadFromSkyCloudPercentage".Translate(((int)(p * (float)100)).ToString()) + "\n";
ret.AppendLine("ATPP_DownloadFromSkyCloudPercentage".Translate(((int)(p * (float)100)).ToString()));
}

if (mindAbsorptionEndingGT != -1)
Expand All @@ -1021,7 +1021,7 @@ public override string CompInspectStringExtra()
float p;

p = p = Math.Min(1.0f, (float)(Find.TickManager.TicksGame - mindAbsorptionStartGT) / (float)(mindAbsorptionEndingGT - mindAbsorptionStartGT));
ret += "ATPP_MindAbsorptionProgress".Translate(((int)(p * (float)100)).ToString()) + "\n";
ret.AppendLine("ATPP_MindAbsorptionProgress".Translate(((int)(p * (float)100)).ToString()));
}

if (controlMode && availableSX.Count > 0)
Expand All @@ -1039,15 +1039,16 @@ public override string CompInspectStringExtra()
}
}

ret += "ATPP_RemotelyControl".Translate(lst.TrimEnd(' ', ',')) + "\n";
ret.AppendLine("ATPP_RemotelyControl".Translate(lst.TrimEnd(' ', ',')));
}

return ret.TrimEnd('\r', '\n', ' ') + base.CompInspectStringExtra();

return ret.TrimEnd().Append(base.CompInspectStringExtra()).ToString();
}
catch(Exception e)
{
Log.Message("[ATPP] CompSurrogateOwner.CompInspectStringExtra "+e.Message+" "+e.StackTrace);
return ret.TrimEnd('\r', '\n', ' ') + base.CompInspectStringExtra();
return ret.TrimEnd().Append(base.CompInspectStringExtra()).ToString();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ private bool SXInCell(IntVec3 c)
List<Thing> thingList = c.GetThingList(base.Map);
for (int i = 0; i < thingList.Count; i++)
{
if (thingList[i] is Pawn && this.CanDesignateThing(thingList[i]).Accepted)
Thing thing = thingList[i];
if (thing is Pawn && this.CanDesignateThing(thing).Accepted)
{
return true;
}
Expand All @@ -194,7 +195,8 @@ private bool TurretInCell(IntVec3 c)
List<Thing> thingList = c.GetThingList(base.Map);
for (int i = 0; i < thingList.Count; i++)
{
if (thingList[i] != null && (thingList[i].def.thingClass == typeof(Building_Turret) || thingList[i].def.thingClass.IsSubclassOf(typeof(Building_Turret)) ) && this.CanDesignateThing(thingList[i]).Accepted)
Thing thing = thingList[i];
if (thing != null && (thing.def.thingClass == typeof(Building_Turret) || thing.def.thingClass.IsSubclassOf(typeof(Building_Turret)) ) && this.CanDesignateThing(thing).Accepted)
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ private bool SXInCell(IntVec3 c)
List<Thing> thingList = c.GetThingList(base.Map);
for (int i = 0; i < thingList.Count; i++)
{
if (thingList[i] is Pawn && this.CanDesignateThing(thingList[i]).Accepted)
Thing thing = thingList[i];
if (thing is Pawn && this.CanDesignateThing(thing).Accepted)
{
return true;
}
Expand Down
8 changes: 3 additions & 5 deletions Source/Androids For RW1.3/Dialogs/Dialog_SkillUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ namespace MOARANDROIDS
{
public class Dialog_SkillUp : Window
{
private static List<string> libs = new List<string> { "Shooting".Translate(), "Melee".Translate(), "Construction".Translate(), "Mining".Translate(), "Cooking".Translate(), "Plants".Translate(), "Animals".Translate(), "Crafting".Translate(), "Artistic".Translate(), "Medicine".Translate(), "Social".Translate(), "Intellectual".Translate() };
private static List<SkillDef> sd = new List<SkillDef> { SkillDefOf.Shooting, SkillDefOf.Melee, SkillDefOf.Construction, SkillDefOf.Mining, SkillDefOf.Cooking, SkillDefOf.Plants, SkillDefOf.Animals, SkillDefOf.Crafting, SkillDefOf.Artistic, SkillDefOf.Medicine, SkillDefOf.Social, SkillDefOf.Intellectual };

Pawn android;
List<string> libs;
List<SkillDef> sd;
List<int> points;
List<int> passionsState;

Expand Down Expand Up @@ -42,9 +43,6 @@ public Dialog_SkillUp(Pawn android, bool isMind=false)
points = new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
passionsState = new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

libs = new List<string> { "Shooting".Translate(), "Melee".Translate(), "Construction".Translate(), "Mining".Translate(), "Cooking".Translate(), "Plants".Translate(), "Animals".Translate(), "Crafting".Translate(), "Artistic".Translate(), "Medicine".Translate(), "Social".Translate(), "Intellectual".Translate()};
sd = new List<SkillDef> { SkillDefOf.Shooting, SkillDefOf.Melee, SkillDefOf.Construction, SkillDefOf.Mining, SkillDefOf.Cooking, SkillDefOf.Plants, SkillDefOf.Animals, SkillDefOf.Crafting, SkillDefOf.Artistic, SkillDefOf.Medicine, SkillDefOf.Social, SkillDefOf.Intellectual };

int i = 0;
foreach(var csd in sd)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Androids For RW1.3/Harmony/Corpse_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void Listener(Pawn butcher, float efficiency, Corpse __instance, r
if (cas.isSurrogate)
{
List<Thing> res = new List<Thing>();
foreach(var r in __result.ToList())
foreach(var r in __result)
{
if (r.def != null && r.def.defName != "AIPersonaCore")
res.Add(r);
Expand Down
2 changes: 1 addition & 1 deletion Source/Androids For RW1.3/Harmony/PawnGenerator_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static void Listener(PawnGenerationRequest request, ref Pawn __result)

if (Utils.RIMMSQOL_LOADED && Utils.lastResolveAllGraphicsHeadGraphicPath != null)
{
__result.story.GetType().GetField("headGraphicPath", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__result.story, Utils.lastResolveAllGraphicsHeadGraphicPath);
Traverse.Create(__result.story).Field("headGraphicPath").SetValue(Utils.lastResolveAllGraphicsHeadGraphicPath);
Utils.lastResolveAllGraphicsHeadGraphicPath = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static void Listener(PawnGroupMakerParms parms, bool warnOnZeroResults, r
tmp.Remove(p);
}

List<Pawn> tmpList = tmp.FastToList();
IEnumerator<Pawn> tmpList = tmp.GetEnumerator();

//On va se servir des nb pawn pregénéré par la fonction patché comme controller
for (int i = 0; i != nb; i++)
Expand All @@ -93,7 +93,8 @@ public static void Listener(PawnGroupMakerParms parms, bool warnOnZeroResults, r
//Pawn surrogate = PawnGenerator.GeneratePawn(request);

PawnKindDef rpkd = null;
var tmpListElem = tmpList[i];
tmpList.MoveNext();
var tmpListElem = tmpList.Current;

if (parms.groupKind == PawnGroupKindDefOf.Peaceful || parms.groupKind == PawnGroupKindDefOf.Trader)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Androids For RW1.3/Harmony/TaleRecorder_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static bool Listener(TaleDef def, params object[] args)
{
Pawn p1 = null;
Pawn p2 = null;
int nba = args.Count();
int nba = args.Length;

if (nba >= 2)
{
Expand Down
17 changes: 9 additions & 8 deletions Source/Androids For RW1.3/Incidents/Incident_DeviceHacking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using RimWorld.Planet;
using UnityEngine;
using Verse.Sound;
using System.Text;

namespace MOARANDROIDS
{
Expand All @@ -24,9 +25,9 @@ protected override bool TryExecuteWorker(IncidentParms parms)
if (Settings.disableSkyMindSecurityStuff)
return false;

List<Thing> victims;
HashSet<Thing> victims;
string title = "";
string msg = "";
var msg = new StringBuilder();
int nbConnectedClients = Utils.GCATPP.getNbThingsConnected();
HashSet<string> cryptolockedThings = new HashSet<string>();
int nbDevices = Utils.GCATPP.getNbDevices();
Expand Down Expand Up @@ -84,7 +85,7 @@ protected override bool TryExecuteWorker(IncidentParms parms)


title = "ATPP_IncidentDeviceHackingVirus".Translate();
msg = "ATPP_IncidentDeviceHackingLiteDesc".Translate(nb);
msg.Append("ATPP_IncidentDeviceHackingLiteDesc".Translate(nb));

victims = Utils.GCATPP.getRandomDevices(nb);
if (victims.Count != nb)
Expand Down Expand Up @@ -120,21 +121,21 @@ protected override bool TryExecuteWorker(IncidentParms parms)
else
nb = 1;

msg = "ATPP_IncidentDeviceHackingHardDesc".Translate(nb) + "\n";
msg.AppendLine("ATPP_IncidentDeviceHackingHardDesc".Translate(nb));

switch (attackType)
{
case 1:
title = "ATPP_IncidentDeviceHackingVirus".Translate();
msg += "ATPP_IncidentDeviceVirusedDesc".Translate();
msg.Append("ATPP_IncidentDeviceVirusedDesc".Translate());
break;
case 2:
title = "ATPP_IncidentDeviceHackingExplosiveVirus".Translate();
msg += "ATPP_IncidentDeviceVirusedExplosiveDesc".Translate();
msg.Append("ATPP_IncidentDeviceVirusedExplosiveDesc".Translate());
break;
case 3:
title = "ATPP_IncidentDeviceHackingCryptolocker".Translate();
msg += "ATPP_IncidentDeviceCryptolockerDesc".Translate();
msg.Append("ATPP_IncidentDeviceCryptolockerDesc".Translate());
break;
}

Expand All @@ -160,7 +161,7 @@ protected override bool TryExecuteWorker(IncidentParms parms)
}
}

Find.LetterStack.ReceiveLetter(title, msg, letter, (LookTargets) victims, null, null);
Find.LetterStack.ReceiveLetter(title, msg.ToString(), letter, new LookTargets(victims), null, null);


if (attackType == 3)
Expand Down
4 changes: 2 additions & 2 deletions Source/Androids For RW1.3/Incidents/Incident_RansomWare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ protected override bool TryExecuteWorker(IncidentParms parms)
{
List<TraitDef> tr;
if (victim.IsAndroid())
tr = Utils.RansomAddedBadTraitsAndroid.ToList();
tr = Utils.RansomAddedBadTraitsAndroid.FastToList();
else
tr = Utils.RansomAddedBadTraits.ToList();
tr = Utils.RansomAddedBadTraits.FastToList();


//Purge des traits deja possédé par la victime ET incompatibles avec ceux present
Expand Down
8 changes: 4 additions & 4 deletions Source/Androids For RW1.3/Utils/CPatchs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public static void PowerPP_CompLocalWirelessPowerEmitter_CompInspectStringExtra(
Building build = (Building)__instance.parent;

int nbConn = 0;
if (Utils.GCATPP.listerLWPNAndroid.ContainsKey(build))
nbConn = Utils.GCATPP.listerLWPNAndroid[build].Count();
if (Utils.GCATPP.listerLWPNAndroid.TryGetValue(build, out var list))
nbConn = list.Count;

if (__instance.parent.def.defName == "ARKPPP_LocalWirelessPortablePowerEmitter")
{
Expand Down Expand Up @@ -366,14 +366,14 @@ public static void QEE_Building_GrowerBase_get_CraftingProgressPercentPostfix(Bu
string BUID = __instance.GetUniqueLoadID();

//Si plus de refgerence au pawnBeingGrown (suite a un rechargement) on essait de reresoudre ce dernier
if (Utils.GCATPP.VatGrowerLastPawnIsTX.ContainsKey(BUID) && Utils.GCATPP.VatGrowerLastPawnIsTX[BUID] && !Utils.GCATPP.VatGrowerLastPawnInProgress.ContainsKey(BUID))
if (Utils.GCATPP.VatGrowerLastPawnIsTX.TryGetValue(BUID, out bool vatGrowerLastPawnIsTX) && vatGrowerLastPawnIsTX && !Utils.GCATPP.VatGrowerLastPawnInProgress.ContainsKey(BUID))
{
Utils.GCATPP.VatGrowerLastPawnInProgress[BUID] = (Pawn)Traverse.Create(__instance).Field("pawnBeingGrown").GetValue();
}


//Si le GS chargé dans le VAT est un exosquelette d'androide TX alors pas de reduction
if (Utils.GCATPP.VatGrowerLastPawnInProgress.ContainsKey(BUID) && Utils.GCATPP.VatGrowerLastPawnInProgress[BUID] != null)
if (Utils.GCATPP.VatGrowerLastPawnInProgress.TryGetValue(BUID, out Pawn vatGrowerLastPawnInProgress) && vatGrowerLastPawnInProgress != null)
{
CompAndroidState cas = Utils.getCachedCAS(Utils.GCATPP.VatGrowerLastPawnInProgress[BUID]);
if (cas != null)
Expand Down
Loading