Spiders Buff and critters change (#13377)
This commit is contained in:
77
Content.Server/Spider/SpiderSystem.cs
Normal file
77
Content.Server/Spider/SpiderSystem.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Spider;
|
||||
using Content.Shared.Maps;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Spider;
|
||||
|
||||
public sealed class SpiderSystem : SharedSpiderSystem
|
||||
{
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SpiderComponent, SpiderWebActionEvent>(OnSpawnNet);
|
||||
}
|
||||
|
||||
private void OnSpawnNet(EntityUid uid, SpiderComponent component, SpiderWebActionEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
var transform = Transform(uid);
|
||||
|
||||
if (transform.GridUid == null)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("spider-web-action-nogrid"), args.Performer, args.Performer);
|
||||
return;
|
||||
}
|
||||
|
||||
var coords = transform.Coordinates;
|
||||
|
||||
// TODO generic way to get certain coordinates
|
||||
|
||||
var result = false;
|
||||
// Spawn web in center
|
||||
if (!IsTileBlockedByWeb(coords))
|
||||
{
|
||||
Spawn(component.WebPrototype, coords);
|
||||
result = true;
|
||||
}
|
||||
|
||||
// Spawn web in other directions
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
var direction = (DirectionFlag) (1 << i);
|
||||
coords = transform.Coordinates.Offset(direction.AsDir().ToVec());
|
||||
|
||||
if (!IsTileBlockedByWeb(coords))
|
||||
{
|
||||
Spawn(component.WebPrototype, coords);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("spider-web-action-success"), args.Performer, args.Performer);
|
||||
args.Handled = true;
|
||||
}
|
||||
else
|
||||
_popup.PopupEntity(Loc.GetString("spider-web-action-fail"), args.Performer, args.Performer);
|
||||
}
|
||||
|
||||
private bool IsTileBlockedByWeb(EntityCoordinates coords)
|
||||
{
|
||||
foreach (var entity in coords.GetEntitiesInTile())
|
||||
{
|
||||
if (HasComp<SpiderWebObjectComponent>(entity))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
32
Content.Server/StationEvents/Events/SpiderSpawn.cs
Normal file
32
Content.Server/StationEvents/Events/SpiderSpawn.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Random;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Server.StationEvents.Events;
|
||||
|
||||
public sealed class SpiderSpawn : StationEventSystem
|
||||
{
|
||||
public override string Prototype => "SpiderSpawn";
|
||||
|
||||
public override void Started()
|
||||
{
|
||||
base.Started();
|
||||
var spawnLocations = EntityManager.EntityQuery<VentCritterSpawnLocationComponent>().ToList();
|
||||
RobustRandom.Shuffle(spawnLocations);
|
||||
|
||||
var mod = Math.Sqrt(GetSeverityModifier());
|
||||
|
||||
var spawnAmount = (int) (RobustRandom.Next(4, 8) * mod);
|
||||
Sawmill.Info($"Spawning {spawnAmount} of spiders");
|
||||
foreach (var location in spawnLocations)
|
||||
{
|
||||
if (spawnAmount-- == 0)
|
||||
break;
|
||||
|
||||
var coords = EntityManager.GetComponent<TransformComponent>(location.Owner);
|
||||
|
||||
EntityManager.SpawnEntity("MobGiantSpiderAngry", coords.Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Random;
|
||||
using System.Linq;
|
||||
|
||||
@@ -7,7 +8,7 @@ namespace Content.Server.StationEvents.Events;
|
||||
public sealed class VentCritters : StationEventSystem
|
||||
{
|
||||
public static List<string> SpawnedPrototypeChoices = new List<string>()
|
||||
{"MobGiantSpiderAngry", "MobMouse", "MobMouse1", "MobMouse2"};
|
||||
{"MobMouse", "MobMouse1", "MobMouse2"};
|
||||
|
||||
public override string Prototype => "VentCritters";
|
||||
|
||||
@@ -18,9 +19,7 @@ public sealed class VentCritters : StationEventSystem
|
||||
var spawnLocations = EntityManager.EntityQuery<VentCritterSpawnLocationComponent>().ToList();
|
||||
RobustRandom.Shuffle(spawnLocations);
|
||||
|
||||
var mod = Math.Sqrt(GetSeverityModifier());
|
||||
|
||||
var spawnAmount = (int) (RobustRandom.Next(4, 12) * mod); // A small colony of critters.
|
||||
var spawnAmount = (int) (RobustRandom.Next(4, 12)); // A small colony of critters.
|
||||
Sawmill.Info($"Spawning {spawnAmount} of {spawnChoice}");
|
||||
foreach (var location in spawnLocations)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user