]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Nuke spaceshroom ore (#28110)
authorEd <96445749+TheShuEd@users.noreply.github.com>
Sat, 18 May 2024 16:17:46 +0000 (19:17 +0300)
committerGitHub <noreply@github.com>
Sat, 18 May 2024 16:17:46 +0000 (12:17 -0400)
nuke spaceshroom ore

Content.Server/Gatherable/Components/GatherableComponent.cs
Content.Server/Gatherable/GatherableSystem.Projectile.cs
Content.Server/Gatherable/GatherableSystem.cs
Resources/Prototypes/Entities/Objects/Misc/spaceshroom.yml
Resources/Prototypes/Entities/Structures/Walls/asteroid.yml
Resources/Prototypes/ore.yml

index f1d0c6ef74d09e72be9d6bf859d43be77d208e26..5480f4404fc2798426b470078f78856840e316b1 100644 (file)
@@ -1,4 +1,6 @@
+using Content.Shared.EntityList;
 using Content.Shared.Whitelist;
+using Robust.Shared.Prototypes;
 
 namespace Content.Server.Gatherable.Components;
 
@@ -10,7 +12,7 @@ public sealed partial class GatherableComponent : Component
     ///     Whitelist for specifying the kind of tools can be used on a resource
     ///     Supports multiple tags.
     /// </summary>
-    [DataField("whitelist", required: true)]
+    [DataField(required: true)]
     public EntityWhitelist? ToolWhitelist;
 
     /// <summary>
@@ -18,14 +20,20 @@ public sealed partial class GatherableComponent : Component
     ///     (Tag1, Tag2, LootTableID1, LootTableID2 are placeholders for example)
     ///     --------------------
     ///     useMappedLoot: true
-    ///     whitelist:
+    ///     toolWhitelist:
     ///       tags:
     ///        - Tag1
     ///        - Tag2
-    ///     mappedLoot:
+    ///     loot:
     ///       Tag1: LootTableID1
     ///       Tag2: LootTableID2
     /// </summary>
-    [DataField("loot")]
-    public Dictionary<string, string>? MappedLoot = new();
+    [DataField]
+    public Dictionary<string, ProtoId<EntityLootTablePrototype>>? Loot = new();
+
+    /// <summary>
+    /// Random shift of the appearing entity during gathering
+    /// </summary>
+    [DataField]
+    public float GatherOffset = 0.3f;
 }
index f773ca2dbb9ee3f8fa3f976270cf1928593803d1..3ab8872fd7d27b9254cf2b860ce5e0969cabdec0 100644 (file)
@@ -1,7 +1,5 @@
 using Content.Server.Gatherable.Components;
-using Content.Server.Projectiles;
 using Content.Shared.Projectiles;
-using Content.Shared.Weapons.Ranged.Systems;
 using Robust.Shared.Physics.Events;
 
 namespace Content.Server.Gatherable;
@@ -13,20 +11,20 @@ public sealed partial class GatherableSystem
         SubscribeLocalEvent<GatheringProjectileComponent, StartCollideEvent>(OnProjectileCollide);
     }
 
-    private void OnProjectileCollide(EntityUid uid, GatheringProjectileComponent component, ref StartCollideEvent args)
+    private void OnProjectileCollide(Entity<GatheringProjectileComponent> gathering, ref StartCollideEvent args)
     {
         if (!args.OtherFixture.Hard ||
             args.OurFixtureId != SharedProjectileSystem.ProjectileFixture ||
-            component.Amount <= 0 ||
+            gathering.Comp.Amount <= 0 ||
             !TryComp<GatherableComponent>(args.OtherEntity, out var gatherable))
         {
             return;
         }
 
-        Gather(args.OtherEntity, uid, gatherable);
-        component.Amount--;
+        Gather(args.OtherEntity, gathering, gatherable);
+        gathering.Comp.Amount--;
 
-        if (component.Amount <= 0)
-            QueueDel(uid);
+        if (gathering.Comp.Amount <= 0)
+            QueueDel(gathering);
     }
 }
index 11295bb3a35c0e02d115af6e2c672066943d0c1b..44e60cb102a1e08552c9908be9cc3f8479282aa9 100644 (file)
@@ -1,11 +1,9 @@
 using Content.Server.Destructible;
 using Content.Server.Gatherable.Components;
-using Content.Shared.EntityList;
 using Content.Shared.Interaction;
 using Content.Shared.Tag;
 using Content.Shared.Weapons.Melee.Events;
 using Robust.Server.GameObjects;
-using Robust.Shared.Audio;
 using Robust.Shared.Audio.Systems;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
@@ -14,7 +12,7 @@ namespace Content.Server.Gatherable;
 
 public sealed partial class GatherableSystem : EntitySystem
 {
-    [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+    [Dependency] private readonly IPrototypeManager _proto = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly DestructibleSystem _destructible = default!;
     [Dependency] private readonly SharedAudioSystem _audio = default!;
@@ -30,20 +28,20 @@ public sealed partial class GatherableSystem : EntitySystem
         InitializeProjectile();
     }
 
-    private void OnAttacked(EntityUid uid, GatherableComponent component, AttackedEvent args)
+    private void OnAttacked(Entity<GatherableComponent> gatherable, ref AttackedEvent args)
     {
-        if (component.ToolWhitelist?.IsValid(args.Used, EntityManager) != true)
+        if (gatherable.Comp.ToolWhitelist?.IsValid(args.Used, EntityManager) != true)
             return;
 
-        Gather(uid, args.User, component);
+        Gather(gatherable, args.User);
     }
 
-    private void OnActivate(EntityUid uid, GatherableComponent component, ActivateInWorldEvent args)
+    private void OnActivate(Entity<GatherableComponent> gatherable, ref ActivateInWorldEvent args)
     {
-        if (component.ToolWhitelist?.IsValid(args.User, EntityManager) != true)
+        if (gatherable.Comp.ToolWhitelist?.IsValid(args.User, EntityManager) != true)
             return;
 
-        Gather(uid, args.User, component);
+        Gather(gatherable, args.User);
     }
 
     public void Gather(EntityUid gatheredUid, EntityUid? gatherer = null, GatherableComponent? component = null)
@@ -60,25 +58,22 @@ public sealed partial class GatherableSystem : EntitySystem
         _destructible.DestroyEntity(gatheredUid);
 
         // Spawn the loot!
-        if (component.MappedLoot == null)
+        if (component.Loot == null)
             return;
 
         var pos = _transform.GetMapCoordinates(gatheredUid);
 
-        foreach (var (tag, table) in component.MappedLoot)
+        foreach (var (tag, table) in component.Loot)
         {
             if (tag != "All")
             {
                 if (gatherer != null && !_tagSystem.HasTag(gatherer.Value, tag))
                     continue;
             }
-            var getLoot = _prototypeManager.Index<EntityLootTablePrototype>(table);
+            var getLoot = _proto.Index(table);
             var spawnLoot = getLoot.GetSpawns(_random);
-            var spawnPos = pos.Offset(_random.NextVector2(0.3f));
+            var spawnPos = pos.Offset(_random.NextVector2(component.GatherOffset));
             Spawn(spawnLoot[0], spawnPos);
         }
     }
 }
-
-
-
index 9ec6ce0ed11e55641e81171369f516286020d41a..157178771579cf7accd9095bff7cf8a3b9338122 100644 (file)
             !type:PhysShapeCircle
             radius: 0.2
     - type: InteractionOutline
-    # TODO: Nuke this shit
-    - type: OreVein
-      oreChance: 1.0
-      currentOre: SpaceShrooms
     - type: Gatherable
-      whitelist:
+      toolWhitelist:
         components:
           - Hands
+      loot:
+        All: SpaceshroomGather
     - type: Damageable
       damageContainer: Inorganic
       damageModifierSet: Wood
             - !type:DoActsBehavior
               acts: [ "Destruction" ]
 
+- type: entityLootTable
+  id: SpaceshroomGather
+  entries:
+  - id: FoodSpaceshroom
+    amount: 1
+    maxAmount: 1
+
 - type: entity
   name: spaceshroom
   parent: FoodProduceBase
index a8cb0b1cb8a2f108dcac47ce372d357555dd9309..c6c3692e598720ab6ab32557a84ffaa8aaaed38c 100644 (file)
       noRot: true
     - type: SoundOnGather
     - type: Gatherable
-      whitelist:
+      toolWhitelist:
         tags:
           - Pickaxe
     - type: Damageable
index dde1516c8552588f713f6902fcf4eacc50b74c84..84d1c667369476d5aa4c705efc3ca6eb6ab23b06 100644 (file)
@@ -1,9 +1,5 @@
 # TODO: Kill ore veins
 # Split it into 2 components, 1 for "spawn XYZ on destruction" and 1 for "randomly select one of these for spawn on destruction"
-# You could even just use an entityspawncollection instead.
-- type: ore
-  id: SpaceShrooms
-  oreEntity: FoodSpaceshroom
 
 # High yields
 - type: ore