modular fix (#1462)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Content.Shared._CP14.MagicEnergy;
|
||||
using Content.Shared._CP14.MagicEnergy.Components;
|
||||
using Content.Shared.Cargo;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server._CP14.MagicEnergy;
|
||||
@@ -14,6 +16,8 @@ public sealed partial class CP14MagicEnergySystem : SharedCP14MagicEnergySystem
|
||||
|
||||
InitializeDraw();
|
||||
InitializePortRelay();
|
||||
|
||||
SubscribeLocalEvent<CP14MagicEnergyContainerComponent, PriceCalculationEvent>(OnMagicEnergyPriceCalculation);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -23,4 +27,9 @@ public sealed partial class CP14MagicEnergySystem : SharedCP14MagicEnergySystem
|
||||
UpdateDraw(frameTime);
|
||||
UpdatePortRelay(frameTime);
|
||||
}
|
||||
|
||||
private void OnMagicEnergyPriceCalculation(Entity<CP14MagicEnergyContainerComponent> ent, ref PriceCalculationEvent args)
|
||||
{
|
||||
args.Price += (double)(ent.Comp.Energy * 0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Item;
|
||||
using Content.Shared._CP14.ModularCraft;
|
||||
using Content.Shared._CP14.ModularCraft.Components;
|
||||
using Content.Shared._CP14.ModularCraft.Prototypes;
|
||||
using Content.Shared.Cargo.Components;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Materials;
|
||||
@@ -108,7 +109,13 @@ public sealed class CP14ModularCraftSystem : CP14SharedModularCraftSystem
|
||||
{
|
||||
foreach (var detail in autoAssemble.Details)
|
||||
{
|
||||
TryAddPartToFirstSlot(ent, detail);
|
||||
var detailEnt = Spawn(detail);
|
||||
if (!TryComp<CP14ModularCraftPartComponent>(detailEnt, out var partComp))
|
||||
{
|
||||
QueueDel(detailEnt);
|
||||
continue;
|
||||
}
|
||||
TryAddPartToFirstSlot(ent, (detailEnt, partComp));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,28 +147,8 @@ public sealed class CP14ModularCraftSystem : CP14SharedModularCraftSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryAddPartToFirstSlot(Entity<CP14ModularCraftStartPointComponent> start,
|
||||
ProtoId<CP14ModularCraftPartPrototype> partProto)
|
||||
{
|
||||
if (!_proto.TryIndex(partProto, out var partIndexed))
|
||||
return false;
|
||||
|
||||
if (partIndexed.Slots.Count == 0)
|
||||
return false;
|
||||
|
||||
foreach (var slot in partIndexed.Slots)
|
||||
{
|
||||
if (!start.Comp.FreeSlots.Contains(slot))
|
||||
continue;
|
||||
|
||||
return TryAddPartToSlot(start, null, partProto, slot);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryAddPartToSlot(Entity<CP14ModularCraftStartPointComponent> start,
|
||||
Entity<CP14ModularCraftPartComponent>? part,
|
||||
Entity<CP14ModularCraftPartComponent> part,
|
||||
ProtoId<CP14ModularCraftPartPrototype> partProto,
|
||||
ProtoId<CP14ModularCraftSlotPrototype> slot)
|
||||
{
|
||||
@@ -175,7 +162,7 @@ public sealed class CP14ModularCraftSystem : CP14SharedModularCraftSystem
|
||||
}
|
||||
|
||||
private void AddPartToSlot(Entity<CP14ModularCraftStartPointComponent> start,
|
||||
Entity<CP14ModularCraftPartComponent>? part,
|
||||
Entity<CP14ModularCraftPartComponent> part,
|
||||
ProtoId<CP14ModularCraftPartPrototype> partProto,
|
||||
ProtoId<CP14ModularCraftSlotPrototype> slot)
|
||||
{
|
||||
@@ -207,11 +194,13 @@ public sealed class CP14ModularCraftSystem : CP14SharedModularCraftSystem
|
||||
}
|
||||
}
|
||||
|
||||
if (TryComp<Shared.Cargo.Components.StaticPriceComponent>(part, out var staticPartPrice))
|
||||
{
|
||||
var startStaticPrice = EnsureComp<Shared.Cargo.Components.StaticPriceComponent>(start);
|
||||
var startStaticPrice = EnsureComp<StaticPriceComponent>(start);
|
||||
startStaticPrice.Price += part.Comp.AddPrice;
|
||||
|
||||
startStaticPrice.Price += staticPartPrice.Price;
|
||||
if (TryComp<StaticPriceComponent>(part, out var partStaticPrice))
|
||||
{
|
||||
|
||||
startStaticPrice.Price += partStaticPrice.Price;
|
||||
}
|
||||
|
||||
foreach (var modifier in indexedPart.Modifiers)
|
||||
|
||||
@@ -57,9 +57,9 @@ public sealed partial class CP14StationEconomySystem : CP14SharedStationEconomyS
|
||||
switch (trade.Service)
|
||||
{
|
||||
case CP14BuyItemsService buyItems:
|
||||
if (!_proto.TryIndex(buyItems.Product, out var indexedProduct))
|
||||
break;
|
||||
price += _price.GetEstimatedPrice(indexedProduct) * buyItems.Count;
|
||||
var tempEnt = Spawn(buyItems.Product); //we need to correctly rate items through price event to rate melee weapon damage, amount of magic energy, and so on.
|
||||
price += _price.GetPrice(tempEnt) * buyItems.Count;
|
||||
QueueDel(tempEnt);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,5 +10,5 @@ namespace Content.Shared._CP14.ModularCraft.Components;
|
||||
public sealed partial class CP14ModularCraftAutoAssembleComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public List<ProtoId<CP14ModularCraftPartPrototype>> Details = new();
|
||||
public List<EntProtoId> Details = new();
|
||||
}
|
||||
|
||||
@@ -12,5 +12,11 @@ public sealed partial class CP14ModularCraftPartComponent : Component
|
||||
[DataField]
|
||||
public float DoAfter = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// Attaching this piece adds an additional price to the target object.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public double AddPrice = 5;
|
||||
|
||||
//TODO: Sound
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- CuissesIronPlate
|
||||
- GreaveIronPlate
|
||||
- CP14ModularCuissesIronPlate
|
||||
- CP14ModularGreaveIronPlate
|
||||
|
||||
- type: entity
|
||||
id: CP14ArmorGoldCuirassPresets
|
||||
@@ -34,8 +34,8 @@
|
||||
color: "#ffaf47"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- CuissesGoldPlate
|
||||
- GreaveGoldPlate
|
||||
- CP14ModularCuissesGoldPlate
|
||||
- CP14ModularGreaveGoldPlate
|
||||
|
||||
- type: entity
|
||||
id: CP14ArmorCopperCuirassPresets
|
||||
@@ -55,8 +55,8 @@
|
||||
color: "#bd712f"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- CuissesCopperPlate
|
||||
- GreaveCopperPlate
|
||||
- CP14ModularCuissesCopperPlate
|
||||
- CP14ModularGreaveCopperPlate
|
||||
|
||||
- type: entity
|
||||
id: CP14ArmorMithrilCuirassPresets
|
||||
@@ -76,8 +76,8 @@
|
||||
color: "#45d2a4"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- CuissesMithrilPlate
|
||||
- GreaveMithrilPlate
|
||||
- CP14ModularCuissesMithrilPlate
|
||||
- CP14ModularGreaveMithrilPlate
|
||||
|
||||
- type: entity
|
||||
id: CP14ArmorIronChainmailPresets
|
||||
@@ -94,8 +94,8 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- CuissesIronChainmail
|
||||
- GreaveIronChainmail
|
||||
- CP14ModularCuissesIronChainmail
|
||||
- CP14ModularGreaveIronChainmail
|
||||
|
||||
- type: entity
|
||||
id: CP14ArmorMithrilChainmailPresets
|
||||
@@ -115,5 +115,5 @@
|
||||
color: "#45d2a4"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- CuissesMithrilChainmail
|
||||
- GreaveMithrilChainmail
|
||||
- CP14ModularCuissesMithrilChainmail
|
||||
- CP14ModularGreaveMithrilChainmail
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- TipIronArrow
|
||||
- CP14ModularTipIronArrow
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularMithrilArrow
|
||||
@@ -30,7 +30,7 @@
|
||||
color: "#45d2a4"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- TipMithrilArrow
|
||||
- CP14ModularTipMithrilArrow
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularCopperArrow
|
||||
@@ -47,5 +47,5 @@
|
||||
color: "#bd712f"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- TipCopperArrow
|
||||
- CP14ModularTipCopperArrow
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronAxe
|
||||
- CP14ModularBladeIronAxe
|
||||
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronDagger
|
||||
- CP14ModularBladeIronDagger
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronHammer
|
||||
- CP14ModularBladeIronHammer
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronHoe
|
||||
- CP14ModularBladeIronHoe
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronMace
|
||||
- CP14ModularBladeIronMace
|
||||
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeWoodMop
|
||||
- CP14ModularBladeWoodMop
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronPickaxe
|
||||
- CP14ModularBladeIronPickaxe
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularCopperPickaxe
|
||||
@@ -27,4 +27,4 @@
|
||||
color: "#e28f08"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeCopperPickaxe
|
||||
- CP14ModularBladeCopperPickaxe
|
||||
@@ -11,7 +11,7 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronRapier
|
||||
- CP14ModularBladeIronRapier
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularCopperRapier
|
||||
@@ -27,7 +27,7 @@
|
||||
color: "#e28f08"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeCopperRapier
|
||||
- CP14ModularBladeCopperRapier
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularGuildmasterRapier
|
||||
@@ -44,6 +44,6 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronRapier
|
||||
- GardeGuildmaster
|
||||
- CP14ModularBladeIronRapier
|
||||
- CP14ModularGardeGuildmaster
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronShovel
|
||||
- CP14ModularBladeIronShovel
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronSickle
|
||||
- CP14ModularBladeIronSickle
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronSkimitar
|
||||
- CP14ModularBladeIronSkimitar
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularCopperSkimitar
|
||||
@@ -27,7 +27,7 @@
|
||||
color: "#e28f08"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeCopperSkimitar
|
||||
- CP14ModularBladeCopperSkimitar
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularCopperSkimitarTundra
|
||||
@@ -42,8 +42,8 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeCopperSkimitar
|
||||
- InlayQuartzWater
|
||||
- CP14ModularBladeCopperSkimitar
|
||||
- CP14ModularInlayQuartzWater
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularGoldSkimitarAgony
|
||||
@@ -58,5 +58,5 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeGoldSkimitar
|
||||
- InlayQuartzElectric
|
||||
- CP14ModularBladeGoldSkimitar
|
||||
- CP14ModularInlayQuartzElectric
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronSpear
|
||||
- CP14ModularBladeIronSpear
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularIronKunai
|
||||
@@ -26,5 +26,5 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronSpear
|
||||
- CP14ModularBladeIronSpear
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronSword
|
||||
- CP14ModularBladeIronSword
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularCopperSword
|
||||
@@ -27,7 +27,7 @@
|
||||
color: "#e28f08"
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeCopperSword
|
||||
- CP14ModularBladeCopperSword
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularGuardHalberd
|
||||
@@ -44,8 +44,8 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeIronSword
|
||||
- GardeSharpIron
|
||||
- CP14ModularBladeIronSword
|
||||
- CP14ModularGardeSharpIron
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularSkeletonHalberd
|
||||
@@ -60,7 +60,7 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeBoneSword
|
||||
- CP14ModularBladeBoneSword
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularSkeletonSword
|
||||
@@ -75,7 +75,7 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeBoneSword
|
||||
- CP14ModularBladeBoneSword
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularSkeletonHalberdUpgrade
|
||||
@@ -91,8 +91,8 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeBoneSword
|
||||
- GardeSharpIron
|
||||
- CP14ModularBladeBoneSword
|
||||
- CP14ModularGardeSharpIron
|
||||
|
||||
- type: entity
|
||||
id: CP14ModularSkeletonSwordUpgrade
|
||||
@@ -108,6 +108,6 @@
|
||||
state: icon
|
||||
- type: CP14ModularCraftAutoAssemble
|
||||
details:
|
||||
- BladeBoneSword
|
||||
- GardeSharpIron
|
||||
- CP14ModularBladeBoneSword
|
||||
- CP14ModularGardeSharpIron
|
||||
|
||||
|
||||
Reference in New Issue
Block a user