[Sci] Non-destructive XenoArch Research (#15398)
* Non-destructive XenoArch research * nerf the price * Points -> Extract
This commit is contained in:
@@ -51,29 +51,7 @@ public sealed partial class ArtifactSystem : EntitySystem
|
||||
/// </remarks>
|
||||
private void GetPrice(EntityUid uid, ArtifactComponent component, ref PriceCalculationEvent args)
|
||||
{
|
||||
var price = component.NodeTree.Sum(x => GetNodePrice(x, component));
|
||||
|
||||
// 25% bonus for fully exploring every node.
|
||||
var fullyExploredBonus = component.NodeTree.Any(x => !x.Triggered) ? 1 : 1.25f;
|
||||
|
||||
args.Price =+ price * fullyExploredBonus;
|
||||
}
|
||||
|
||||
private float GetNodePrice(ArtifactNode node, ArtifactComponent component)
|
||||
{
|
||||
if (!node.Discovered) //no money for undiscovered nodes.
|
||||
return 0;
|
||||
|
||||
var triggerProto = _prototype.Index<ArtifactTriggerPrototype>(node.Trigger);
|
||||
var effectProto = _prototype.Index<ArtifactEffectPrototype>(node.Effect);
|
||||
|
||||
//quarter price if not triggered
|
||||
var priceMultiplier = node.Triggered ? 1f : 0.25f;
|
||||
//the danger is the average of node depth, effect danger, and trigger danger.
|
||||
var nodeDanger = (node.Depth + effectProto.TargetDepth + triggerProto.TargetDepth) / 3;
|
||||
|
||||
var price = MathF.Pow(2f, nodeDanger) * component.PricePerNode * priceMultiplier;
|
||||
return price;
|
||||
args.Price =+ GetResearchPointValue(uid, component) * component.PriceMultiplier;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -96,9 +74,32 @@ public sealed partial class ArtifactSystem : EntitySystem
|
||||
|
||||
var sumValue = component.NodeTree.Sum(n => GetNodePointValue(n, component, getMaxPrice));
|
||||
var fullyExploredBonus = component.NodeTree.All(x => x.Triggered) || getMaxPrice ? 1.25f : 1;
|
||||
sumValue -= component.ConsumedPoints;
|
||||
|
||||
var pointValue = (int) (sumValue * fullyExploredBonus);
|
||||
return pointValue;
|
||||
return (int) (sumValue * fullyExploredBonus);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts how many points on the artifact have been consumed
|
||||
/// </summary>
|
||||
public void AdjustConsumedPoints(EntityUid uid, int amount, ArtifactComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
component.ConsumedPoints += amount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether or not the artifact is suppressed,
|
||||
/// preventing it from activating
|
||||
/// </summary>
|
||||
public void SetIsSuppressed(EntityUid uid, bool suppressed, ArtifactComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
component.IsSuppressed = suppressed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -201,8 +202,8 @@ public sealed partial class ArtifactSystem : EntitySystem
|
||||
var currentNode = GetNodeFromId(component.CurrentNodeId.Value, component);
|
||||
|
||||
var allNodes = currentNode.Edges;
|
||||
_sawmill.Debug("artifact", $"our node: {currentNode.Id}");
|
||||
_sawmill.Debug("artifact", $"other nodes: {string.Join(", ", allNodes)}");
|
||||
_sawmill.Debug($"our node: {currentNode.Id}");
|
||||
_sawmill.Debug($"other nodes: {string.Join(", ", allNodes)}");
|
||||
|
||||
if (TryComp<BiasedArtifactComponent>(uid, out var bias) &&
|
||||
TryComp<TraversalDistorterComponent>(bias.Provider, out var trav) &&
|
||||
@@ -225,14 +226,14 @@ public sealed partial class ArtifactSystem : EntitySystem
|
||||
}
|
||||
|
||||
var undiscoveredNodes = allNodes.Where(x => !GetNodeFromId(x, component).Discovered).ToList();
|
||||
_sawmill.Debug("artifact", $"Undiscovered nodes: {string.Join(", ", undiscoveredNodes)}");
|
||||
_sawmill.Debug($"Undiscovered nodes: {string.Join(", ", undiscoveredNodes)}");
|
||||
var newNode = _random.Pick(allNodes);
|
||||
if (undiscoveredNodes.Any() && _random.Prob(0.75f))
|
||||
{
|
||||
newNode = _random.Pick(undiscoveredNodes);
|
||||
}
|
||||
|
||||
_sawmill.Debug("artifact", $"Going to node {newNode}");
|
||||
_sawmill.Debug($"Going to node {newNode}");
|
||||
return GetNodeFromId(newNode, component);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user