diff --git a/RevolutionaryGamesCommon b/RevolutionaryGamesCommon index ba0cdac34bd..bdeebb8e876 160000 --- a/RevolutionaryGamesCommon +++ b/RevolutionaryGamesCommon @@ -1 +1 @@ -Subproject commit ba0cdac34bdbef2702ec1b896adfb0bb5d5a2c84 +Subproject commit bdeebb8e876d3fcbf2019dff0513f36891bcee2e diff --git a/Thrive.csproj b/Thrive.csproj index 46a25d1bce6..1f793bfb206 100644 --- a/Thrive.csproj +++ b/Thrive.csproj @@ -103,8 +103,7 @@ - + diff --git a/Thrive.csproj.old.1 b/Thrive.csproj.old.1 new file mode 100644 index 00000000000..369db73deb8 --- /dev/null +++ b/Thrive.csproj.old.1 @@ -0,0 +1,119 @@ + + + + false + net10.0 + net9.0 + net8.0 + true + 14 + enable + Revolutionary Games Studio + 1.0.0.0 + + true + + + + + $(DefaultItemExcludes);Scripts\**\*;ThriveScriptsShared\**\*;test\code_tests\**\*;test\code_benchmarks\**\*;RevolutionaryGamesCommon\**\*;third_party\**\* + + + + + + $(DefaultItemExcludes);test/**/*;addons\gdUnit4\**\* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(MSBuildThisFileDirectory)RevolutionaryGamesCommon/StyleCop.ruleset + + + + + diff --git a/src/auto-evo/AutoEvoExploringTool.Export.cs b/src/auto-evo/AutoEvoExploringTool.Export.cs index 3ca5d075a57..3f107de9acb 100644 --- a/src/auto-evo/AutoEvoExploringTool.Export.cs +++ b/src/auto-evo/AutoEvoExploringTool.Export.cs @@ -100,11 +100,11 @@ private void ExportCurrentWorldSpeciesHistory(string basePath) microbeSpecies.BaseRotationSpeed.ToString(CultureInfo.InvariantCulture), microbeSpecies.StorageCapacities.Nominal.ToString(CultureInfo.InvariantCulture), microbeSpecies.IsBacteria.ToString(), - microbeSpecies.Organelles.Count.ToString(), + microbeSpecies.ReadonlyOrganelles.Count.ToString(), }); data.AddRange(allOrganelles - .Select(d => microbeSpecies.Organelles.Count(t => t.Definition == d).ToString())); + .Select(d => microbeSpecies.ReadonlyOrganelles.Count(t => t.Definition == d).ToString())); } else { diff --git a/src/auto-evo/AutoEvoExploringTool.cs b/src/auto-evo/AutoEvoExploringTool.cs index b06d8ee5f8a..3866be6a8d9 100644 --- a/src/auto-evo/AutoEvoExploringTool.cs +++ b/src/auto-evo/AutoEvoExploringTool.cs @@ -1169,8 +1169,8 @@ public void UpdateWorldStatistics() foreach (var organelle in SimulationParameters.Instance.GetAllOrganelles()) { MicrobeSpeciesOrganelleStatistics[organelle] = ( - microbeSpecies.Average(s => s.Organelles.Any(o => o.Definition == organelle) ? 1 : 0), - microbeSpecies.Average(s => s.Organelles.Count(o => o.Definition == organelle))); + microbeSpecies.Average(s => s.ReadonlyOrganelles.Any(o => o.Definition == organelle) ? 1 : 0), + microbeSpecies.Average(s => s.ReadonlyOrganelles.Count(o => o.Definition == organelle))); } foreach (var upgradeName in MicrobeSpeciesUpgradesStatistics.Keys) @@ -1178,9 +1178,11 @@ public void UpdateWorldStatistics() MicrobeSpeciesUpgradesStatistics[upgradeName] = ( MicrobeSpeciesUpgradesStatistics[upgradeName].Name, microbeSpecies.Average(s => - s.Organelles.Any(o => o.Upgrades?.UnlockedFeatures.Contains(upgradeName) ?? false) ? 1 : 0), + s.ReadonlyOrganelles.Any(o => o.Upgrades?.UnlockedFeatures.Contains(upgradeName) ?? false) ? + 1 : + 0), microbeSpecies.Average(s => - s.Organelles.Count(o => o.Upgrades?.UnlockedFeatures.Contains(upgradeName) ?? false))); + s.ReadonlyOrganelles.Count(o => o.Upgrades?.UnlockedFeatures.Contains(upgradeName) ?? false))); } foreach (var membrane in SimulationParameters.Instance.GetAllMembranes()) @@ -1192,11 +1194,11 @@ public void UpdateWorldStatistics() foreach (var enzyme in MicrobeSpeciesEnzymesStatistics.Keys) { MicrobeSpeciesEnzymesStatistics[enzyme] = ( - microbeSpecies.Average(s => s.Organelles.Any(o => + microbeSpecies.Average(s => s.ReadonlyOrganelles.Any(o => o.Definition.Enzymes.TryGetValue(enzyme, out var value) && value > 0) ? 1 : 0), - microbeSpecies.Average(s => s.Organelles.Count(o => + microbeSpecies.Average(s => s.ReadonlyOrganelles.Count(o => o.Definition.Enzymes.TryGetValue(enzyme, out var value) && value > 0))); } } diff --git a/src/auto-evo/mutation_strategy/AddOrganelleAnywhere.cs b/src/auto-evo/mutation_strategy/AddOrganelleAnywhere.cs index c5ec93d87eb..3371e3fe672 100644 --- a/src/auto-evo/mutation_strategy/AddOrganelleAnywhere.cs +++ b/src/auto-evo/mutation_strategy/AddOrganelleAnywhere.cs @@ -113,7 +113,7 @@ public static AddOrganelleAnywhere ThatConvertBetweenCompounds(Compound fromComp continue; // Don't add duplicate unique organelles - if (organelle.Unique && baseSpecies.Organelles.Select(x => x.Definition).Contains(organelle)) + if (organelle.Unique && baseSpecies.ModifiableOrganelles.Select(x => x.Definition).Contains(organelle)) continue; var newSpecies = (MicrobeSpecies)baseSpecies.Clone(); diff --git a/src/auto-evo/mutation_strategy/ModifyOrganelleBase.cs b/src/auto-evo/mutation_strategy/ModifyOrganelleBase.cs index eaa70372f88..f7ddb80f06f 100644 --- a/src/auto-evo/mutation_strategy/ModifyOrganelleBase.cs +++ b/src/auto-evo/mutation_strategy/ModifyOrganelleBase.cs @@ -42,7 +42,7 @@ public ModifyOrganelleBase(Func criteria, bool should List? organelleIndexesToMutate = null; // Manual looping to avoid one enumerator allocation per call - var organelleList = baseSpecies.Organelles.Organelles; + var organelleList = baseSpecies.ModifiableOrganelles.Organelles; var organelleCount = organelleList.Count; for (var i = 0; i < organelleCount; ++i) { @@ -98,14 +98,14 @@ public ModifyOrganelleBase(Func criteria, bool should // We did not change the position at all, so we can safely put down the organelle as upgrades // cannot affect the shape - newSpecies.Organelles.AddAutoEvoAttemptOrganelle(upgradedOrganelle); + newSpecies.ModifiableOrganelles.AddAutoEvoAttemptOrganelle(upgradedOrganelle); mutatedOrganelle = true; } else { // TODO: switch away from cloning again once ensured that auto-evo does not modify original // organelles - newSpecies.Organelles.AddAutoEvoAttemptOrganelle(organelleList[j].Clone()); + newSpecies.ModifiableOrganelles.AddAutoEvoAttemptOrganelle(organelleList[j].Clone()); // newSpecies.Organelles.AddAutoEvoAttemptOrganelle(organelleList[j]); } diff --git a/src/auto-evo/mutation_strategy/MoveOrganelleBack.cs b/src/auto-evo/mutation_strategy/MoveOrganelleBack.cs index 40cd4342563..ca66cb51cf2 100644 --- a/src/auto-evo/mutation_strategy/MoveOrganelleBack.cs +++ b/src/auto-evo/mutation_strategy/MoveOrganelleBack.cs @@ -28,11 +28,12 @@ public MoveOrganelleBack(Func criteria) var workMemory2 = new List(); var workMemory3 = new HashSet(); - foreach (OrganelleTemplate organelle in baseSpecies.Organelles.Where(x => allOrganelles.Contains(x.Definition))) + foreach (OrganelleTemplate organelle in baseSpecies.ModifiableOrganelles.Where(x => + allOrganelles.Contains(x.Definition))) { MicrobeSpecies newSpecies = (MicrobeSpecies)baseSpecies.Clone(); - newSpecies.Organelles.Remove(organelle); + newSpecies.ModifiableOrganelles.Remove(organelle); if (CommonMutationFunctions.AddOrganelle(organelle.Definition, CommonMutationFunctions.Direction.Rear, newSpecies, workMemory1, workMemory2, workMemory3, random)) diff --git a/src/auto-evo/mutation_strategy/RemoveOrganelle.cs b/src/auto-evo/mutation_strategy/RemoveOrganelle.cs index b36aef11d8c..0cd969742fb 100644 --- a/src/auto-evo/mutation_strategy/RemoveOrganelle.cs +++ b/src/auto-evo/mutation_strategy/RemoveOrganelle.cs @@ -52,7 +52,7 @@ public static RemoveOrganelle ThatCreateCompound(Compound compound) if (mp < Constants.ORGANELLE_REMOVE_COST) return null; - var organelles = baseSpecies.Organelles.Where(x => Criteria(x.Definition)) + var organelles = baseSpecies.ModifiableOrganelles.Where(x => Criteria(x.Definition)) .OrderBy(_ => random.Next()).Take(Constants.AUTO_EVO_ORGANELLE_REMOVE_ATTEMPTS); List>? mutated = null; @@ -73,8 +73,8 @@ public static RemoveOrganelle ThatCreateCompound(Compound compound) // Is this the best way to do this? Probably not, but this is how mutations.cs does is // and the other way outright did not work // This is now slightly improved - hhyyrylainen - var baseOrganelles = baseSpecies.Organelles.Organelles; - var count = baseSpecies.Organelles.Count; + var baseOrganelles = baseSpecies.ReadonlyOrganelles.Organelles; + var count = baseSpecies.ReadonlyOrganelles.Count; for (var i = 0; i < count; ++i) { @@ -85,10 +85,11 @@ public static RemoveOrganelle ThatCreateCompound(Compound compound) // Copy the organelle var newOrganelle = parentOrganelle.Clone(); - newSpecies.Organelles.AddIfPossible(newOrganelle, workMemory.WorkingMemory1, workMemory.WorkingMemory2); + newSpecies.ModifiableOrganelles.AddIfPossible(newOrganelle, workMemory.WorkingMemory1, + workMemory.WorkingMemory2); } - CommonMutationFunctions.AttachIslandHexes(newSpecies.Organelles, workMemory); + CommonMutationFunctions.AttachIslandHexes(newSpecies.ModifiableOrganelles, workMemory); mutated ??= new List>(); mutated.Add(Tuple.Create(newSpecies, mp - Constants.ORGANELLE_REMOVE_COST)); diff --git a/src/auto-evo/mutations/CommonMutationFunctions.cs b/src/auto-evo/mutations/CommonMutationFunctions.cs index 559d2990d49..49a3e9f6a5b 100644 --- a/src/auto-evo/mutations/CommonMutationFunctions.cs +++ b/src/auto-evo/mutations/CommonMutationFunctions.cs @@ -90,7 +90,7 @@ public static MicrobeSpecies GenerateRandomSpecies(MicrobeSpecies mutated, Patch MutationLogicFunctions.ColourNewMicrobeSpecies(random, mutated); } - mutated.ModifiableTolerances.CopyFrom(forPatch.GenerateTolerancesForMicrobe(mutated.Organelles)); + mutated.ModifiableTolerances.CopyFrom(forPatch.GenerateTolerancesForMicrobe(mutated.ReadonlyOrganelles)); // Override the default species starting name to have more variability in the names var nameGenerator = SimulationParameters.Instance.NameGenerator; @@ -119,17 +119,18 @@ public static bool AddOrganelleWithStrategy(OrganelleAddStrategy strategy, Organ switch (strategy) { case OrganelleAddStrategy.Realistic: - position = GetRealisticPosition(organelle, newSpecies.Organelles, direction, workMemory1, workMemory3, + position = GetRealisticPosition(organelle, newSpecies.ModifiableOrganelles, direction, workMemory1, + workMemory3, random); break; case OrganelleAddStrategy.Spiral: - position = GetSpiralPosition(organelle, newSpecies.Organelles, workMemory1, workMemory3); + position = GetSpiralPosition(organelle, newSpecies.ModifiableOrganelles, workMemory1, workMemory3); break; case OrganelleAddStrategy.Front: - position = GetFrontPosition(organelle, newSpecies.Organelles, workMemory1, workMemory3); + position = GetFrontPosition(organelle, newSpecies.ModifiableOrganelles, workMemory1, workMemory3); break; case OrganelleAddStrategy.Back: - position = GetBackPosition(organelle, newSpecies.Organelles, workMemory1, workMemory3); + position = GetBackPosition(organelle, newSpecies.ModifiableOrganelles, workMemory1, workMemory3); break; default: throw new ArgumentOutOfRangeException(nameof(strategy), strategy, null); @@ -139,7 +140,7 @@ public static bool AddOrganelleWithStrategy(OrganelleAddStrategy strategy, Organ if (position == null) return false; - newSpecies.Organelles.AddFast(position, workMemory1, workMemory2); + newSpecies.ModifiableOrganelles.AddFast(position, workMemory1, workMemory2); // If the new species is eukaryotic, mark this as such. if (organelle == Nucleus) diff --git a/src/auto-evo/mutations/MutationLogicFunctions.cs b/src/auto-evo/mutations/MutationLogicFunctions.cs index a651c6aecff..d99a6fdfba8 100644 --- a/src/auto-evo/mutations/MutationLogicFunctions.cs +++ b/src/auto-evo/mutations/MutationLogicFunctions.cs @@ -68,8 +68,8 @@ public static void ColourNewMicrobeSpecies(Random random, MicrobeSpecies newSpec private static bool MicrobeSpeciesIsNewGenus(MicrobeSpecies species1, MicrobeSpecies species2) { - var species1UniqueOrganelles = species1.Organelles.Select(o => o.Definition).ToHashSet(); - var species2UniqueOrganelles = species2.Organelles.Select(o => o.Definition).ToHashSet(); + var species1UniqueOrganelles = species1.ReadonlyOrganelles.Select(o => o.Definition).ToHashSet(); + var species2UniqueOrganelles = species2.ReadonlyOrganelles.Select(o => o.Definition).ToHashSet(); return species1UniqueOrganelles.Union(species2UniqueOrganelles).Count() - species1UniqueOrganelles.Intersect(species2UniqueOrganelles).Count() diff --git a/src/auto-evo/selection_pressure/CompoundConversionEfficiencyPressure.cs b/src/auto-evo/selection_pressure/CompoundConversionEfficiencyPressure.cs index 459cc92760c..af66aab4281 100644 --- a/src/auto-evo/selection_pressure/CompoundConversionEfficiencyPressure.cs +++ b/src/auto-evo/selection_pressure/CompoundConversionEfficiencyPressure.cs @@ -71,7 +71,7 @@ public override float Score(Species species, Patch patch, SimulationCache cache) // being in a colony no longer reduces osmoregulation cost. var bindingModifier = 1.0f; - MicrobeInternalCalculations.GetBindingAndSignalling(microbeSpecies.Organelles.Organelles, + MicrobeInternalCalculations.GetBindingAndSignalling(microbeSpecies.ReadonlyOrganelles.Organelles, out var hasBindingAgent, out var hasSignallingAgent); if (hasBindingAgent) diff --git a/src/auto-evo/selection_pressure/ReproductionCompoundPressure.cs b/src/auto-evo/selection_pressure/ReproductionCompoundPressure.cs index 8c5e1a7491a..20776c4c086 100644 --- a/src/auto-evo/selection_pressure/ReproductionCompoundPressure.cs +++ b/src/auto-evo/selection_pressure/ReproductionCompoundPressure.cs @@ -161,7 +161,7 @@ public override float Score(Species species, Patch patch, SimulationCache cache) // being in a colony no longer reduces osmoregulation cost. var bindingModifier = 1.0f; - MicrobeInternalCalculations.GetBindingAndSignalling(microbeSpecies.Organelles.Organelles, + MicrobeInternalCalculations.GetBindingAndSignalling(microbeSpecies.ReadonlyOrganelles.Organelles, out var hasBindingAgent, out var hasSignallingAgent); if (hasBindingAgent) diff --git a/src/auto-evo/simulation/SimulationCache.cs b/src/auto-evo/simulation/SimulationCache.cs index 6579e730725..7c36899fd2c 100644 --- a/src/auto-evo/simulation/SimulationCache.cs +++ b/src/auto-evo/simulation/SimulationCache.cs @@ -101,13 +101,13 @@ public EnergyBalanceInfoSimple GetEnergyBalanceForSpecies(MicrobeSpecies species return cached; } - var maximumMovementDirection = MicrobeInternalCalculations.MaximumSpeedDirection(species.Organelles); + var maximumMovementDirection = MicrobeInternalCalculations.MaximumSpeedDirection(species.ReadonlyOrganelles); // TODO: check if caching instances of these objects would be better than always recreating cached = new EnergyBalanceInfoSimple(); // Auto-evo uses the average values of compound during the course of a simulated day - ProcessSystem.ComputeEnergyBalanceSimple(species.Organelles, biomeConditions, + ProcessSystem.ComputeEnergyBalanceSimple(species.ReadonlyOrganelles, biomeConditions, GetEnvironmentalTolerances(species, biomeConditions), species.MembraneType, maximumMovementDirection, true, species.PlayerSpecies, worldSettings, CompoundAmountType.Average, this, cached); @@ -124,7 +124,7 @@ public float GetSpeedForSpecies(MicrobeSpecies species) return cached; } - cached = MicrobeInternalCalculations.CalculateSpeed(species.Organelles.Organelles, species.MembraneType, + cached = MicrobeInternalCalculations.CalculateSpeed(species.ReadonlyOrganelles.Organelles, species.MembraneType, species.MembraneRigidity, species.IsBacteria, true); cachedBaseSpeeds.Add(species, cached); @@ -151,7 +151,7 @@ public float GetRotationSpeedForSpecies(MicrobeSpecies species) return cached; } - cached = MicrobeInternalCalculations.CalculateRotationSpeed(species.Organelles.Organelles); + cached = MicrobeInternalCalculations.CalculateRotationSpeed(species.ReadonlyOrganelles.Organelles); cachedBaseRotationSpeeds.Add(species, cached); return cached; @@ -358,7 +358,7 @@ public float GetPredationScore(Species predatorSpecies, Species preySpecies, Bio var hasSignallingAgent = false; var hasBindingAgent = false; - var organelles = predator.Organelles.Organelles; + var organelles = predator.ReadonlyOrganelles.Organelles; int count = organelles.Count; for (int i = 0; i < count; ++i) { @@ -375,7 +375,7 @@ public float GetPredationScore(Species predatorSpecies, Species preySpecies, Bio // TODO: switch to a manual loop to avoid an allocation var preyOxygenUsingOrganellesCount = 0; - foreach (var organelle in prey.Organelles.Organelles) + foreach (var organelle in prey.ReadonlyOrganelles.Organelles) { if (organelle.Definition.IsOxygenMetabolism) preyOxygenUsingOrganellesCount += 1; @@ -626,7 +626,7 @@ public bool GetUsesVaryingCompoundsForSpecies(MicrobeSpecies species, BiomeCondi return cached; } - cached = MicrobeInternalCalculations.UsesDayVaryingCompounds(species.Organelles, biomeConditions, null); + cached = MicrobeInternalCalculations.UsesDayVaryingCompounds(species.ReadonlyOrganelles, biomeConditions, null); cachedUsesVaryingCompounds.Add(key, cached); return cached; @@ -644,7 +644,7 @@ public float GetChemoreceptorCloudScore(MicrobeSpecies species, CompoundDefiniti cached = 0.0f; var hasChemoreceptor = false; - foreach (var organelle in species.Organelles.Organelles) + foreach (var organelle in species.ReadonlyOrganelles.Organelles) { var organelleTargetCompound = organelle.GetActiveTargetCompound(); if (organelleTargetCompound == Compound.Invalid) @@ -682,7 +682,7 @@ public float GetChemoreceptorChunkScore(MicrobeSpecies species, ChunkConfigurati // Need to have chemoreceptor to be able to "smell" chunks cached = 0.0f; var hasChemoreceptor = false; - foreach (var organelle in species.Organelles.Organelles) + foreach (var organelle in species.ReadonlyOrganelles.Organelles) { var organelleTargetCompound = organelle.GetActiveTargetCompound(); if (organelleTargetCompound == Compound.Invalid) @@ -762,7 +762,7 @@ public List GetActiveProcessList(MicrobeSpecies microbeSpecies) return cached; } - ProcessSystem.ComputeActiveProcessList(microbeSpecies.Organelles, ref cached); + ProcessSystem.ComputeActiveProcessList(microbeSpecies.ModifiableOrganelles, ref cached); cachedProcessLists.Add(microbeSpecies, cached); return cached; @@ -788,7 +788,7 @@ public PredationToolsRawScores GetPredationToolsRawScores(MicrobeSpecies microbe var mucocystsScore = Constants.AUTO_EVO_MUCOCYST_SCORE; var pullingCiliaModifier = 1.0f; - var organelles = microbeSpecies.Organelles.Organelles; + var organelles = microbeSpecies.ModifiableOrganelles.Organelles; var organelleCount = organelles.Count; var totalToxinOrganellesCount = 0; var totalToxinTypesCount = 0; @@ -968,7 +968,7 @@ public float GetEnzymesScore(MicrobeSpecies predator, string dissolverEnzyme) if (cachedEnzymeScores.TryGetValue(key, out var cached)) return cached; - var organelles = predator.Organelles.Organelles; + var organelles = predator.ReadonlyOrganelles.Organelles; var isMembraneDigestible = dissolverEnzyme == Constants.LIPASE_ENZYME; var enzymesScore = 0.0f; @@ -1035,11 +1035,11 @@ private float CalculateStorageScore(MicrobeSpecies species, BiomeConditions biom float daySeconds = worldSettings.DayLength * worldSettings.DaytimeFraction; var cachedCapacities = - MicrobeInternalCalculations.GetTotalSpecificCapacity(species.Organelles, out var cachedCapacity); + MicrobeInternalCalculations.GetTotalSpecificCapacity(species.ReadonlyOrganelles, out var cachedCapacity); Dictionary? dayCompoundBalances = null; var (canSurvive, requiredAmounts) = MicrobeInternalCalculations.CalculateNightStorageRequirements( - species.Organelles, species.MembraneType, moving, species.PlayerSpecies, biomeConditions, + species.ReadonlyOrganelles, species.MembraneType, moving, species.PlayerSpecies, biomeConditions, GetEnvironmentalTolerances(species, biomeConditions), worldSettings, ref dayCompoundBalances); @@ -1047,7 +1047,7 @@ private float CalculateStorageScore(MicrobeSpecies species, BiomeConditions biom throw new Exception("Day compound balance should have been calculated"); var resultCompounds = - MicrobeInternalCalculations.GetCompoundsProducedByProcessesTakingIn(compound, species.Organelles); + MicrobeInternalCalculations.GetCompoundsProducedByProcessesTakingIn(compound, species.ReadonlyOrganelles); float cacheScore = 0; int scoreCount = 0; diff --git a/src/general/GameProperties.cs b/src/general/GameProperties.cs index dde14f1d95e..f0196162a95 100644 --- a/src/general/GameProperties.cs +++ b/src/general/GameProperties.cs @@ -178,10 +178,10 @@ public static GameProperties StartNewAwareStageGame(WorldGenerationSettings sett var template = new OrganelleTemplate(axon, new Hex(0, r), 0); // Add no longer allows replacing cytoplasm by default - if (!brainType.ModifiableOrganelles.CanPlaceAndIsTouching(template, false, workMemory1, workMemory2, false)) + if (!brainType.ReadonlyOrganelles.CanPlaceAndIsTouching(template, false, workMemory1, workMemory2, false)) continue; - brainType.ModifiableOrganelles.AddFast(template, workMemory1, workMemory2); + brainType.ReadonlyOrganelles.AddFast(template, workMemory1, workMemory2); brainType.RepositionToOrigin(); break; } @@ -416,33 +416,35 @@ private static MicrobeSpecies MakePlayerOrganellesMakeSenseForMulticellular(Game var workMemory1 = new List(); var workMemory2 = new List(); - playerSpecies.Organelles.AddFast(new OrganelleTemplate(simulationParameters.GetOrganelleType("nucleus"), + playerSpecies.ModifiableOrganelles.AddFast(new OrganelleTemplate( + simulationParameters.GetOrganelleType("nucleus"), new Hex(0, -3), 0), workMemory1, workMemory2); playerSpecies.IsBacteria = false; var mitochondrion = simulationParameters.GetOrganelleType("mitochondrion"); // Remove the original cytoplasm in the species and replace with hydrogenosome for a more efficient layout - playerSpecies.Organelles.RemoveHexAt(new Hex(0, 0), workMemory1); + playerSpecies.ModifiableOrganelles.RemoveHexAt(new Hex(0, 0), workMemory1); - playerSpecies.Organelles.AddFast(new OrganelleTemplate(simulationParameters.GetOrganelleType("bindingAgent"), + playerSpecies.ModifiableOrganelles.AddFast(new OrganelleTemplate( + simulationParameters.GetOrganelleType("bindingAgent"), new Hex(0, 2), 0), workMemory1, workMemory2); - playerSpecies.Organelles.AddFast(new OrganelleTemplate(mitochondrion, + playerSpecies.ModifiableOrganelles.AddFast(new OrganelleTemplate(mitochondrion, new Hex(-1, 2), 0), workMemory1, workMemory2); - playerSpecies.Organelles.AddFast(new OrganelleTemplate(mitochondrion, + playerSpecies.ModifiableOrganelles.AddFast(new OrganelleTemplate(mitochondrion, new Hex(1, 1), 0), workMemory1, workMemory2); - playerSpecies.Organelles.AddFast(new OrganelleTemplate(mitochondrion, + playerSpecies.ModifiableOrganelles.AddFast(new OrganelleTemplate(mitochondrion, new Hex(0, 1), 0), workMemory1, workMemory2); var cytoplasm = simulationParameters.GetOrganelleType("cytoplasm"); - playerSpecies.Organelles.AddFast(new OrganelleTemplate(cytoplasm, + playerSpecies.ModifiableOrganelles.AddFast(new OrganelleTemplate(cytoplasm, new Hex(1, -1), 0), workMemory1, workMemory2); - playerSpecies.Organelles.AddFast(new OrganelleTemplate(cytoplasm, + playerSpecies.ModifiableOrganelles.AddFast(new OrganelleTemplate(cytoplasm, new Hex(-1, 0), 0), workMemory1, workMemory2); playerSpecies.OnEdited(); diff --git a/src/general/GameWorld.cs b/src/general/GameWorld.cs index 272839ec2e9..4dbdec7f8df 100644 --- a/src/general/GameWorld.cs +++ b/src/general/GameWorld.cs @@ -153,12 +153,12 @@ public GameWorld(WorldGenerationSettings settings, Species? startingSpecies = nu if (PlayerSpecies is MicrobeSpecies microbeSpecies) { PlayerSpecies.ModifiableTolerances.CopyFrom( - patch.GenerateTolerancesForMicrobe(microbeSpecies.Organelles)); + patch.GenerateTolerancesForMicrobe(microbeSpecies.ReadonlyOrganelles)); } else if (PlayerSpecies is MulticellularSpecies multicellularSpecies) { PlayerSpecies.ModifiableTolerances.CopyFrom(patch.GenerateTolerancesForMicrobe(multicellularSpecies - .ModifiableGameplayCells[0].ModifiableOrganelles)); + .ModifiableGameplayCells[0].ReadonlyOrganelles)); } else { @@ -265,7 +265,8 @@ public static void SetInitialSpeciesProperties(MicrobeSpecies species, List species.MembraneType = SimulationParameters.Instance.GetMembrane("single"); - species.Organelles.AddFast(new OrganelleTemplate(SimulationParameters.Instance.GetOrganelleType("cytoplasm"), + species.ModifiableOrganelles.AddFast(new OrganelleTemplate( + SimulationParameters.Instance.GetOrganelleType("cytoplasm"), new Hex(0, 0), 0), workMemory1, workMemory2); species.OnEdited(); diff --git a/src/general/base_stage/CreatureStageBase.cs b/src/general/base_stage/CreatureStageBase.cs index 36bda8438b8..0350ccad763 100644 --- a/src/general/base_stage/CreatureStageBase.cs +++ b/src/general/base_stage/CreatureStageBase.cs @@ -579,7 +579,7 @@ private void CheckPerformanceEnoughForSimulationSpeed() private void AdjustTolerancesToWorkInPatch(MicrobeSpecies species, Patch currentPatch) { - var optimal = currentPatch.GenerateTolerancesForMicrobe(species.Organelles); + var optimal = currentPatch.GenerateTolerancesForMicrobe(species.ReadonlyOrganelles); var current = MicrobeEnvironmentalToleranceCalculations.CalculateTolerances(species, currentPatch.Biome); diff --git a/src/general/world_effects/MarineSnowDensityEffect.cs b/src/general/world_effects/MarineSnowDensityEffect.cs index 1e65107c86a..972164ceecf 100644 --- a/src/general/world_effects/MarineSnowDensityEffect.cs +++ b/src/general/world_effects/MarineSnowDensityEffect.cs @@ -137,7 +137,7 @@ private long GetPopulationFromPatch(Patch patch, long totalPopulation) // For now, only microbe species affect what organelles are available if (tuple.Key is MicrobeSpecies microbeSpecies) { - foreach (var organelle in microbeSpecies.Organelles) + foreach (var organelle in microbeSpecies.ReadonlyOrganelles) { availableOrganelles.Add(organelle.Definition); } diff --git a/src/macroscopic_stage/MacroscopicSpecies.cs b/src/macroscopic_stage/MacroscopicSpecies.cs index 41b8b6e3fb3..de69711cab5 100644 --- a/src/macroscopic_stage/MacroscopicSpecies.cs +++ b/src/macroscopic_stage/MacroscopicSpecies.cs @@ -46,7 +46,7 @@ public MacroscopicSpecies(uint id, string genus, string epithet) : base(id, genu /// public IEnumerable Organelles => ((MetaballLayout)ModifiableBodyLayout).Select(m => m.ModifiableCellType).Distinct() - .SelectMany(c => c.ModifiableOrganelles); + .SelectMany(c => c.ReadonlyOrganelles); public override ushort CurrentArchiveVersion => SERIALIZATION_VERSION; diff --git a/src/microbe_stage/CellHexesPhotoBuilder.cs b/src/microbe_stage/CellHexesPhotoBuilder.cs index e9be59ea0a9..31a8ab5018e 100644 --- a/src/microbe_stage/CellHexesPhotoBuilder.cs +++ b/src/microbe_stage/CellHexesPhotoBuilder.cs @@ -73,7 +73,7 @@ private void BuildHexStruct() // TODO: The code below is partly duplicate to CellEditorComponent and HexEditorComponentBase. // If that code is changed this needs changes too. - var organelleLayout = Species.Organelles.Organelles; + var organelleLayout = Species.ReadonlyOrganelles.Organelles; foreach (var organelle in organelleLayout) { var position = organelle.Position; @@ -114,7 +114,7 @@ private void CalculateRadius() float farthest = 0; - foreach (var organelle in species.Organelles) + foreach (var organelle in species.ReadonlyOrganelles) { var position = organelle.Position; foreach (var hex in organelle.RotatedHexes) diff --git a/src/microbe_stage/ICellDefinition.cs b/src/microbe_stage/ICellDefinition.cs index ec3eb92359b..eb0db58a7da 100644 --- a/src/microbe_stage/ICellDefinition.cs +++ b/src/microbe_stage/ICellDefinition.cs @@ -13,7 +13,7 @@ /// public interface ICellDefinition : IReadOnlyCellDefinition, ISimulationPhotographable { - public OrganelleLayout ModifiableOrganelles { get; } + public OrganelleLayout ReadonlyOrganelles { get; } public new MembraneType MembraneType { get; set; } public new float MembraneRigidity { get; set; } public new Color Colour { get; set; } diff --git a/src/microbe_stage/MicrobeEnvironmentalToleranceCalculations.cs b/src/microbe_stage/MicrobeEnvironmentalToleranceCalculations.cs index f479d1e0d21..49d4cff515b 100644 --- a/src/microbe_stage/MicrobeEnvironmentalToleranceCalculations.cs +++ b/src/microbe_stage/MicrobeEnvironmentalToleranceCalculations.cs @@ -27,7 +27,7 @@ public static double CalculateTotalToleranceScore(MicrobeSpecies species, BiomeC public static ToleranceResult CalculateTolerances(MicrobeSpecies species, BiomeConditions environment) { - return CalculateTolerances(species.Tolerances, species.Organelles, environment); + return CalculateTolerances(species.Tolerances, species.ReadonlyOrganelles, environment); } public static ToleranceResult CalculateTolerances(IReadOnlyEnvironmentalTolerances speciesTolerances, diff --git a/src/microbe_stage/MicrobeInternalCalculations.cs b/src/microbe_stage/MicrobeInternalCalculations.cs index f5fbbc257fa..aae4cd50196 100644 --- a/src/microbe_stage/MicrobeInternalCalculations.cs +++ b/src/microbe_stage/MicrobeInternalCalculations.cs @@ -696,7 +696,7 @@ public static HashSet GetCompoundsProducedByProcessesTakingIn(Compound public static void CalculatePossibleEndosymbiontsFromSpecies(MicrobeSpecies species, List<(OrganelleDefinition Organelle, int Cost)> result, bool lawk) { - var organelles = species.Organelles.Organelles; + var organelles = species.ReadonlyOrganelles.Organelles; int organelleCount = organelles.Count; for (int i = 0; i < organelleCount; ++i) diff --git a/src/microbe_stage/MicrobeSpecies.cs b/src/microbe_stage/MicrobeSpecies.cs index f133a3ac55e..dce38f5499b 100644 --- a/src/microbe_stage/MicrobeSpecies.cs +++ b/src/microbe_stage/MicrobeSpecies.cs @@ -8,7 +8,7 @@ /// /// Represents a microbial species with microbe stage specific species things. /// -public class MicrobeSpecies : Species, IReadOnlyMicrobeSpecies, ICellDefinition +public sealed class MicrobeSpecies : Species, IReadOnlyMicrobeSpecies, ICellDefinition { public const ushort SERIALIZATION_VERSION = 1; @@ -19,7 +19,7 @@ public class MicrobeSpecies : Species, IReadOnlyMicrobeSpecies, ICellDefinition public MicrobeSpecies(uint id, string genus, string epithet) : base(id, genus, epithet) { - Organelles = new OrganelleLayout(); + ModifiableOrganelles = new OrganelleLayout(); } /// @@ -36,9 +36,9 @@ public MicrobeSpecies(Species cloneOf, ICellDefinition withCellDefinition, List< { cloneOf.ClonePropertiesTo(this); - foreach (var organelle in withCellDefinition.ModifiableOrganelles) + foreach (var organelle in withCellDefinition.ReadonlyOrganelles) { - Organelles.AddFast(organelle, workMemory1, workMemory2); + ModifiableOrganelles.AddFast(organelle, workMemory1, workMemory2); } MembraneType = withCellDefinition.MembraneType; @@ -66,9 +66,9 @@ public MicrobeSpecies(Species cloneOf, ICellDefinition withCellDefinition, List< /// Do not change this once the object is in use as the readonly adapter will not have been updated. /// /// - public OrganelleLayout Organelles { get; private set; } + public OrganelleLayout ModifiableOrganelles { get; private set; } - public OrganelleLayout ModifiableOrganelles => Organelles; + public OrganelleLayout ReadonlyOrganelles => ModifiableOrganelles; public Color Colour { @@ -80,7 +80,8 @@ public Color Colour // Base refers here to the fact that these are the values when a cell is freshly spawned and has no // reproduction progress. public float BaseSpeed => - MicrobeInternalCalculations.CalculateSpeed(Organelles.Organelles, MembraneType, MembraneRigidity, IsBacteria); + MicrobeInternalCalculations.CalculateSpeed(ReadonlyOrganelles.Organelles, MembraneType, MembraneRigidity, + IsBacteria); public float BaseRotationSpeed { get; set; } @@ -97,7 +98,8 @@ public float BaseHexSize var raw = 0.0f; // Need to do the calculation this way to avoid extra memory allocations - var organelles = Organelles.Organelles; + // keeping it with modifiable since the above comment seems to reccomend it ~Psyke + var organelles = ModifiableOrganelles.Organelles; int count = organelles.Count; for (int i = 0; i < count; ++i) { @@ -118,7 +120,7 @@ public float BaseHexSize { get { - var specific = MicrobeInternalCalculations.GetTotalSpecificCapacity(Organelles, out var nominal); + var specific = MicrobeInternalCalculations.GetTotalSpecificCapacity(ReadonlyOrganelles, out var nominal); return (nominal, specific); } } @@ -142,7 +144,7 @@ public float BaseHexSize // here IReadOnlyOrganelleLayout IReadOnlyCellDefinition.Organelles => readonlyLayout ??= - new ReadonlyOrganelleLayoutAdapter(Organelles); + new ReadonlyOrganelleLayoutAdapter(ReadonlyOrganelles); public static bool StateHasStabilizedImpl(IWorldSimulation worldSimulation) { @@ -167,7 +169,7 @@ public static MicrobeSpecies ReadFromArchive(ISArchiveReader reader, ushort vers instance.IsBacteria = reader.ReadBool(); instance.MembraneType = reader.ReadObject(); instance.MembraneRigidity = reader.ReadFloat(); - instance.Organelles = reader.ReadObject>(); + instance.ModifiableOrganelles = reader.ReadObject>(); instance.BaseRotationSpeed = reader.ReadFloat(); return instance; @@ -181,7 +183,7 @@ public override void WriteToArchive(ISArchiveWriter writer) writer.WriteObject(MembraneType); writer.Write(MembraneRigidity); - writer.WriteObject(Organelles); + writer.WriteObject(ModifiableOrganelles); writer.Write(BaseRotationSpeed); } @@ -189,7 +191,7 @@ public void UpdateIsBacteria() { var nucleus = SimulationParameters.Instance.GetOrganelleType("nucleus"); IsBacteria = true; - var organelles = Organelles.Organelles; + var organelles = ReadonlyOrganelles.Organelles; var count = organelles.Count; for (int i = 0; i < count; ++i) @@ -212,10 +214,10 @@ public override void OnEdited() UpdateIsBacteria(); // Reset endosymbiont status so that they aren't free to move / delete in the next editor cycle - var count = Organelles.Organelles.Count; + var count = ReadonlyOrganelles.Organelles.Count; for (var i = 0; i < count; ++i) { - ModifiableOrganelles.Organelles[i].IsEndosymbiont = false; + ReadonlyOrganelles.Organelles[i].IsEndosymbiont = false; } cachedFillTimes.Clear(); @@ -223,7 +225,7 @@ public override void OnEdited() public override bool RepositionToOrigin() { - var changes = Organelles.RepositionToOrigin(); + var changes = ModifiableOrganelles.RepositionToOrigin(); CalculateRotationSpeed(); return changes; } @@ -251,10 +253,11 @@ public override void UpdateInitialCompounds() }; // False is passed here until we can make the initial compounds patch specific - ProcessSystem.ComputeCompoundBalance(Organelles, biomeConditions, environmentalTolerances, + ProcessSystem.ComputeCompoundBalance(ReadonlyOrganelles, biomeConditions, environmentalTolerances, CompoundAmountType.Biome, false, compoundBalances); - bool giveBonusGlucose = Organelles.Count <= Constants.FULL_INITIAL_GLUCOSE_SMALL_SIZE_LIMIT && IsBacteria; + bool giveBonusGlucose = + ReadonlyOrganelles.Count <= Constants.FULL_INITIAL_GLUCOSE_SMALL_SIZE_LIMIT && IsBacteria; var cachedCapacities = StorageCapacities; @@ -314,7 +317,7 @@ public override void HandleNightSpawnCompounds(CompoundBag targetStorage, ISpawn if (!cachedFillTimes.TryGetValue(biome, out compoundTimes)) { // TODO: should moving be false in some cases? - compoundTimes = MicrobeInternalCalculations.CalculateDayVaryingCompoundsFillTimes(Organelles, + compoundTimes = MicrobeInternalCalculations.CalculateDayVaryingCompoundsFillTimes(ReadonlyOrganelles, MembraneType, true, PlayerSpecies, biome, resolvedTolerances, spawnEnvironment.WorldSettings); cachedFillTimes[biome] = compoundTimes; } @@ -330,14 +333,14 @@ public override void ApplyMutation(Species mutation) var casted = (MicrobeSpecies)mutation; - Organelles.Clear(); + ModifiableOrganelles.Clear(); var workMemory1 = new List(); var workMemory2 = new List(); - foreach (var organelle in casted.Organelles) + foreach (var organelle in casted.ModifiableOrganelles) { - Organelles.AddFast(organelle.Clone(), workMemory1, workMemory2); + ModifiableOrganelles.AddFast(organelle.Clone(), workMemory1, workMemory2); } IsBacteria = casted.IsBacteria; @@ -349,7 +352,7 @@ public override void ApplyMutation(Species mutation) public override float GetPredationTargetSizeFactor() { - return Organelles.Count; + return ReadonlyOrganelles.Count; } public Vector3 CalculatePhotographDistance(IWorldSimulation worldSimulation) @@ -384,7 +387,7 @@ public MicrobeSpecies Clone(bool cloneOrganelles) if (cloneOrganelles) { - result.Organelles = Organelles.Clone(); + result.ModifiableOrganelles = ModifiableOrganelles.Clone(); } return result; @@ -395,14 +398,14 @@ public override ulong GetVisualHashCode() var hash = base.GetVisualHashCode(); // This code also exists in CellType visual calculation - var count = Organelles.Count; + var count = ReadonlyOrganelles.Count; hash ^= PersistentStringHash.GetHash(MembraneType.InternalName) * 5743; hash ^= (ulong)MembraneRigidity.GetHashCode() * 5749; hash ^= (IsBacteria ? 1UL : 0UL) * 5779UL; hash ^= (ulong)count * 131; - var list = Organelles.Organelles; + var list = ReadonlyOrganelles.Organelles; for (int i = 0; i < count; ++i) { @@ -437,11 +440,11 @@ protected override Dictionary CalculateTotalReproductionCost() { var result = base.CalculateTotalReproductionCost(); - int organelleCount = Organelles.Organelles.Count; + int organelleCount = ReadonlyOrganelles.Organelles.Count; for (int i = 0; i < organelleCount; ++i) { - result.Merge(Organelles.Organelles[i].Definition.InitialComposition); + result.Merge(ModifiableOrganelles.Organelles[i].Definition.InitialComposition); } return result; @@ -449,6 +452,6 @@ protected override Dictionary CalculateTotalReproductionCost() private void CalculateRotationSpeed() { - BaseRotationSpeed = MicrobeInternalCalculations.CalculateRotationSpeed(Organelles.Organelles); + BaseRotationSpeed = MicrobeInternalCalculations.CalculateRotationSpeed(ModifiableOrganelles.Organelles); } } diff --git a/src/microbe_stage/MicrobeStage.cs b/src/microbe_stage/MicrobeStage.cs index 723d5ea6e75..6fbb2c8643f 100644 --- a/src/microbe_stage/MicrobeStage.cs +++ b/src/microbe_stage/MicrobeStage.cs @@ -913,7 +913,7 @@ public override void OnReturnFromEditor() species.Species, species.Species, WorldSimulation, workData1, workData2); - foreach (var organelle in species.Species.Organelles) + foreach (var organelle in species.Species.ReadonlyOrganelles) { if (organelle.Definition.HasHeatCollection) { diff --git a/src/microbe_stage/PatchManager.cs b/src/microbe_stage/PatchManager.cs index f0583943cb3..75b3a49e8b3 100644 --- a/src/microbe_stage/PatchManager.cs +++ b/src/microbe_stage/PatchManager.cs @@ -254,7 +254,7 @@ private void HandleCellSpawns(Patch patch, IMicrobeSpawnEnvironment spawnEnviron if (entry.Key is MicrobeSpecies microbeSpecies) { - hasBinding = microbeSpecies.Organelles.Any(o => o.Definition.HasBindingFeature); + hasBinding = microbeSpecies.ReadonlyOrganelles.Any(o => o.Definition.HasBindingFeature); } if (hasBinding) diff --git a/src/microbe_stage/components/OrganelleContainer.cs b/src/microbe_stage/components/OrganelleContainer.cs index 73f5d189d19..00ebbf2f093 100644 --- a/src/microbe_stage/components/OrganelleContainer.cs +++ b/src/microbe_stage/components/OrganelleContainer.cs @@ -325,7 +325,7 @@ public static void CreateOrganelleLayout(this ref OrganelleContainer container, container.Organelles ??= new OrganelleLayout(); - foreach (var organelleTemplate in cellDefinition.ModifiableOrganelles) + foreach (var organelleTemplate in cellDefinition.ReadonlyOrganelles) { container.Organelles.AddFast(new PlacedOrganelle(organelleTemplate.Definition, organelleTemplate.Position, diff --git a/src/microbe_stage/editor/CellEditorComponent.cs b/src/microbe_stage/editor/CellEditorComponent.cs index 491c2eb869a..1104ecefc1f 100644 --- a/src/microbe_stage/editor/CellEditorComponent.cs +++ b/src/microbe_stage/editor/CellEditorComponent.cs @@ -980,7 +980,7 @@ public override void OnEditorSpeciesSetup(Species species) } // Get the species organelles to be edited. This also updates the placeholder hexes - foreach (var organelle in properties.ModifiableOrganelles.Organelles) + foreach (var organelle in properties.ReadonlyOrganelles.Organelles) { editedMicrobeOrganelles.AddFast(organelle.Clone(), hexTemporaryMemory, hexTemporaryMemory2); } @@ -989,7 +989,7 @@ public override void OnEditorSpeciesSetup(Species species) // This needs to be calculated here, otherwise ATP-related unlock conditions would // get null as the ATP balance - CalculateEnergyAndCompoundBalance(properties.ModifiableOrganelles.Organelles, properties.MembraneType, + CalculateEnergyAndCompoundBalance(properties.ReadonlyOrganelles.Organelles, properties.MembraneType, Editor.CurrentPatch.Biome); UpdateOrganelleUnlockTooltips(true); @@ -1027,13 +1027,13 @@ public void OnFinishEditing(bool shouldUpdatePosition) // Apply changes to the species organelles // It is easiest to just replace all // Note that if this code is changed, then also CellType.CopyFrom needs changes - editedProperties.ModifiableOrganelles.Clear(); + editedProperties.ReadonlyOrganelles.Clear(); // Even in a multicellular context, it should always be safe to apply the organelle growth order foreach (var organelle in growthOrderGUI.ApplyOrderingToItems(editedMicrobeOrganelles.Organelles)) { var organelleToAdd = organelle.Clone(); - editedProperties.ModifiableOrganelles.AddFast(organelleToAdd, hexTemporaryMemory, hexTemporaryMemory2); + editedProperties.ReadonlyOrganelles.AddFast(organelleToAdd, hexTemporaryMemory, hexTemporaryMemory2); } if (shouldUpdatePosition) @@ -2832,7 +2832,7 @@ private void CopyEditedPropertiesToSpecies(MicrobeSpecies target) target.MembraneRigidity = Rigidity; target.IsBacteria = true; - target.Organelles.Clear(); + target.ModifiableOrganelles.Clear(); // TODO: if this is too slow to copy each organelle like this, we'll need to find a faster way to get the data // in, perhaps by sharing the entire Organelles object @@ -2841,7 +2841,7 @@ private void CopyEditedPropertiesToSpecies(MicrobeSpecies target) if (entry.Definition == nucleus) target.IsBacteria = false; - target.Organelles.AddFast(entry, hexTemporaryMemory, hexTemporaryMemory2); + target.ModifiableOrganelles.AddFast(entry, hexTemporaryMemory, hexTemporaryMemory2); } // Copy behaviour if it is known @@ -3459,11 +3459,11 @@ private void CopyPristineToCalculation() if (pristineSpeciesCopy.PlayerSpecies) calculationSpecies.BecomePlayerSpecies(); - calculationSpecies.Organelles.Clear(); + calculationSpecies.ModifiableOrganelles.Clear(); - foreach (var entry in pristineSpeciesCopy.Organelles) + foreach (var entry in pristineSpeciesCopy.ReadonlyOrganelles) { - calculationSpecies.Organelles.AddFast(entry, workMemory1, workMemory2); + calculationSpecies.ModifiableOrganelles.AddFast(entry, workMemory1, workMemory2); } // The pristine copy is not modified, so it is safe to not clone here diff --git a/src/microbe_stage/editor/PatchMapDrawer.cs b/src/microbe_stage/editor/PatchMapDrawer.cs index e700e4514cf..aa8400d7407 100644 --- a/src/microbe_stage/editor/PatchMapDrawer.cs +++ b/src/microbe_stage/editor/PatchMapDrawer.cs @@ -1121,7 +1121,7 @@ private void AddPatchNode(Patch patch, Vector2 position) if (playerSpecies is MicrobeSpecies microbeSpecies) { - speciesSizeModifier = Math.Sqrt(microbeSpecies.Organelles.Organelles.Count); + speciesSizeModifier = Math.Sqrt(microbeSpecies.ReadonlyOrganelles.Organelles.Count); } else if (playerSpecies is MulticellularSpecies) { diff --git a/src/microbe_stage/organelle_unlocks/WorldBasedUnlockCondition.cs b/src/microbe_stage/organelle_unlocks/WorldBasedUnlockCondition.cs index b6c7f9e484a..f9306e4514a 100644 --- a/src/microbe_stage/organelle_unlocks/WorldBasedUnlockCondition.cs +++ b/src/microbe_stage/organelle_unlocks/WorldBasedUnlockCondition.cs @@ -105,7 +105,7 @@ public override void GenerateTooltip(LocalizedStringBuilder builder, IUnlockStat private float GetPlayerSpeed(ICellDefinition playerData) { - var rawSpeed = MicrobeInternalCalculations.CalculateSpeed(playerData.ModifiableOrganelles.Organelles, + var rawSpeed = MicrobeInternalCalculations.CalculateSpeed(playerData.ReadonlyOrganelles.Organelles, playerData.MembraneType, playerData.MembraneRigidity, playerData.IsBacteria); // This needs to be user-readable as it is shown by the tooltip diff --git a/src/microbe_stage/systems/MicrobeAISystem.cs b/src/microbe_stage/systems/MicrobeAISystem.cs index 2b395de7a94..de279b7e053 100644 --- a/src/microbe_stage/systems/MicrobeAISystem.cs +++ b/src/microbe_stage/systems/MicrobeAISystem.cs @@ -1417,7 +1417,8 @@ private bool GetIsSpeciesUsingVaryingCompounds(Species species) if (species is MicrobeSpecies microbeSpecies) { // TODO: thread local storage for this cache - result = MicrobeInternalCalculations.UsesDayVaryingCompounds(microbeSpecies.Organelles, patch.Biome, + result = MicrobeInternalCalculations.UsesDayVaryingCompounds(microbeSpecies.ModifiableOrganelles, + patch.Biome, varyingCompoundsTemporary); } else if (species is MulticellularSpecies multicellularSpecies) @@ -1426,7 +1427,7 @@ private bool GetIsSpeciesUsingVaryingCompounds(Species species) // accurate. // TODO: thread local storage for this cache result = MicrobeInternalCalculations.UsesDayVaryingCompounds( - multicellularSpecies.ModifiableGameplayCells[0].ModifiableOrganelles, patch.Biome, + multicellularSpecies.ModifiableGameplayCells[0].ReadonlyOrganelles, patch.Biome, varyingCompoundsTemporary); } else diff --git a/src/microbe_stage/systems/ProcessSystem.cs b/src/microbe_stage/systems/ProcessSystem.cs index a540a1cc7df..6c1c2f38b17 100644 --- a/src/microbe_stage/systems/ProcessSystem.cs +++ b/src/microbe_stage/systems/ProcessSystem.cs @@ -709,9 +709,10 @@ public static float CalculateSpeciesActiveProcessListForEffect(Species species, return 0; var balance = new EnergyBalanceInfoSimple(); - var maximumMovementDirection = MicrobeInternalCalculations.MaximumSpeedDirection(microbeSpecies.Organelles); + var maximumMovementDirection = + MicrobeInternalCalculations.MaximumSpeedDirection(microbeSpecies.ReadonlyOrganelles); - ComputeEnergyBalanceSimple(microbeSpecies.Organelles, conditions, environmentTolerances, + ComputeEnergyBalanceSimple(microbeSpecies.ReadonlyOrganelles, conditions, environmentTolerances, microbeSpecies.MembraneType, maximumMovementDirection, false, false, worldGenerationSettings, CompoundAmountType.Average, cache, balance); @@ -726,7 +727,7 @@ public static float CalculateSpeciesActiveProcessListForEffect(Species species, // called time would be wasted on trying to match up processes between different species which is unlikely to // work) processesResult.Clear(); - ComputeActiveProcessList(microbeSpecies.Organelles, ref processesResult); + ComputeActiveProcessList(microbeSpecies.ReadonlyOrganelles, ref processesResult); return balanceModifier; } diff --git a/src/multicellular_stage/CellBodyPlanInternalCalculations.cs b/src/multicellular_stage/CellBodyPlanInternalCalculations.cs index 6492401d0d2..f9b985685fb 100644 --- a/src/multicellular_stage/CellBodyPlanInternalCalculations.cs +++ b/src/multicellular_stage/CellBodyPlanInternalCalculations.cs @@ -15,10 +15,10 @@ public static Dictionary GetTotalSpecificCapacity(IEnumerable> cell { var leader = cells[0].Data!; - var speed = MicrobeInternalCalculations.CalculateSpeed(leader.ModifiableOrganelles, leader.MembraneType, + var speed = MicrobeInternalCalculations.CalculateSpeed(leader.ReadonlyOrganelles, leader.MembraneType, leader.MembraneRigidity, leader.IsBacteria); if (cells.Count == 1) @@ -124,7 +124,7 @@ public static float CalculateRotationSpeed(IReadOnlyList result) { result.Clear(); - var organellesInternal = hex.ModifiableOrganelles.Organelles; + var organellesInternal = hex.ReadonlyOrganelles.Organelles; int organelleCount = organellesInternal.Count; for (int i = 0; i < organelleCount; ++i) diff --git a/src/multicellular_stage/CellTemplate.cs b/src/multicellular_stage/CellTemplate.cs index ae687019d64..777535d96eb 100644 --- a/src/multicellular_stage/CellTemplate.cs +++ b/src/multicellular_stage/CellTemplate.cs @@ -72,7 +72,7 @@ public float BaseRotationSpeed public string FormattedName => ModifiableCellType.CellTypeName; public IReadOnlyOrganelleLayout Organelles => ModifiableCellType.Organelles; - public OrganelleLayout ModifiableOrganelles => ModifiableCellType.ModifiableOrganelles; + public OrganelleLayout ReadonlyOrganelles => ModifiableCellType.ReadonlyOrganelles; public ISimulationPhotographable.SimulationType SimulationToPhotograph => ISimulationPhotographable.SimulationType.MicrobeGraphics; diff --git a/src/multicellular_stage/CellType.cs b/src/multicellular_stage/CellType.cs index 6247ad447e2..cf6b9a13c57 100644 --- a/src/multicellular_stage/CellType.cs +++ b/src/multicellular_stage/CellType.cs @@ -14,7 +14,7 @@ public class CellType : ICellDefinition, IReadOnlyCellTypeDefinition, ICloneable public CellType(OrganelleLayout organelles, MembraneType membraneType) { - ModifiableOrganelles = organelles; + ReadonlyOrganelles = organelles; MembraneType = membraneType; CanEngulf = membraneType.CanEngulf; } @@ -22,7 +22,7 @@ public CellType(OrganelleLayout organelles, MembraneType memb public CellType(MembraneType membraneType) { MembraneType = membraneType; - ModifiableOrganelles = new OrganelleLayout(); + ReadonlyOrganelles = new OrganelleLayout(); CanEngulf = membraneType.CanEngulf; } @@ -35,9 +35,9 @@ public CellType(MembraneType membraneType) public CellType(MicrobeSpecies microbeSpecies, List workMemory1, List workMemory2) : this(microbeSpecies.MembraneType) { - foreach (var organelle in microbeSpecies.Organelles) + foreach (var organelle in microbeSpecies.ReadonlyOrganelles) { - ModifiableOrganelles.AddFast(organelle.Clone(), workMemory1, workMemory2); + ReadonlyOrganelles.AddFast(organelle.Clone(), workMemory1, workMemory2); } MembraneRigidity = microbeSpecies.MembraneRigidity; @@ -49,9 +49,9 @@ public CellType(MicrobeSpecies microbeSpecies, List workMemory1, List // TODO: avoid this adapter object allocation public IReadOnlyOrganelleLayout Organelles => readonlyLayout ??= - new ReadonlyOrganelleLayoutAdapter(ModifiableOrganelles); + new ReadonlyOrganelleLayoutAdapter(ReadonlyOrganelles); - public OrganelleLayout ModifiableOrganelles { get; } + public OrganelleLayout ReadonlyOrganelles { get; } public string CellTypeName { get; set; } = "error"; public int MPCost { get; set; } = 15; @@ -98,7 +98,7 @@ public static CellType ReadFromArchive(ISArchiveReader reader, ushort version, i public void WriteToArchive(ISArchiveWriter writer) { - writer.WriteObject(ModifiableOrganelles); + writer.WriteObject(ReadonlyOrganelles); writer.WriteObject(MembraneType); writer.Write(CellTypeName); @@ -111,7 +111,7 @@ public void WriteToArchive(ISArchiveWriter writer) public bool RepositionToOrigin() { - var changes = ModifiableOrganelles.RepositionToOrigin(); + var changes = ReadonlyOrganelles.RepositionToOrigin(); CalculateRotationSpeed(); return changes; } @@ -183,13 +183,13 @@ public void CopyFrom(CellType otherType, List hexTemporaryMemory, List bool shouldUpdatePosition = false) { // Code very similar to what CellEditorComponent does on applying changes - ModifiableOrganelles.Clear(); + ReadonlyOrganelles.Clear(); // Even in a multicellular context, it should always be safe to apply the organelle growth order - foreach (var organelle in otherType.ModifiableOrganelles) + foreach (var organelle in otherType.ReadonlyOrganelles) { var organelleToAdd = organelle.Clone(); - ModifiableOrganelles.AddFast(organelleToAdd, hexTemporaryMemory, hexTemporaryMemory2); + ReadonlyOrganelles.AddFast(organelleToAdd, hexTemporaryMemory, hexTemporaryMemory2); } if (shouldUpdatePosition) @@ -222,7 +222,7 @@ public object Clone() foreach (var organelle in Organelles) { - result.ModifiableOrganelles.AddFast(organelle.Clone(), workMemory1, workMemory2); + result.ReadonlyOrganelles.AddFast(organelle.Clone(), workMemory1, workMemory2); } return result; @@ -242,7 +242,7 @@ public ulong GetVisualHashCode() // is applied by MicrobeSpecies' base class. hash ^= Colour.GetVisualHashCode(); - var list = ModifiableOrganelles.Organelles; + var list = ReadonlyOrganelles.Organelles; for (int i = 0; i < count; ++i) { @@ -264,7 +264,7 @@ public override int GetHashCode() int hash = CellTypeName.GetHashCode() ^ MembraneType.InternalName.GetHashCode() * 5743 ^ MembraneRigidity.GetHashCode() * 5749 ^ (IsBacteria ? 1 : 0) * 5779 ^ count * 131; - var list = ModifiableOrganelles.Organelles; + var list = ReadonlyOrganelles.Organelles; for (int i = 0; i < count; ++i) { @@ -282,6 +282,6 @@ public override string ToString() private void CalculateRotationSpeed() { // TODO: switch this to use a read only interface - BaseRotationSpeed = MicrobeInternalCalculations.CalculateRotationSpeed(ModifiableOrganelles.Organelles); + BaseRotationSpeed = MicrobeInternalCalculations.CalculateRotationSpeed(ReadonlyOrganelles.Organelles); } } diff --git a/src/multicellular_stage/MulticellularSpecies.cs b/src/multicellular_stage/MulticellularSpecies.cs index 17c7e780fdb..cf6a36d53ca 100644 --- a/src/multicellular_stage/MulticellularSpecies.cs +++ b/src/multicellular_stage/MulticellularSpecies.cs @@ -149,10 +149,10 @@ public override void OnEdited() } // Reset endosymbiont status so that they aren't free to move / delete in the next editor cycle - var count = cellType.ModifiableOrganelles.Count; + var count = cellType.ReadonlyOrganelles.Count; for (var i = 0; i < count; ++i) { - cellType.ModifiableOrganelles.Organelles[i].IsEndosymbiont = false; + cellType.ReadonlyOrganelles.Organelles[i].IsEndosymbiont = false; } } @@ -214,10 +214,10 @@ public override void UpdateInitialCompounds() ProcessSpeedModifier = 1, }; - ProcessSystem.ComputeCompoundBalance(ModifiableGameplayCells[0].ModifiableOrganelles, + ProcessSystem.ComputeCompoundBalance(ModifiableGameplayCells[0].ReadonlyOrganelles, biomeConditions, environmentalTolerances, CompoundAmountType.Biome, false, compoundBalances); var storageCapacity = - MicrobeInternalCalculations.CalculateCapacity(ModifiableGameplayCells[0].ModifiableOrganelles); + MicrobeInternalCalculations.CalculateCapacity(ModifiableGameplayCells[0].ReadonlyOrganelles); InitialCompounds.Clear(); @@ -261,7 +261,7 @@ public override void HandleNightSpawnCompounds(CompoundBag targetStorage, ISpawn // TODO: CACHING IS MISSING from here (but microbe has it) // TODO: should moving be false in some cases? var compoundTimes = MicrobeInternalCalculations.CalculateDayVaryingCompoundsFillTimes( - cellType.ModifiableOrganelles, cellType.MembraneType, true, PlayerSpecies, + cellType.ReadonlyOrganelles, cellType.MembraneType, true, PlayerSpecies, microbeSpawnEnvironment.CurrentBiome, environmentalTolerances, microbeSpawnEnvironment.WorldSettings); diff --git a/src/multicellular_stage/editor/CellBodyPlanEditorComponent.GUI.cs b/src/multicellular_stage/editor/CellBodyPlanEditorComponent.GUI.cs index 9bf6f4eb479..9c4050caacf 100644 --- a/src/multicellular_stage/editor/CellBodyPlanEditorComponent.GUI.cs +++ b/src/multicellular_stage/editor/CellBodyPlanEditorComponent.GUI.cs @@ -49,7 +49,7 @@ private void HandleProcessList(EnergyBalanceInfoFull energyBalance, IBiomeCondit { newProcesses.Clear(); - ProcessSystem.ComputeActiveProcessList(cellType.Key.ModifiableOrganelles, ref newProcesses); + ProcessSystem.ComputeActiveProcessList(cellType.Key.ReadonlyOrganelles, ref newProcesses); for (int i = 0; i < newProcesses.Count; ++i) { diff --git a/src/multicellular_stage/editor/CellBodyPlanEditorComponent.cs b/src/multicellular_stage/editor/CellBodyPlanEditorComponent.cs index cb1f6c33bfb..5bfc1751621 100644 --- a/src/multicellular_stage/editor/CellBodyPlanEditorComponent.cs +++ b/src/multicellular_stage/editor/CellBodyPlanEditorComponent.cs @@ -1099,15 +1099,15 @@ private void UpdateCellTypeTooltipAndWarning(CellTypeTooltip tooltip, CellTypeSe bool moving = organismStatisticsPanel.CalculateBalancesWhenMoving; var maximumMovementDirection = - MicrobeInternalCalculations.MaximumSpeedDirection(cellType.ModifiableOrganelles); + MicrobeInternalCalculations.MaximumSpeedDirection(cellType.ReadonlyOrganelles); - ProcessSystem.ComputeEnergyBalanceFull(cellType.ModifiableOrganelles, Editor.CurrentPatch.Biome, + ProcessSystem.ComputeEnergyBalanceFull(cellType.ReadonlyOrganelles, Editor.CurrentPatch.Biome, environmentalTolerances, cellType.MembraneType, maximumMovementDirection, moving, true, Editor.CurrentGame.GameWorld.WorldSettings, organismStatisticsPanel.CompoundAmountType, null, energyBalance); - AddCellTypeCompoundBalance(balances, cellType.ModifiableOrganelles, organismStatisticsPanel.BalanceDisplayType, + AddCellTypeCompoundBalance(balances, cellType.ReadonlyOrganelles, organismStatisticsPanel.BalanceDisplayType, organismStatisticsPanel.CompoundAmountType, Editor.CurrentPatch.Biome, energyBalance, environmentalTolerances); @@ -1120,17 +1120,17 @@ private void UpdateCellTypeTooltipAndWarning(CellTypeTooltip tooltip, CellTypeSe cellType.MembraneType, cellType.MembraneRigidity)); tooltip.UpdateStorageIndicator( - MicrobeInternalCalculations.GetTotalNominalCapacity(cellType.ModifiableOrganelles)); + MicrobeInternalCalculations.GetTotalNominalCapacity(cellType.ReadonlyOrganelles)); - tooltip.UpdateSpeedIndicator(MicrobeInternalCalculations.CalculateSpeed(cellType.ModifiableOrganelles, + tooltip.UpdateSpeedIndicator(MicrobeInternalCalculations.CalculateSpeed(cellType.ReadonlyOrganelles, cellType.MembraneType, cellType.MembraneRigidity, cellType.IsBacteria, false)); tooltip.UpdateRotationSpeedIndicator( - MicrobeInternalCalculations.CalculateRotationSpeed(cellType.ModifiableOrganelles)); + MicrobeInternalCalculations.CalculateRotationSpeed(cellType.ReadonlyOrganelles)); tooltip.UpdateSizeIndicator(cellType.Organelles.Sum(o => o.Definition.HexCount)); tooltip.UpdateDigestionSpeedIndicator( - MicrobeInternalCalculations.CalculateTotalDigestionSpeed(cellType.ModifiableOrganelles)); + MicrobeInternalCalculations.CalculateTotalDigestionSpeed(cellType.ReadonlyOrganelles)); button.ShowInsufficientATPWarning = energyBalance.TotalProduction < energyBalance.TotalConsumption; @@ -1261,7 +1261,7 @@ private void CalculateEnergyAndCompoundBalance(IReadOnlyList CalculateCompoundBalanceWithMethod foreach (var cell in cells) { AddCellTypeCompoundBalance(compoundBalanceData, - GetEditedCellDataIfEdited(cell.Data!.ModifiableCellType).ModifiableOrganelles, calculationType, + GetEditedCellDataIfEdited(cell.Data!.ModifiableCellType).ReadonlyOrganelles, calculationType, amountType, biome, energyBalance, environmentalTolerances); } diff --git a/test/MetaballTest.cs b/test/MetaballTest.cs index 409862d4c25..86607f6fd27 100644 --- a/test/MetaballTest.cs +++ b/test/MetaballTest.cs @@ -113,7 +113,7 @@ private CellType CreateDummyCellType(Color colour) return new CellType(simulationParameters.GetMembrane("single")) { Colour = colour, - ModifiableOrganelles = + ReadonlyOrganelles = { new OrganelleTemplate(simulationParameters.GetOrganelleType("cytoplasm"), new Hex(0, 0), 0) }, }; } diff --git a/test/PhysicsTest.cs b/test/PhysicsTest.cs index 493b28534b3..fbf1b793bcf 100644 --- a/test/PhysicsTest.cs +++ b/test/PhysicsTest.cs @@ -596,7 +596,7 @@ private void SetupMicrobeTest() random); testMicrobeOrganellePositions = - microbeSpecies.Organelles.Select(o => new JVecF3(Hex.AxialToCartesian(o.Position))).ToArray(); + microbeSpecies.ModifiableOrganelles.Select(o => new JVecF3(Hex.AxialToCartesian(o.Position))).ToArray(); int created = 0; diff --git a/test/code_tests/MicrobeStage.Tests/EditorMPTests.cs b/test/code_tests/MicrobeStage.Tests/EditorMPTests.cs index e07f5064e62..a5fbd3c8219 100644 --- a/test/code_tests/MicrobeStage.Tests/EditorMPTests.cs +++ b/test/code_tests/MicrobeStage.Tests/EditorMPTests.cs @@ -399,7 +399,7 @@ public void EditorMPTests_MultipleIndependentUpgrades() var editsFacade = new MicrobeEditsFacade(originalSpecies, dummyNucleus); var history = new EditorActionHistory(); - var template = originalSpecies.Organelles.GetElementAt(new Hex(0, 0), new List()) ?? + var template = originalSpecies.ReadonlyOrganelles.GetElementAt(new Hex(0, 0), new List()) ?? throw new Exception("Couldn't find organelle"); var upgrades1 = new OrganelleUpgrades @@ -430,7 +430,7 @@ public void EditorMPTests_MultipleUpgradesCombine() var editsFacade = new MicrobeEditsFacade(originalSpecies, dummyNucleus); var history = new EditorActionHistory(); - var template = originalSpecies.Organelles.GetElementAt(new Hex(0, 0), new List()) ?? + var template = originalSpecies.ReadonlyOrganelles.GetElementAt(new Hex(0, 0), new List()) ?? throw new Exception("Couldn't find organelle"); var upgrades1 = new OrganelleUpgrades @@ -461,7 +461,7 @@ public void EditorMPTests_MultipleUpgradesCombine3Step() var editsFacade = new MicrobeEditsFacade(originalSpecies, dummyNucleus); var history = new EditorActionHistory(); - var template = originalSpecies.Organelles.GetElementAt(new Hex(0, 0), new List()) ?? + var template = originalSpecies.ReadonlyOrganelles.GetElementAt(new Hex(0, 0), new List()) ?? throw new Exception("Couldn't find organelle"); var upgrades1 = new OrganelleUpgrades @@ -578,7 +578,7 @@ public void EditorMPTests_DeleteBetweenUpgradesWorksCorrectly() var editsFacade = new MicrobeEditsFacade(originalSpecies, dummyNucleus); var history = new EditorActionHistory(); - var template = originalSpecies.Organelles.GetElementAt(new Hex(0, 0), new List()) ?? + var template = originalSpecies.ReadonlyOrganelles.GetElementAt(new Hex(0, 0), new List()) ?? throw new Exception("Couldn't find organelle"); var upgrades1 = new OrganelleUpgrades @@ -691,7 +691,7 @@ public void EditorMPTests_ReplacingMovedCytoplasmWithoutPlacingIt() var editsFacade = new MicrobeEditsFacade(originalSpecies, dummyNucleus); var history = new EditorActionHistory(); - var template1 = originalSpecies.Organelles.GetElementAt(new Hex(2, 1), new List()) ?? + var template1 = originalSpecies.ReadonlyOrganelles.GetElementAt(new Hex(2, 1), new List()) ?? throw new Exception("Couldn't find organelle"); var moveData = new OrganelleMoveActionData(template1, new Hex(2, 1), new Hex(1, 0), 0, 0); @@ -1150,7 +1150,7 @@ public void EditorMPTests_FullRefundIsNotGivenAfterPlacingMultipleOrganelles() var editsFacade = new MicrobeEditsFacade(originalSpecies, dummyNucleus); var history = new EditorActionHistory(); - var originalToRemove = originalSpecies.Organelles.GetElementAt(new Hex(0, 0), new List()) ?? + var originalToRemove = originalSpecies.ReadonlyOrganelles.GetElementAt(new Hex(0, 0), new List()) ?? throw new Exception("Couldn't find organelle"); var template2 = new OrganelleTemplate(cheapOrganelle, new Hex(1, 0), 0); @@ -1180,7 +1180,7 @@ public void EditorMPTests_RotatingOrganelleIsFree() var editsFacade = new MicrobeEditsFacade(originalSpecies, dummyNucleus); var history = new EditorActionHistory(); - var originalToMove = originalSpecies.Organelles.GetElementAt(new Hex(0, 0), new List()) ?? + var originalToMove = originalSpecies.ReadonlyOrganelles.GetElementAt(new Hex(0, 0), new List()) ?? throw new Exception("Couldn't find organelle"); var moveData = new OrganelleMoveActionData(originalToMove, new Hex(0, 0), new Hex(1, 0), 0, 2); diff --git a/test/microbe_stage.tests/MicrobeSpeciesTests.cs b/test/microbe_stage.tests/MicrobeSpeciesTests.cs index e6d7884d3c6..e4de064b95f 100644 --- a/test/microbe_stage.tests/MicrobeSpeciesTests.cs +++ b/test/microbe_stage.tests/MicrobeSpeciesTests.cs @@ -29,16 +29,19 @@ public MicrobeSpeciesTests() }; testSpecies1.BecomePlayerSpecies(); - testSpecies1.Organelles.Add(new OrganelleTemplate(SimulationParameters.Instance.GetOrganelleType("cytoplasm"), + testSpecies1.ModifiableOrganelles.Add(new OrganelleTemplate( + SimulationParameters.Instance.GetOrganelleType("cytoplasm"), new Hex(0, 0), 0)); - testSpecies1.Organelles.Add(new OrganelleTemplate(SimulationParameters.Instance.GetOrganelleType("rusticyanin"), + testSpecies1.ModifiableOrganelles.Add(new OrganelleTemplate( + SimulationParameters.Instance.GetOrganelleType("rusticyanin"), new Hex(1, 0), 0)); - testSpecies1.Organelles.Add(new OrganelleTemplate( + testSpecies1.ModifiableOrganelles.Add(new OrganelleTemplate( SimulationParameters.Instance.GetOrganelleType("chromatophore"), new Hex(1, 1), 0)); - testSpecies1.Organelles.Add(new OrganelleTemplate(SimulationParameters.Instance.GetOrganelleType("nitrogenase"), + testSpecies1.ModifiableOrganelles.Add(new OrganelleTemplate( + SimulationParameters.Instance.GetOrganelleType("nitrogenase"), new Hex(0, 1), 0)); - testSpecies1.Organelles.Add( + testSpecies1.ModifiableOrganelles.Add( new OrganelleTemplate(SimulationParameters.Instance.GetOrganelleType("cytoplasm"), new Hex(2, 1), 3) { ModifiableUpgrades = new OrganelleUpgrades @@ -58,7 +61,8 @@ public MicrobeSpeciesTests() }; testSpecies2.BecomePlayerSpecies(); - testSpecies2.Organelles.Add(new OrganelleTemplate(SimulationParameters.Instance.GetOrganelleType("cytoplasm"), + testSpecies2.ModifiableOrganelles.Add(new OrganelleTemplate( + SimulationParameters.Instance.GetOrganelleType("cytoplasm"), new Hex(0, 0), 0)); testSpecies2.OnEdited(); }