Skip to content

Commit

Permalink
Centralized the serialization id attributes
Browse files Browse the repository at this point in the history
* so one doesn't have to search throught the whole project to find the next free id, this may be replaced by a generator in the future, that's why the empty serialization id attribute is still present
* removed some deprecated todos
* fixed some todos and hacks

Co-authored-by: Marcus Aurelius <[email protected]>
  • Loading branch information
susch19 and Gallimathias committed Sep 6, 2023
1 parent 53e6e6d commit 5393a68
Show file tree
Hide file tree
Showing 79 changed files with 259 additions and 160 deletions.
39 changes: 37 additions & 2 deletions OctoAwesome/OctoAwesome.Basics/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
using System;
using OctoAwesome;
using OctoAwesome.Basics;
using OctoAwesome.Basics.Entities;
using OctoAwesome.Basics.EntityComponents;
using OctoAwesome.Basics.FunctionBlocks;
using OctoAwesome.Basics.SimulationComponents;
using OctoAwesome.Basics.UI.Components;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -14,4 +22,31 @@
NameOfStaticDeserializeWithCtor = "DeserializeAndCreate",
NameOfDeserializeOnInstance = "Deserialize",
NameOfStaticDeserializeIntoInstance = "Deserialize",
NameOfStaticDeserializeWithOutParams = "DeserializeOut")]
NameOfStaticDeserializeWithOutParams = "DeserializeOut")]

[assembly: SerializationId<WauziEntity>(2, 1)]
[assembly: SerializationId<Chest>(2, 2)]
[assembly: SerializationId<Furnace>(2, 3)]
[assembly: SerializationId<ComplexPlanet>(2, 4)]
[assembly: SerializationId<BodyPowerComponent>(2, 5)]
[assembly: SerializationId<ProductionInventoriesComponent>(2, 6)]
[assembly: SerializationId<BurningComponent>(2, 7)]
[assembly: SerializationId<EntityCollisionComponent>(2, 8)]
[assembly: SerializationId<ForceComponent>(2, 9)]
[assembly: SerializationId<GravityComponent>(2, 10)]
[assembly: SerializationId<MassComponent>(2, 11)]
[assembly: SerializationId<MoveableComponent>(2, 12)]
[assembly: SerializationId<PowerComponent>(2, 13)]
[assembly: SerializationId<RelatedEntityComponent>(2, 14)]
[assembly: SerializationId<TransferComponent>(2, 15)]
[assembly: SerializationId<AccelerationComponent>(2, 16)]
[assembly: SerializationId<BlockInteractionComponent>(2, 17)]
[assembly: SerializationId<CollisionComponent>(2, 18)]
[assembly: SerializationId<ComponentContainerInteractionComponent>(2, 19)]
[assembly: SerializationId<ForceAggregatorComponent>(2, 20)]
[assembly: SerializationId<MoveComponent>(2, 21)]
[assembly: SerializationId<NewtonGravitatorComponent>(2, 22)]
[assembly: SerializationId<PowerAggregatorComponent>(2, 23)]
[assembly: SerializationId<WattMoverComponent>(2, 24)]
[assembly: SerializationId<FurnaceUIComponent>(2, 25)]
[assembly: SerializationId<TransferUIComponent>(2, 26)]
2 changes: 1 addition & 1 deletion OctoAwesome/OctoAwesome.Basics/ComplexPlanet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OctoAwesome.Basics
/// <summary>
/// A complex planet implementation with complex features.
/// </summary>
[SerializationId(2, 4), Nooson]
[SerializationId(), Nooson]
public partial class ComplexPlanet : Planet, IConstructionSerializable<ComplexPlanet>
{
// The gravitational constant was chosen on purpose to be that "big", see Issue #220
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public FurnaceItem(FurnaceItemDefinition definition, IMaterialDefinition materia
/// <inheritdoc/>
public override int Hit(IMaterialDefinition material, BlockInfo blockInfo, decimal volumeRemaining, int volumePerHit)
{
//TODO: Implement Place Chest and remove this item
//TODO: Implement Place Furnace and remove this item
var position = blockInfo.Position;
Furnace chest = new(new Coordinate(0, new(position.X, position.Y, position.Z + 1), new Vector3(0.5f, 0.5f, 0.5f)));
var notification = new EntityNotification
Expand Down
2 changes: 1 addition & 1 deletion OctoAwesome/OctoAwesome.Basics/Entities/WauziEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace OctoAwesome.Basics.Entities
/// <summary>
/// An entity used for dogs in the game.
/// </summary>
[SerializationId(2, 1)]
[SerializationId()]
[Nooson]
public partial class WauziEntity : Entity, ISerializable<WauziEntity>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// Component to apply power to the body of an entity.
/// </summary>
[Nooson]
[SerializationId(2, 5)]
[SerializationId()]
public sealed partial class BodyPowerComponent : PowerComponent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
namespace OctoAwesome.Basics.EntityComponents;

[Nooson]
[SerializationId(2, 6)]
[SerializationId()]
internal partial class ProductionInventoriesComponent : Component, IEntityComponent, IConstructionSerializable<ProductionInventoriesComponent>
{
//TODO Check if Inventory Components have parent
public InventoryComponent InputInventory { get; set; }
public InventoryComponent OutputInventory { get; set; }
public InventoryComponent ProductionInventory { get; set; }
Expand Down Expand Up @@ -55,7 +54,7 @@ protected override void OnParentSetting(IComponentContainer newParent)
}
}

[SerializationId(2, 7)]
[SerializationId()]
internal partial class BurningComponent : Component, IEntityComponent, IUpdateable
{
private StateMachine stateMachine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OctoAwesome.Basics.EntityComponents
/// <summary>
/// Component for entities that should have collision.
/// </summary>
[SerializationId(2, 8)]
[SerializationId()]
public sealed class EntityCollisionComponent : CollisionComponent
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace OctoAwesome.Basics.EntityComponents
/// <summary>
/// Base class for forces to be applied to the entity.
/// </summary>
[SerializationId(2, 9)]
[SerializationId()]
public abstract class ForceComponent : Component, IEntityComponent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Component for applying gravity force to the entity.
/// </summary>
[SerializationId(2, 10)]
[SerializationId()]
public sealed class GravityComponent : ForceComponent
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OctoAwesome.Basics.EntityComponents
/// <summary>
/// Component or specifying the mass of entities.
/// </summary>
[SerializationId(2, 11)]
[SerializationId()]
public sealed class MassComponent : Component, IEntityComponent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace OctoAwesome.Basics.EntityComponents
/// Component for entities that can be moved.
/// </summary>
[Nooson]
[SerializationId(2, 12)]
[SerializationId()]
public sealed partial class MoveableComponent : Component, IEntityComponent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace OctoAwesome.Basics.EntityComponents
/// Base component to apply power to an entity.
/// </summary>
[Nooson]
[SerializationId(2, 13)]
[SerializationId()]
public abstract partial class PowerComponent : Component, IEntityComponent
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OctoAwesome.Basics.EntityComponents;
[Nooson]
[SerializationId(2, 14)]
[SerializationId()]
internal partial class RelatedEntityComponent : Component, IEntityComponent
{
public Guid RelatedEntityId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace OctoAwesome.Basics.EntityComponents;
/// <summary>
/// Used for transfering items from one entity to another
/// </summary>
[SerializationId(2, 15)]
[SerializationId()]
public class TransferComponent : Component, IEntityComponent
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion OctoAwesome/OctoAwesome.Basics/FunctionBlocks/Chest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace OctoAwesome.Basics.FunctionBlocks
/// <summary>
/// Chest entity implementation.
/// </summary>
[SerializationId(2, 2)]
[SerializationId()]
[Nooson]
public partial class Chest : Entity, ISerializable<Chest>
{
Expand Down
2 changes: 1 addition & 1 deletion OctoAwesome/OctoAwesome.Basics/FunctionBlocks/Furnace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace OctoAwesome.Basics.FunctionBlocks;
/// <summary>
/// Represents the furnace object in the world
/// </summary>
[SerializationId(2, 3)]
[SerializationId()]
[Nooson]
public partial class Furnace : Entity, IConstructionSerializable<Furnace>
{
Expand Down
2 changes: 1 addition & 1 deletion OctoAwesome/OctoAwesome.Basics/OctoAwesome.Basics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="dotVariant" Version="0.5.3" />
<PackageReference Include="engenious" Version="0.7.1-alpha" />
<PackageReference Include="engenious.UI" Version="0.7.1-alpha" />
<PackageReference Include="NonSucking.Framework.Serialization" Version="0.1.0.105-alpha" />
<PackageReference Include="NonSucking.Framework.Serialization" Version="0.1.0.108-alpha" />
<!--<ProjectReference Include="..\..\..\..\NonSucking.Framework.Extension\NonSucking.Framework.Serialization\NonSucking.Framework.Serialization.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="true"/>-->
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation with accelerations.
/// </summary>
[SerializationId(2, 16)]
[SerializationId()]
public sealed class AccelerationComponent : SimulationComponent<
Entity,
AccelerationComponent.AcceleratedEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation with block interactions.
/// </summary>
[SerializationId(2, 17)]
[SerializationId()]
public class BlockInteractionComponent : SimulationComponent<
Entity,
SimulationComponentRecord<Entity, ControllableComponent, InventoryComponent>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation with collisions of entities.
/// </summary>
[SerializationId(2, 18)]
[SerializationId()]
public sealed class CollisionComponent : SimulationComponent<Entity>
{
/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation with block interactions with entities.
/// </summary>
[SerializationId(2, 19)]
[SerializationId()]
public class ComponentContainerInteractionComponent : SimulationComponent<
Entity,
SimulationComponentRecord<Entity, ControllableComponent, InventoryComponent>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation with force applied to entities.
/// </summary>
[SerializationId(2, 20)]
[SerializationId()]
public sealed class ForceAggregatorComponent : SimulationComponent<
Entity,
ForceAggregatorComponent.ForcedEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation with moveable entities.
/// </summary>
[SerializationId(2, 21)]
[SerializationId()]
public sealed class MoveComponent : SimulationComponent<
Entity,
SimulationComponentRecord<Entity, MoveableComponent, PositionComponent>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation with newtonian gravity.
/// </summary>
[SerializationId(2, 22)]
[SerializationId()]
public class NewtonGravitatorComponent : SimulationComponent<
Entity,
NewtonGravitatorComponent.GravityEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation aggregated power application to entities.
/// </summary>
[SerializationId(2, 23)]
[SerializationId()]
public sealed class PowerAggregatorComponent : SimulationComponent<
Entity,
PowerAggregatorComponent.PoweredEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace OctoAwesome.Basics.SimulationComponents
/// <summary>
/// Component for simulation with watt energy system.
/// </summary>
[SerializationId(2, 24)]
[SerializationId()]
public class WattMoverComponent : SimulationComponent<
Entity,
SimulationComponentRecord<Entity, ControllableComponent, BodyPowerComponent>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace OctoAwesome.Basics.UI.Components;
/// <summary>
/// Component to provide an UI for transferring items from and to a furnace from a different inventory.
/// </summary>
[SerializationId(2, 25)]
[SerializationId()]
public class FurnaceUIComponent : UIComponent<UiComponentRecord<InventoryComponent, TransferComponent>, InventoryComponent, TransferComponent>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace OctoAwesome.Basics.UI.Components;
/// <summary>
/// Component to provide an UI for transferring items from one inventory to another.
/// </summary>
[SerializationId(2, 26)]
[SerializationId()]
public class TransferUIComponent : UIComponent<UiComponentRecord<InventoryComponent, TransferComponent>, InventoryComponent, TransferComponent>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ private enum TransferDirection
BToA
}

//TODO Where and how to initialize this screen?
/// <summary>
/// Initializes a new instance of the <see cref="TransferScreen"/> class.
/// </summary>
Expand Down
3 changes: 0 additions & 3 deletions OctoAwesome/OctoAwesome.Basics/WauziPopulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ public WauziPopulator(IResourceManager resManager)
/// <inheritdoc />
public void Populate(IResourceManager resourcemanager, IPlanet planet, IChunkColumn column00, IChunkColumn column01, IChunkColumn column10, IChunkColumn column11)
{
//HACK: Activate Wauzi
//return;

if (ispop-- <= 0)
return;

Expand Down
10 changes: 8 additions & 2 deletions OctoAwesome/OctoAwesome.Client.UI/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using OctoAwesome;
using OctoAwesome.UI.Components;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -14,4 +17,7 @@
NameOfStaticDeserializeWithCtor = "DeserializeAndCreate",
NameOfDeserializeOnInstance = "Deserialize",
NameOfStaticDeserializeIntoInstance = "Deserialize",
NameOfStaticDeserializeWithOutParams = "DeserializeOut")]
NameOfStaticDeserializeWithOutParams = "DeserializeOut")]

[assembly: SerializationId<UiKeyComponent>(3, 1)]
[assembly: SerializationId<UiMappingComponent>(3, 2)]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace OctoAwesome.UI.Components;
/// Component to identify which UIComponent to use for an entity interaction.
/// </summary>
[Nooson]
[SerializationId(3, 1)]
[SerializationId()]
public partial class UiKeyComponent : Component, IEntityComponent, IEquatable<UiKeyComponent>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace OctoAwesome.UI.Components;
/// <summary>
/// Class for mapping a <see cref="Component"/> to an <see cref="IEntityComponent"/>
/// </summary>
[SerializationId(3, 2)]
[SerializationId()]
public class UiMappingComponent : Component, IEntityComponent, IDisposable
{
/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions OctoAwesome/OctoAwesome.Client.UI/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

namespace OctoAwesome.Client.UI
{
//TODO: Perhaps outsource

/// <summary>
/// The base extension implementation.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="engenious.UI" Version="0.7.1-alpha" />
<PackageReference Include="NonSucking.Framework.Serialization" Version="0.1.0.105-alpha" />
<PackageReference Include="NonSucking.Framework.Serialization" Version="0.1.0.108-alpha" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions OctoAwesome/OctoAwesome.GameServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ private static int ExecuteCommand(Parser parser, string? command)

if (commandResult.Errors.Count > 0)
{
//Write the fucking manual and then read it!
//TODO
//TODO Write the fucking manual and then read it!
}

return commandResult.Invoke();
Expand Down
Loading

0 comments on commit 5393a68

Please sign in to comment.