189 lines
5.4 KiB
C#
189 lines
5.4 KiB
C#
#nullable enable
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Demo2.Domain
|
|
{
|
|
public enum Demo2Phase : byte { Title, Lobby, Build, Production, Defense, Reward, Victory, Defeat }
|
|
public enum Demo2TransportMode : byte { Tcp, Kcp }
|
|
public enum Demo2MachineKind : byte { Miner, Conveyor, Splitter, Smelter, Assembler, Loader, Turret, Generator, NightShiftSmelter = 100 }
|
|
public enum Demo2MaterialKind : byte { IronOre, Fuel, Ingot, Gear, Ammo, Energy }
|
|
public enum Demo2RuleCategory : byte { Production, Logistics, MachineState, CycleSettlement, RiskExchange }
|
|
public enum Demo2RuleOpcode : byte
|
|
{
|
|
AddPayload,
|
|
MultiplyPayload,
|
|
AddMultiplier,
|
|
MultiplyMultiplier,
|
|
ConvertEnergyToPayload,
|
|
AddMoneyFromExcess,
|
|
DuplicateNextOutput,
|
|
AddFaults,
|
|
RepairFaults
|
|
}
|
|
|
|
[Flags]
|
|
public enum Demo2RuleCondition : ushort
|
|
{
|
|
None = 0,
|
|
ThreeSameRecipes = 1 << 0,
|
|
IronFuelAdjacent = 1 << 1,
|
|
BeltBelowEightyPercent = 1 << 2,
|
|
NoFaults = 1 << 3,
|
|
HasExcessEnergy = 1 << 4,
|
|
FirstBatch = 1 << 5,
|
|
CoreAtRisk = 1 << 6,
|
|
HasFaults = 1 << 7
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2RuleInstructionData
|
|
{
|
|
public Demo2RuleOpcode Opcode;
|
|
public Demo2RuleCondition Condition;
|
|
public long Operand;
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2RuleDefinition
|
|
{
|
|
public string Id = string.Empty;
|
|
public string Name = string.Empty;
|
|
public string Description = string.Empty;
|
|
public Demo2RuleCategory Category;
|
|
public List<Demo2RuleInstructionData> Instructions = new();
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2RecipeDefinition
|
|
{
|
|
public int Id;
|
|
public string Name = string.Empty;
|
|
public Demo2MaterialKind InputA;
|
|
public Demo2MaterialKind InputB;
|
|
public Demo2MaterialKind Output;
|
|
public int InputCountA;
|
|
public int InputCountB;
|
|
public int OutputCount;
|
|
public int ProcessTicks;
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2MachineDefinition
|
|
{
|
|
public Demo2MachineKind Kind;
|
|
public string Name = string.Empty;
|
|
public int Cost;
|
|
public int RecipeId;
|
|
public int Capacity;
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2WaveDefinition
|
|
{
|
|
public int Cycle;
|
|
public long TotalHealth;
|
|
public string Trait = string.Empty;
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2BuildCommand
|
|
{
|
|
public long Sequence;
|
|
public string IdempotencyToken = string.Empty;
|
|
public string PlayerId = string.Empty;
|
|
public Demo2MachineKind Kind;
|
|
public int X;
|
|
public int Y;
|
|
public byte Rotation;
|
|
public int RecipeId;
|
|
public bool Remove;
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2CommandResult
|
|
{
|
|
public bool Accepted;
|
|
public bool Duplicate;
|
|
public string ErrorCode = string.Empty;
|
|
public int Refund;
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2SnapshotEntity
|
|
{
|
|
public int StableId;
|
|
public Demo2MachineKind MachineKind;
|
|
public Demo2MaterialKind MaterialKind;
|
|
public int X;
|
|
public int Y;
|
|
public byte Rotation;
|
|
public int RecipeId;
|
|
public int Progress;
|
|
public int Quantity;
|
|
public int Faults;
|
|
public int PendingOutputs;
|
|
public long TurretAmmo;
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2Snapshot
|
|
{
|
|
public int SimulationVersion = Demo2Protocol.SimulationVersion;
|
|
public long Tick;
|
|
public ulong Seed;
|
|
public Demo2Phase Phase;
|
|
public int Cycle;
|
|
public int CoreHealth;
|
|
public long Money;
|
|
public long Payload;
|
|
public long MultiplierMilli = SaturatingMath.Scale;
|
|
public long Energy;
|
|
public long ExcessFirepower;
|
|
public int RuleAppliedCycle;
|
|
public int SpeedMultiplier = 1;
|
|
public long Extracted;
|
|
public long Transported;
|
|
public long Processed;
|
|
public long AmmoProduced;
|
|
public int CompletedSameRecipeStreak;
|
|
public int LastRecipeId;
|
|
public int Faults;
|
|
public int BeltOccupancy;
|
|
public int BeltCapacity;
|
|
public byte IronFuelAdjacent;
|
|
public byte FirstBatch;
|
|
public int DuplicateNextOutputs;
|
|
public ulong StateHash;
|
|
public List<string> RuleIds = new();
|
|
public List<Demo2SnapshotEntity> Entities = new();
|
|
}
|
|
|
|
[Serializable]
|
|
public sealed class Demo2SaveData
|
|
{
|
|
public const int CurrentVersion = 1;
|
|
public int Version = CurrentVersion;
|
|
public int Cycle = 1;
|
|
public int CoreHealth = 3;
|
|
public long Money = 500;
|
|
public ulong Seed = 20260817;
|
|
public string BlueprintJson = string.Empty;
|
|
public List<string> RuleIds = new();
|
|
public List<string> UnlockIds = new();
|
|
public string SnapshotJson = string.Empty;
|
|
public string SnapshotHash = string.Empty;
|
|
}
|
|
|
|
public static class Demo2Protocol
|
|
{
|
|
public const string GameVersion = "1.0.0";
|
|
public const int SimulationVersion = 1;
|
|
public const int TickRate = 20;
|
|
public const int GridWidth = 32;
|
|
public const int GridHeight = 20;
|
|
public const int CycleCount = 5;
|
|
}
|
|
}
|