From 4f9c6285d43e86a512b67b494661e952bd77f895 Mon Sep 17 00:00:00 2001 From: CaptainSqrBeard Date: Sun, 22 Dec 2024 00:08:34 +0600 Subject: [PATCH 1/5] snowballs --- .../Thresholds/Behaviors/SpillBehavior.cs | 7 +- .../Components/FromTileCrafterComponent.cs | 54 +++++++++++ .../Systems/FromTileCrafterSystem.cs | 89 ++++++++++++++++++ .../ru-RU/_corvaxnext/flavors/flavors.ftl | 1 + .../entities/objects/misc/snowball.ftl | 5 + .../Entities/Structures/Machines/lathe.yml | 1 + .../_CorvaxNext/Entities/Fun/snowball.yml | 78 +++++++++++++++ .../_CorvaxNext/Flavors/flavors.yml | 6 +- .../_CorvaxNext/Recipes/Lathes/Misc.yml | 6 ++ .../Objects/Misc/snowball.rsi/meta.json | 14 +++ .../Objects/Misc/snowball.rsi/snowball.png | Bin 0 -> 361 bytes .../Misc/snowball_maker.rsi/inhand-left.png | Bin 0 -> 344 bytes .../Misc/snowball_maker.rsi/inhand-right.png | Bin 0 -> 349 bytes .../Objects/Misc/snowball_maker.rsi/meta.json | 22 +++++ .../snowball_maker.rsi/snowball-maker.png | Bin 0 -> 420 bytes 15 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 Content.Shared/_CorvaxNext/FromTileCrafter/Components/FromTileCrafterComponent.cs create mode 100644 Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs create mode 100644 Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/misc/snowball.ftl create mode 100644 Resources/Prototypes/_CorvaxNext/Entities/Fun/snowball.yml create mode 100644 Resources/Prototypes/_CorvaxNext/Recipes/Lathes/Misc.yml create mode 100644 Resources/Textures/_CorvaxNext/Objects/Misc/snowball.rsi/meta.json create mode 100644 Resources/Textures/_CorvaxNext/Objects/Misc/snowball.rsi/snowball.png create mode 100644 Resources/Textures/_CorvaxNext/Objects/Misc/snowball_maker.rsi/inhand-left.png create mode 100644 Resources/Textures/_CorvaxNext/Objects/Misc/snowball_maker.rsi/inhand-right.png create mode 100644 Resources/Textures/_CorvaxNext/Objects/Misc/snowball_maker.rsi/meta.json create mode 100644 Resources/Textures/_CorvaxNext/Objects/Misc/snowball_maker.rsi/snowball-maker.png diff --git a/Content.Server/Destructible/Thresholds/Behaviors/SpillBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/SpillBehavior.cs index ff050ce2cda..b229169fcd8 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/SpillBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/SpillBehavior.cs @@ -12,6 +12,11 @@ public sealed partial class SpillBehavior : IThresholdBehavior [DataField] public string? Solution; + // Corvax-Next-Snowballs-Start + [DataField] + public bool SpillSound = true; + // Corvax-Next-Snowballs-End + /// /// If there is a SpillableComponent on EntityUidowner use it to create a puddle/smear. /// Or whatever solution is specified in the behavior itself. @@ -35,7 +40,7 @@ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause else if (Solution != null && solutionContainerSystem.TryGetSolution(owner, Solution, out _, out var behaviorSolution)) { - spillableSystem.TrySplashSpillAt(owner, coordinates, behaviorSolution, out _, user: cause); + spillableSystem.TrySplashSpillAt(owner, coordinates, behaviorSolution, out _, SpillSound, user: cause); // Corvax-Next-Snowballs } } } diff --git a/Content.Shared/_CorvaxNext/FromTileCrafter/Components/FromTileCrafterComponent.cs b/Content.Shared/_CorvaxNext/FromTileCrafter/Components/FromTileCrafterComponent.cs new file mode 100644 index 00000000000..32758637b4c --- /dev/null +++ b/Content.Shared/_CorvaxNext/FromTileCrafter/Components/FromTileCrafterComponent.cs @@ -0,0 +1,54 @@ +using Content.Shared.DoAfter; +using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization; + +namespace Content.Shared._CorvaxNext.FromTileCrafter.Components; + +[RegisterComponent, NetworkedComponent] +public sealed partial class FromTileCrafterComponent : Component +{ + /// + /// Object that will be created + /// + [DataField, ViewVariables(VVAccess.ReadOnly)] + [ValidatePrototypeId] + public string EntityToSpawn; + + /// + /// Tiles that allowed to use to craft an object + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public HashSet AllowedTileIds = new(); + + /// + /// The time it takes to craft. + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float Delay = 1f; +} + +[Serializable, NetSerializable] +public sealed partial class FromTileCraftDoAfterEvent : DoAfterEvent +{ + public NetEntity Grid; + public Vector2i GridTile; + + public FromTileCraftDoAfterEvent(NetEntity grid, Vector2i gridTile) + { + Grid = grid; + GridTile = gridTile; + } + + public override DoAfterEvent Clone() + { + return this; + } + + public override bool IsDuplicate(DoAfterEvent other) + { + return other is FromTileCraftDoAfterEvent otherTile + && Grid == otherTile.Grid + && GridTile == otherTile.GridTile; + } +} diff --git a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs new file mode 100644 index 00000000000..f848e09e92c --- /dev/null +++ b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs @@ -0,0 +1,89 @@ +using System.Numerics; +using Content.Shared._CorvaxNext.FromTileCrafter.Components; +using Content.Shared.DoAfter; +using Content.Shared.Hands.EntitySystems; +using Content.Shared.Interaction; +using Robust.Shared.Map; +using Robust.Shared.Map.Components; +using Robust.Shared.Network; +using Robust.Shared.Random; + + +namespace Content.Shared._CorvaxNext.FromTileCrafter.Systems; + +public sealed class FromTileCrafterSystem : EntitySystem +{ + [Dependency] private readonly SharedHandsSystem _handsSystem = default!; + [Dependency] private readonly SharedMapSystem _maps = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; + [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; + [Dependency] private readonly ITileDefinitionManager _tileDefManager = default!; + [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly INetManager _netManager = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnFromTileCraftComplete); + SubscribeLocalEvent(OnAfterInteract); + } + + private void OnFromTileCraftComplete(Entity ent, ref FromTileCraftDoAfterEvent args) + { + var comp = ent.Comp; + if (args.Handled || args.Cancelled) + return; + + var gridUid = GetEntity(args.Grid); + if (!TryComp(gridUid, out var grid)) + return; + + var mapGrid = Comp(gridUid); + var tileRef = _maps.GetTileRef(gridUid, grid, args.GridTile); + var coords = _maps.ToCoordinates(tileRef, grid); + + var spread = mapGrid.TileSize * 0.1f; + var offset = new Vector2( + _robustRandom.NextFloat() - 0.5f * spread, + _robustRandom.NextFloat() - 0.5f * spread); + + if (!_netManager.IsServer) + return; + + var crafted = Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset)); + _handsSystem.TryPickup(args.User, crafted, checkActionBlocker: false, animate: false); + + } + + private void OnAfterInteract(Entity ent, ref AfterInteractEvent args) + { + if (args.Handled || args.Target != null) + return; + + var comp = ent.Comp; + + if (!_mapManager.TryFindGridAt(_transformSystem.ToMapCoordinates(args.ClickLocation), out var gridUid, out var mapGrid)) + return; + + var tileRef = _maps.GetTileRef(gridUid, mapGrid, args.ClickLocation); + var tileId = _tileDefManager[tileRef.Tile.TypeId].ID; + + if (!comp.AllowedTileIds.Contains(tileId)) + return; + + var coordinates = _maps.GridTileToLocal(gridUid, mapGrid, tileRef.GridIndices); + if (!_interactionSystem.InRangeUnobstructed(args.User, coordinates, popup: false)) + return; + + var doAfterEvent = new FromTileCraftDoAfterEvent(GetNetEntity(gridUid), tileRef.GridIndices); + var doAfterArgs = new DoAfterArgs(EntityManager, args.User, comp.Delay, doAfterEvent, ent, used: ent) + { + BreakOnMove = true, + BlockDuplicate = true, + DuplicateCondition = DuplicateConditions.SameTool, + }; + _doAfterSystem.TryStartDoAfter(doAfterArgs, out _); + } +} diff --git a/Resources/Locale/ru-RU/_corvaxnext/flavors/flavors.ftl b/Resources/Locale/ru-RU/_corvaxnext/flavors/flavors.ftl index d622feb39b3..d0fd7d2f08c 100644 --- a/Resources/Locale/ru-RU/_corvaxnext/flavors/flavors.ftl +++ b/Resources/Locale/ru-RU/_corvaxnext/flavors/flavors.ftl @@ -1,3 +1,4 @@ flavor-complex-bear = как медведь, карты и что-то про футбол flavor-complex-sumer = как лето flavor-complex-holidais = как новый год +flavor-base-snow = как снег diff --git a/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/misc/snowball.ftl b/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/misc/snowball.ftl new file mode 100644 index 00000000000..15b001c6abd --- /dev/null +++ b/Resources/Locale/ru-RU/ss14-ru/prototypes/_corvaxnext/entities/objects/misc/snowball.ftl @@ -0,0 +1,5 @@ +ent-ItemSnowballMaker = снежколеп + .desc = Позволяет быстро лепить снежки из снега (или из астро-снега, когда сезон не тот). + +ent-ItemSnowball = снежок + .desc = Небольшой комочек снега, что можно бросить в кого-то. diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 6b97fa69eb4..097686c3ce8 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -204,6 +204,7 @@ - CassetteTape - TapeRecorder - PlantAnalyzer # Corvax-Next-PlantAnalyzer + - SnowballMaker # Corvax-Next-Snowballs - type: EmagLatheRecipes emagStaticRecipes: - BoxLethalshot diff --git a/Resources/Prototypes/_CorvaxNext/Entities/Fun/snowball.yml b/Resources/Prototypes/_CorvaxNext/Entities/Fun/snowball.yml new file mode 100644 index 00000000000..17e91b1ae73 --- /dev/null +++ b/Resources/Prototypes/_CorvaxNext/Entities/Fun/snowball.yml @@ -0,0 +1,78 @@ +- type: entity + name: snowball maker + parent: BaseItem + id: ItemSnowballMaker + description: Makes snowballs. + components: + - type: Sprite + sprite: _CorvaxNext/Objects/Misc/snowball_maker.rsi + layers: + - state: snowball-maker + - type: Item + - type: PhysicalComposition + materialComposition: + Plastic: 200 + - type: FromTileCrafter + delay: 0.5 + entityToSpawn: ItemSnowball + allowedTileIds: + - FloorAstroSnow + - FloorSnow + - FloorSnowDug + - PlatingSnow + +- type: entity + parent: [BaseItem, FoodBase] + id: ItemSnowball + name: snowball + description: Fun + components: + - type: Damageable + damageContainer: Inorganic + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 1 + behaviors: + - !type:SpillBehavior + solution: snowball + spillSound: False + - !type:PlaySoundBehavior + sound: + path: /Audio/Effects/chop.ogg + - !type:DoActsBehavior + acts: ["Destruction"] + - type: DamageOnLand + damage: + types: + Blunt: 3 + - type: StaminaDamageOnCollide + damage: 8.1 + - type: Sprite + sprite: _CorvaxNext/Objects/Misc/snowball.rsi + state: snowball + - type: Item + size: Tiny + - type: SolutionContainerManager + solutions: + snowball: + maxVol: 10 + reagents: + - ReagentId: Water + Quantity: 5 + - type: FlavorProfile + flavors: + - snow + ignoreReagents: + - Water + - type: Food + solution: snowball + - type: MixableSolution + solution: snowball + - type: InjectableSolution + solution: snowball + - type: RefillableSolution + solution: snowball + - type: LandAtCursor + diff --git a/Resources/Prototypes/_CorvaxNext/Flavors/flavors.yml b/Resources/Prototypes/_CorvaxNext/Flavors/flavors.yml index e0bcca16c71..0b8f7849a7a 100644 --- a/Resources/Prototypes/_CorvaxNext/Flavors/flavors.yml +++ b/Resources/Prototypes/_CorvaxNext/Flavors/flavors.yml @@ -11,4 +11,8 @@ - type: flavor id: holidais flavorType: Complex - description: flavor-complex-holidais \ No newline at end of file + description: flavor-complex-holidais + +- type: flavor + id: snow + description: flavor-base-snow diff --git a/Resources/Prototypes/_CorvaxNext/Recipes/Lathes/Misc.yml b/Resources/Prototypes/_CorvaxNext/Recipes/Lathes/Misc.yml new file mode 100644 index 00000000000..d1f91c10d99 --- /dev/null +++ b/Resources/Prototypes/_CorvaxNext/Recipes/Lathes/Misc.yml @@ -0,0 +1,6 @@ +- type: latheRecipe + id: SnowballMaker + result: ItemSnowballMaker + completetime: 2 + materials: + Plastic: 200 diff --git a/Resources/Textures/_CorvaxNext/Objects/Misc/snowball.rsi/meta.json b/Resources/Textures/_CorvaxNext/Objects/Misc/snowball.rsi/meta.json new file mode 100644 index 00000000000..c1346e58028 --- /dev/null +++ b/Resources/Textures/_CorvaxNext/Objects/Misc/snowball.rsi/meta.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Made by RedTerror (Discord, id 748161739056611428)", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "snowball" + } + ] +} diff --git a/Resources/Textures/_CorvaxNext/Objects/Misc/snowball.rsi/snowball.png b/Resources/Textures/_CorvaxNext/Objects/Misc/snowball.rsi/snowball.png new file mode 100644 index 0000000000000000000000000000000000000000..3dbaa124ed2257d17ebf117434cf2fd6a6df1405 GIT binary patch literal 361 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^ThgKNpD0f^_us^{bd~nbHOyfq2NO!( z+gyIFAE7V)ZRxzbEfa6oTS**PFTTewp~r)D;_pXynI8-7QvaTNbb;Cw>2;@GDu~M6 zYx&;P(xE)j>FVdQ&MBb@ E0FQo^^#A|> literal 0 HcmV?d00001 diff --git a/Resources/Textures/_CorvaxNext/Objects/Misc/snowball_maker.rsi/inhand-left.png b/Resources/Textures/_CorvaxNext/Objects/Misc/snowball_maker.rsi/inhand-left.png new file mode 100644 index 0000000000000000000000000000000000000000..8968f8c0dfc496e7c609653f56b95f5f61f20e39 GIT binary patch literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|et5b#hE&XX zd&`io*?_0@VSwgw1?M!sLyeZ6X>1m3&Q=Q+bSxA)>m7CLfAp@KeVnNqdKrP*fFR&Z zyGHMI|63JTpYm30|8ZN^YI>KxtxL0-%_`S#ic+snB}HsMzVb$gpPZq7ne6Gus~^vO zk>_B4^zq&8e&KJd%8r`9WQ}EBW1JTKt!caKchwJya)sI#Ocx|g{J!|#9=W7uKah~DBW(>eh=%jXWM6FF0<#qCG&E@&&m2T zyj~x_Y3E|hA3ODIU-6kKuUCu29QStF?fiAxl7CU%t!&fO7+Te@7-yvEsRm9r*y!iG_g?CxC#K8Rlxn< iAiuYU*GM$yqTp(!mx>HrH)Hx^Xo-hCTQ(>caT|g$3=&*7RyLRiC(vfCz<5p4?JBo z_1IIU8D|!4?-f><`gBh6{@-PizfS2)efsEbVZ#fpBb)}m&eXBZi(CI$;Q0^Ht+{&| z-cEXZeRbF^)!(1Z?{cmPIKL+D(XSa3Y<&-uotz+gAoKCFuX!tuE$@|fPn*vc80BNX zw|&B;y1QLFlr7%!d}%0I?~MB+>WAPgqm*%gxX0*>gW38ri7wFswz8i;Q z#g?$kui>8cuKH25f^Wk`hSQDre{Oy9nqO?s5-V{7jU`!iMO)WaJFIpH{U;FNx9y>P zWWnt!-#u}1OKlaq(~ecmzR=bDh(Fz^?aKPbkGjCXzopr00Hl@ApigX literal 0 HcmV?d00001 From dca1c920ec2fe4bac2c8632dc1bc79878463b4e1 Mon Sep 17 00:00:00 2001 From: CaptainSqrBeard Date: Sun, 22 Dec 2024 00:15:12 +0600 Subject: [PATCH 2/5] nah --- .../FromTileCrafter/Systems/FromTileCrafterSystem.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs index f848e09e92c..56629a3df6c 100644 --- a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs +++ b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs @@ -50,11 +50,7 @@ private void OnFromTileCraftComplete(Entity ent, ref F _robustRandom.NextFloat() - 0.5f * spread); if (!_netManager.IsServer) - return; - - var crafted = Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset)); - _handsSystem.TryPickup(args.User, crafted, checkActionBlocker: false, animate: false); - + Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset)); } private void OnAfterInteract(Entity ent, ref AfterInteractEvent args) From 8e5e756159837751a31dbdf3935922dc190a968c Mon Sep 17 00:00:00 2001 From: CaptainSqrBeard Date: Sun, 22 Dec 2024 05:14:47 +0600 Subject: [PATCH 3/5] reviewe --- .../FromTileCrafter/Systems/FromTileCrafterSystem.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs index 56629a3df6c..94edee20255 100644 --- a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs +++ b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs @@ -25,7 +25,6 @@ public sealed class FromTileCrafterSystem : EntitySystem public override void Initialize() { - base.Initialize(); SubscribeLocalEvent(OnFromTileCraftComplete); SubscribeLocalEvent(OnAfterInteract); } @@ -40,14 +39,13 @@ private void OnFromTileCraftComplete(Entity ent, ref F if (!TryComp(gridUid, out var grid)) return; - var mapGrid = Comp(gridUid); var tileRef = _maps.GetTileRef(gridUid, grid, args.GridTile); var coords = _maps.ToCoordinates(tileRef, grid); - var spread = mapGrid.TileSize * 0.1f; + var spread = grid.TileSize * 0.1f; var offset = new Vector2( - _robustRandom.NextFloat() - 0.5f * spread, - _robustRandom.NextFloat() - 0.5f * spread); + _robustRandom.NextFloat() * spread - 0.5f, + _robustRandom.NextFloat() * spread - 0.5f); if (!_netManager.IsServer) Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset)); From 1b6cb20c5a3a3fa7880b899716bd725513ae3e20 Mon Sep 17 00:00:00 2001 From: CaptainSqrBeard Date: Sun, 22 Dec 2024 05:56:56 +0600 Subject: [PATCH 4/5] oops + better offset --- .../Components/FromTileCrafterComponent.cs | 6 ++++++ .../FromTileCrafter/Systems/FromTileCrafterSystem.cs | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Content.Shared/_CorvaxNext/FromTileCrafter/Components/FromTileCrafterComponent.cs b/Content.Shared/_CorvaxNext/FromTileCrafter/Components/FromTileCrafterComponent.cs index 32758637b4c..3ee9e19f271 100644 --- a/Content.Shared/_CorvaxNext/FromTileCrafter/Components/FromTileCrafterComponent.cs +++ b/Content.Shared/_CorvaxNext/FromTileCrafter/Components/FromTileCrafterComponent.cs @@ -26,6 +26,12 @@ public sealed partial class FromTileCrafterComponent : Component /// [DataField, ViewVariables(VVAccess.ReadWrite)] public float Delay = 1f; + + /// + /// How far spawned item can offset from tile center + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float Spread = 0.3f; } [Serializable, NetSerializable] diff --git a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs index 94edee20255..d1aa93ecf25 100644 --- a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs +++ b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs @@ -42,12 +42,12 @@ private void OnFromTileCraftComplete(Entity ent, ref F var tileRef = _maps.GetTileRef(gridUid, grid, args.GridTile); var coords = _maps.ToCoordinates(tileRef, grid); - var spread = grid.TileSize * 0.1f; + var spread = comp.Spread * grid.TileSize; var offset = new Vector2( - _robustRandom.NextFloat() * spread - 0.5f, - _robustRandom.NextFloat() * spread - 0.5f); + (_robustRandom.NextFloat() - 0.5f) * spread + grid.TileSize * 0.5f, + (_robustRandom.NextFloat() - 0.5f) * spread + grid.TileSize * 0.5f); - if (!_netManager.IsServer) + if (_netManager.IsServer) Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset)); } From a706e92d5c6d6033254d2a641a31781ed2dfa7ab Mon Sep 17 00:00:00 2001 From: CaptainSqrBeard Date: Sun, 22 Dec 2024 06:29:42 +0600 Subject: [PATCH 5/5] a --- .../Systems/FromTileCrafterSystem.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs index d1aa93ecf25..1fc904daa6a 100644 --- a/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs +++ b/Content.Shared/_CorvaxNext/FromTileCrafter/Systems/FromTileCrafterSystem.cs @@ -31,10 +31,14 @@ public override void Initialize() private void OnFromTileCraftComplete(Entity ent, ref FromTileCraftDoAfterEvent args) { - var comp = ent.Comp; + if (_netManager.IsClient) + return; + if (args.Handled || args.Cancelled) return; + var comp = ent.Comp; + var gridUid = GetEntity(args.Grid); if (!TryComp(gridUid, out var grid)) return; @@ -42,13 +46,11 @@ private void OnFromTileCraftComplete(Entity ent, ref F var tileRef = _maps.GetTileRef(gridUid, grid, args.GridTile); var coords = _maps.ToCoordinates(tileRef, grid); - var spread = comp.Spread * grid.TileSize; var offset = new Vector2( - (_robustRandom.NextFloat() - 0.5f) * spread + grid.TileSize * 0.5f, - (_robustRandom.NextFloat() - 0.5f) * spread + grid.TileSize * 0.5f); + ((_robustRandom.NextFloat() - 0.5f) * comp.Spread + 0.5f) * grid.TileSize, + ((_robustRandom.NextFloat() - 0.5f) * comp.Spread + 0.5f) * grid.TileSize); - if (_netManager.IsServer) - Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset)); + Spawn(ent.Comp.EntityToSpawn, coords.Offset(offset)); } private void OnAfterInteract(Entity ent, ref AfterInteractEvent args)