Skip to content

Commit

Permalink
Fixed a bunch of warnings and adjusted flagellum force down
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyyrylainen committed Oct 27, 2023
1 parent 8f8417a commit 5586d11
Show file tree
Hide file tree
Showing 43 changed files with 76 additions and 121 deletions.
3 changes: 3 additions & 0 deletions Scripts/NativeLibs.cs
Expand Up @@ -249,6 +249,9 @@ private string GetLibraryDllName(Library library, PackagePlatform platform)
return Task.FromResult(true);
}

// TODO: more library files per library?
cancellationToken.ThrowIfCancellationRequested();

ColourConsole.WriteErrorLine($"Library does not exist: {file}");
return Task.FromResult(false);
}
Expand Down
1 change: 0 additions & 1 deletion Thrive.csproj
Expand Up @@ -682,7 +682,6 @@
<Compile Include="src\general\Int3.cs" />
<Compile Include="src\general\GameProperties.cs" />
<Compile Include="src\microbe_stage\AgentProperties.cs" />
<Compile Include="src\general\ITimedLife.cs" />
<Compile Include="src\general\IWorldEffect.cs" />
<Compile Include="src\general\TimedWorldOperations.cs" />
<Compile Include="src\general\Species.cs" />
Expand Down
2 changes: 1 addition & 1 deletion simulation_parameters/Constants.cs
Expand Up @@ -144,7 +144,7 @@ public static class Constants

public const float FLAGELLA_ENERGY_COST = 4.0f;

public const float FLAGELLA_BASE_FORCE = 750.7f;
public const float FLAGELLA_BASE_FORCE = 250.7f;

public const float BASE_MOVEMENT_FORCE = 910.0f;

Expand Down
4 changes: 1 addition & 3 deletions src/benchmark/DummySpawnSystem.cs
@@ -1,6 +1,4 @@
using System;
using DefaultEcs;
using DefaultEcs.Command;
using DefaultEcs.Command;
using Godot;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/early_multicellular_stage/CellType.cs
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using Godot;
using Newtonsoft.Json;

Expand Down
Expand Up @@ -5,7 +5,6 @@
using System.Linq;
using DefaultEcs;
using DefaultEcs.Command;
using Godot;
using Newtonsoft.Json;

/// <summary>
Expand Down Expand Up @@ -212,7 +211,7 @@ public static void BecomeFullyGrownMulticellularColony(this ref MulticellularGro
var compound = entry.Key;
var neededAmount = entry.Value;

if (multicellularGrowth.CompoundsNeededForNextCell.TryGetValue(compound, out var left))
if (multicellularGrowth.CompoundsNeededForNextCell!.TryGetValue(compound, out var left))
{
var alreadyUsed = neededAmount - left;

Expand Down
Expand Up @@ -174,7 +174,7 @@ protected override void Update(float delta, in Entity entity)
multicellularGrowth.CompoundsNeededForNextCell[entry.Key] = left;
}

multicellularGrowth.CompoundsUsedForMulticellularGrowth.TryGetValue(entry.Key, out float alreadyUsed);
multicellularGrowth.CompoundsUsedForMulticellularGrowth!.TryGetValue(entry.Key, out float alreadyUsed);

multicellularGrowth.CompoundsUsedForMulticellularGrowth[entry.Key] = alreadyUsed + usedAmount;

Expand Down
2 changes: 1 addition & 1 deletion src/engine/common_components/Health.cs
Expand Up @@ -186,7 +186,7 @@ public static void RescaleMaxHealth(this ref Health health, float newMaxHealth)

float currentFraction = health.CurrentHealth / health.MaxHealth;

health.MaxHealth = health.CurrentHealth;
health.MaxHealth = newMaxHealth;

health.CurrentHealth = health.MaxHealth * currentFraction;
}
Expand Down
1 change: 0 additions & 1 deletion src/engine/common_components/ReproductionStatus.cs
Expand Up @@ -61,7 +61,6 @@ public static class ReproductionStatusHelpers
resultReceiver.TryGetValue(totalCost.Key, out var alreadyAbsorbed);
resultReceiver[totalCost.Key] = alreadyAbsorbed + absorbed;
}

}
}
}
4 changes: 0 additions & 4 deletions src/engine/common_components/SoundEffectPlayer.cs
@@ -1,6 +1,5 @@
namespace Components
{
using System;
using System.Runtime.CompilerServices;
using Godot;
using Newtonsoft.Json;
Expand Down Expand Up @@ -63,9 +62,6 @@ public struct SoundEffectSlot

public static class SoundEffectPlayerHelpers
{



/// <summary>
/// Starts playing a new sound effect
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/engine/common_systems/PhysicsBodyControlSystem.cs
Expand Up @@ -47,7 +47,7 @@ protected override void Update(float delta, in Entity entity)
{
control.RemoveVelocity = false;
control.RemoveAngularVelocity = false;
physicalWorld!.SetBodyVelocity(body, Vector3.Zero, Vector3.Zero);
physicalWorld.SetBodyVelocity(body, Vector3.Zero, Vector3.Zero);
}
else if (control.RemoveVelocity)
{
Expand Down
1 change: 0 additions & 1 deletion src/engine/common_systems/PhysicsBodyCreationSystem.cs
@@ -1,6 +1,5 @@
namespace Systems
{
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Components;
Expand Down
4 changes: 1 addition & 3 deletions src/engine/common_systems/SpatialAttachSystem.cs
Expand Up @@ -14,15 +14,13 @@
public sealed class SpatialAttachSystem : AComponentSystem<float, SpatialInstance>
{
private readonly Node godotWorldRoot;
private readonly World world;

private readonly Dictionary<Spatial, AttachedInfo> attachedSpatialInstances = new();
private readonly List<Spatial> instancesToDelete = new();

public SpatialAttachSystem(Node godotWorldRoot, World world) : base(world)
public SpatialAttachSystem(Node godotWorldRoot, World world) : base(world, null)
{
this.godotWorldRoot = godotWorldRoot;
this.world = world;
}

protected override void PreUpdate(float state)
Expand Down
1 change: 0 additions & 1 deletion src/engine/common_systems/TimedLifeSystem.cs
@@ -1,6 +1,5 @@
namespace Systems
{
using System;
using Components;
using DefaultEcs;
using DefaultEcs.System;
Expand Down
7 changes: 0 additions & 7 deletions src/general/ITimedLife.cs

This file was deleted.

3 changes: 1 addition & 2 deletions src/general/PlayerInspectInfo.cs
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Components;
using DefaultEcs;
Expand Down
4 changes: 2 additions & 2 deletions src/general/base_stage/StageBase.cs
Expand Up @@ -73,8 +73,8 @@ public abstract class StageBase : NodeWithInput, IStageBase, IGodotEarlyNodeReso
/// </summary>
/// <remarks>
/// <para>
/// This used to have an internal set (<see cref="CreatureStageBase{TPlayer}.MovingToEditor"/> had that as
/// well) but with the needed <see cref="ICreatureStage"/> that seems no longer possible
/// This used to have an internal set (<see cref="CreatureStageBase{TPlayer,TSimulation}.MovingToEditor"/>
/// had that as well) but with the needed <see cref="ICreatureStage"/> that seems no longer possible
/// </para>
/// </remarks>
[JsonIgnore]
Expand Down
3 changes: 1 addition & 2 deletions src/late_multicellular_stage/MulticellularCreature.cs
Expand Up @@ -287,8 +287,7 @@ public MulticellularCreature SpawnOffspring()
GetParent(), SpawnHelpers.LoadMulticellularScene(), true, spawnSystem!, CurrentGame);

// Make it despawn like normal
throw new NotImplementedException();

// TODO: reimplement spawn system for the multicellular stage
// spawnSystem!.NotifyExternalEntitySpawned(copyEntity);

// TODO: some kind of resource splitting for the offspring?
Expand Down
3 changes: 0 additions & 3 deletions src/late_multicellular_stage/MulticellularStage.cs
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Godot;
using Newtonsoft.Json;
Expand Down Expand Up @@ -321,8 +320,6 @@ public override void OnReturnFromEditor()
}
}



public override void OnSuicide()
{
Player?.Damage(9999.0f, "suicide");
Expand Down
4 changes: 1 addition & 3 deletions src/microbe_stage/AgentProperties.cs
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using Components;
using Components;
using Newtonsoft.Json;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/microbe_stage/ChunkConfiguration.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Godot;
using Newtonsoft.Json;

/// <summary>
Expand Down
33 changes: 14 additions & 19 deletions src/microbe_stage/MicrobeHUD.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Components;
using DefaultEcs;
using Godot;
Expand Down Expand Up @@ -295,7 +294,7 @@ protected override void UpdateHealth(float delta)

protected override Func<Compound, bool> GetIsUsefulCheck()
{
if (!stage!.Player.Has<Components.MicrobeColony>())
if (!stage!.Player.Has<MicrobeColony>())
{
var compounds = stage.Player.Get<CompoundStorage>().Compounds;
return compound => compounds.IsUseful(compound);
Expand All @@ -319,7 +318,7 @@ protected override bool SpecialHandleBar(ProgressBar bar)

protected override bool ShouldShowAgentsPanel()
{
if (!stage!.Player.Has<Components.MicrobeColony>())
if (!stage!.Player.Has<MicrobeColony>())
{
return GetPlayerUsefulCompounds()!.AreAnySpecificallySetUseful(allAgents);
}
Expand All @@ -332,7 +331,7 @@ protected override bool ShouldShowAgentsPanel()

protected override ICompoundStorage GetPlayerStorage()
{
if (!stage!.Player.Has<Components.MicrobeColony>())
if (!stage!.Player.Has<MicrobeColony>())
{
return stage.Player.Get<CompoundStorage>().Compounds;
}
Expand All @@ -346,7 +345,7 @@ protected override void UpdateCompoundBars(float delta)
{
base.UpdateCompoundBars(delta);

if (stage!.Player.Has<Components.MicrobeColony>())
if (stage!.Player.Has<MicrobeColony>())
{
// TODO: calculate total engulf size (probably don't need to cache this as only the GUI needs this
// currently)
Expand Down Expand Up @@ -385,7 +384,7 @@ protected override void UpdateAbilitiesHotBar()
bool showSlime;

// Multicellularity is not checked here (only colony membership) as that is also not checked when firing toxins
if (player.Has<Components.MicrobeColony>())
if (player.Has<MicrobeColony>())
{
throw new NotImplementedException();

Expand Down Expand Up @@ -515,7 +514,7 @@ private void OnRadialItemSelected(int itemId)

private float GetPlayerUsedIngestionCapacity()
{
if (stage!.Player.Has<Components.MicrobeColony>())
if (stage!.Player.Has<MicrobeColony>())
{
// TODO: calculate total used ingestion capacity
throw new NotImplementedException();
Expand All @@ -531,7 +530,7 @@ private void UpdateMulticellularButton(Entity player)
if (stage == null)
throw new InvalidOperationException("Can't update multicellular button without stage set");

if (!player.Has<Components.MicrobeColony>())
if (!player.Has<MicrobeColony>())
{
multicellularButton.Visible = false;
return;
Expand All @@ -546,11 +545,9 @@ private void UpdateMulticellularButton(Entity player)

multicellularButton.Visible = true;

ref var colony = ref player.Get<Components.MicrobeColony>();
ref var colony = ref player.Get<MicrobeColony>();

throw new NotImplementedException();

/*var newColonySize = player.Colony.ColonyMembers.Count;
var newColonySize = colony.ColonyMembers.Length;

if (stage.MovingToEditor)
{
Expand All @@ -568,7 +565,7 @@ private void UpdateMulticellularButton(Entity player)
}
}

UpdateColonySize(newColonySize);*/
UpdateColonySize(newColonySize);
}

private void UpdateColonySize(int newColonySize)
Expand All @@ -595,7 +592,7 @@ private void UpdateMacroscopicButton(Entity player)
if (stage == null)
throw new InvalidOperationException("Can't update macroscopic button without stage set");

if (!player.Has<Components.MicrobeColony>())
if (!player.Has<MicrobeColony>())
{
macroscopicButton.Visible = false;
return;
Expand All @@ -609,11 +606,9 @@ private void UpdateMacroscopicButton(Entity player)

macroscopicButton.Visible = true;

ref var colony = ref player.Get<Components.MicrobeColony>();

throw new NotImplementedException();
ref var colony = ref player.Get<MicrobeColony>();

/*var newColonySize = colony.ColonyMembers.Count;
var newColonySize = colony.ColonyMembers.Length;

if (stage.MovingToEditor)
{
Expand All @@ -624,7 +619,7 @@ private void UpdateMacroscopicButton(Entity player)
macroscopicButton.Disabled = newColonySize < Constants.COLONY_SIZE_REQUIRED_FOR_MACROSCOPIC;
}

UpdateColonySize(newColonySize);*/
UpdateColonySize(newColonySize);
}

private void UpdateColonySizeForMacroscopic()
Expand Down
3 changes: 1 addition & 2 deletions src/microbe_stage/MicrobeInternalCalculations.cs
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Godot;

Expand Down
1 change: 0 additions & 1 deletion src/microbe_stage/MicrobeStage.cs
Expand Up @@ -6,7 +6,6 @@
using DefaultEcs.Command;
using Godot;
using Newtonsoft.Json;
using Object = Godot.Object;

/// <summary>
/// Main class for managing the microbe stage
Expand Down
4 changes: 4 additions & 0 deletions src/microbe_stage/MicrobeWorldSimulation.cs
Expand Up @@ -67,6 +67,7 @@ public class MicrobeWorldSimulation : WorldSimulationWithPhysics
private MicrobeReproductionSystem microbeReproductionSystem = null!;
private TintColourAnimationSystem tintColourAnimationSystem = null!;
private ToxinCollisionSystem toxinCollisionSystem = null!;
private UnneededCompoundVentingSystem unneededCompoundVentingSystem = null!;

#pragma warning disable CA2213
private Node visualsParent = null!;
Expand Down Expand Up @@ -171,6 +172,7 @@ public void Init(Node visualDisplayRoot, CompoundCloudSystem cloudSystem)
tintColourAnimationSystem = new TintColourAnimationSystem(EntitySystem);

toxinCollisionSystem = new ToxinCollisionSystem(EntitySystem, parallelRunner);
unneededCompoundVentingSystem = new UnneededCompoundVentingSystem(cloudSystem, EntitySystem, parallelRunner);

// Systems stored in properties
CameraFollowSystem = new CameraFollowSystem(EntitySystem);
Expand Down Expand Up @@ -276,6 +278,7 @@ protected override void OnProcessFixedLogic(float delta)
spatialPositionSystem.Update(delta);

allCompoundsVentingSystem.Update(delta);
unneededCompoundVentingSystem.Update(delta);
compoundAbsorptionSystem.Update(delta);
entitySignalingSystem.Update(delta);

Expand Down Expand Up @@ -396,6 +399,7 @@ protected override void Dispose(bool disposing)
microbeReproductionSystem.Dispose();
tintColourAnimationSystem.Dispose();
toxinCollisionSystem.Dispose();
unneededCompoundVentingSystem.Dispose();

CameraFollowSystem.Dispose();
ProcessSystem.Dispose();
Expand Down

0 comments on commit 5586d11

Please sign in to comment.