Files
OldThink/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactComponent.cs
2023-03-24 13:50:24 +11:00

144 lines
4.3 KiB
C#

using Content.Shared.Xenoarchaeology.XenoArtifacts;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Xenoarchaeology.XenoArtifacts;
[RegisterComponent]
public sealed class ArtifactComponent : Component
{
/// <summary>
/// Every node contained in the tree
/// </summary>
[DataField("nodeTree"), ViewVariables]
public List<ArtifactNode> NodeTree = new();
/// <summary>
/// The current node the artifact is on.
/// </summary>
[DataField("currentNodeId"), ViewVariables]
public int? CurrentNodeId;
#region Node Tree Gen
/// <summary>
/// Minimum number of nodes to generate, inclusive
/// </summary>
[DataField("nodesMin")]
public int NodesMin = 3;
/// <summary>
/// Maximum number of nodes to generate, exclusive
/// </summary>
[DataField("nodesMax")]
public int NodesMax = 9;
#endregion
/// <summary>
/// Cooldown time between artifact activations (in seconds).
/// </summary>
[DataField("timer"), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan CooldownTime = TimeSpan.FromSeconds(5);
/// <summary>
/// Is this artifact under some suppression device?
/// f true, will ignore all trigger activations attempts.
/// </summary>
[DataField("isSuppressed"), ViewVariables(VVAccess.ReadWrite)]
public bool IsSuppressed;
/// <summary>
/// The last time the artifact was activated.
/// </summary>
[DataField("lastActivationTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan LastActivationTime;
/// <summary>
/// The base price of each node for an artifact
/// </summary>
[DataField("pricePerNode")]
public int PricePerNode = 500;
/// <summary>
/// The base amount of research points for each artifact node.
/// </summary>
[DataField("pointsPerNode")]
public int PointsPerNode = 5000;
/// <summary>
/// A multiplier that is raised to the power of the average depth of a node.
/// Used for calculating the research point value of an artifact node.
/// </summary>
[DataField("pointDangerMultiplier")]
public float PointDangerMultiplier = 1.35f;
}
/// <summary>
/// A single "node" of an artifact that contains various data about it.
/// </summary>
[DataDefinition]
public sealed class ArtifactNode : ICloneable
{
/// <summary>
/// A numeric id corresponding to each node.
/// </summary>
[DataField("id"), ViewVariables]
public int Id;
/// <summary>
/// how "deep" into the node tree. used for generation and price/value calculations
/// </summary>
[DataField("depth"), ViewVariables]
public int Depth;
/// <summary>
/// A list of surrounding nodes. Used for tree traversal
/// </summary>
[DataField("edges"), ViewVariables]
public HashSet<int> Edges = new();
/// <summary>
/// Whether or not the node has been entered
/// </summary>
[DataField("discovered"), ViewVariables(VVAccess.ReadWrite)]
public bool Discovered;
/// <summary>
/// The trigger for the node
/// </summary>
[DataField("trigger", customTypeSerializer: typeof(PrototypeIdSerializer<ArtifactTriggerPrototype>), required: true), ViewVariables]
public string Trigger = default!;
/// <summary>
/// Whether or not the node has been triggered
/// </summary>
[DataField("triggered"), ViewVariables(VVAccess.ReadWrite)]
public bool Triggered;
/// <summary>
/// The effect when the node is activated
/// </summary>
[DataField("effect", customTypeSerializer: typeof(PrototypeIdSerializer<ArtifactEffectPrototype>), required: true), ViewVariables]
public string Effect = default!;
/// <summary>
/// Used for storing cumulative information about nodes
/// </summary>
[DataField("nodeData"), ViewVariables]
public Dictionary<string, object> NodeData = new();
public object Clone()
{
return new ArtifactNode
{
Id = Id,
Depth = Depth,
Edges = Edges,
Discovered = Discovered,
Trigger = Trigger,
Triggered = Triggered,
Effect = Effect,
NodeData = NodeData
};
}
}