Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blob #690

Closed
wants to merge 5 commits into from
Closed

Blob #690

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Content.Client/ADT/Blob/BlobTileComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Content.Shared.Blob;

namespace Content.Client.Blob;

[RegisterComponent]
public sealed class BlobTileComponent : SharedBlobTileComponent
{

}
47 changes: 47 additions & 0 deletions Content.Client/ADT/Blob/BlobTileSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Linq;
using Content.Shared.Blob;
using Robust.Client.GameObjects;
using Robust.Shared.GameStates;

namespace Content.Client.Blob;

public sealed class BlobTileSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BlobTileComponent, ComponentHandleState>(OnBlobTileHandleState);
}

private void OnBlobTileHandleState(EntityUid uid, BlobTileComponent component, ref ComponentHandleState args)
{
if (args.Current is not BlobTileComponentState state)
return;

if (component.State == state.State) return;

component.State = state.State;
TryComp<SpriteComponent>(uid, out var sprite);

if (sprite == null)
return;

for (var i = 0; i < sprite.AllLayers.Count(); i++)
{
switch (state.State)
{
case BlobTileState.Dead:
sprite.LayerSetColor(i, Color.White);
break;
case BlobTileState.Blue:
sprite.LayerSetColor(i, Color.Blue);
break;
case BlobTileState.Green:
sprite.LayerSetColor(i, Color.Green);
break;
}
}


}
}
8 changes: 8 additions & 0 deletions Content.Server/ADT/Blob/BlobBorderComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Content.Server.Blob
{
[RegisterComponent]
public sealed class BlobBorderComponent : Component
{

}
}
99 changes: 99 additions & 0 deletions Content.Server/ADT/Blob/BlobCoreComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Robust.Shared.Audio;

namespace Content.Server.Blob;

[RegisterComponent]
public sealed class BlobCoreComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("attackRate")]
public float ActionRate = 0.4f;

[DataField("attackSound")]
public SoundSpecifier AttackSound = new SoundPathSpecifier("/Audio/Animals/Blob/blobattack.ogg");

[ViewVariables(VVAccess.ReadOnly), DataField("damage")]
public DamageSpecifier Damage = new()
{
DamageDict = new Dictionary<string, FixedPoint2>
{
{ "Blunt", 15 },
{ "Structural", 100 },
}
};

[ViewVariables(VVAccess.ReadWrite), DataField("factoryRadiusLimit")]
public float FactoryRadiusLimit = 6f;

[ViewVariables(VVAccess.ReadWrite), DataField("resourceRadiusLimit")]
public float ResourceRadiusLimit = 3f;

[ViewVariables(VVAccess.ReadWrite), DataField("nodeRadiusLimit")]
public float NodeRadiusLimit = 4f;

[ViewVariables(VVAccess.ReadWrite), DataField("attackCost")]
public FixedPoint2 AttackCost = 2;

[ViewVariables(VVAccess.ReadWrite), DataField("factoryBlobCost")]
public FixedPoint2 FactoryBlobCost = 60;

[ViewVariables(VVAccess.ReadWrite), DataField("normalBlobCost")]
public FixedPoint2 NormalBlobCost = 4;

[ViewVariables(VVAccess.ReadWrite), DataField("resourceBlobCost")]
public FixedPoint2 ResourceBlobCost = 40;

[ViewVariables(VVAccess.ReadWrite), DataField("nodeBlobCost")]
public FixedPoint2 NodeBlobCost = 50;

[ViewVariables(VVAccess.ReadWrite), DataField("blobbernautCost")]
public FixedPoint2 BlobbernautCost = 60;

[ViewVariables(VVAccess.ReadWrite), DataField("strongBlobCost")]
public FixedPoint2 StrongBlobCost = 15;

[ViewVariables(VVAccess.ReadWrite), DataField("reflectiveBlobCost")]
public FixedPoint2 ReflectiveBlobCost = 15;

[ViewVariables(VVAccess.ReadWrite), DataField("splitCoreCost")]
public FixedPoint2 SplitCoreCost = 100;

[ViewVariables(VVAccess.ReadWrite), DataField("swapCoreCost")]
public FixedPoint2 SwapCoreCost = 80;

[ViewVariables(VVAccess.ReadWrite), DataField("swapChemCost")]
public FixedPoint2 SwapChemCost = 40;

[ViewVariables(VVAccess.ReadWrite), DataField("reflectiveBlobTile")]
public string ReflectiveBlobTile = "ReflectiveBlobTile";

[ViewVariables(VVAccess.ReadWrite), DataField("strongBlobTile")]
public string StrongBlobTile = "StrongBlobTile";

[ViewVariables(VVAccess.ReadWrite), DataField("normalBlobTile")]
public string NormalBlobTile = "NormalBlobTile";

[ViewVariables(VVAccess.ReadWrite), DataField("factoryBlobTile")]
public string FactoryBlobTile = "FactoryBlobTile";

[ViewVariables(VVAccess.ReadWrite), DataField("resourceBlobTile")]
public string ResourceBlobTile = "ResourceBlobTile";

[ViewVariables(VVAccess.ReadWrite), DataField("nodeBlobTile")]
public string NodeBlobTile = "NodeBlobTile";

[ViewVariables(VVAccess.ReadWrite), DataField("coreBlobTile")]
public string CoreBlobTile = "CoreBlobTile";

[ViewVariables(VVAccess.ReadOnly)]
public EntityUid? Observer = default!;

[ViewVariables(VVAccess.ReadOnly)]
public List<EntityUid> BlobTiles = new();

public TimeSpan NextAction = TimeSpan.Zero;

[ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 Points = 50;
}
92 changes: 92 additions & 0 deletions Content.Server/ADT/Blob/BlobCoreSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using Content.Shared.Alert;
using Content.Shared.Blob;
using Content.Shared.Destructible;
using Content.Shared.FixedPoint;
using Content.Shared.Popups;
using Robust.Shared.Map;

namespace Content.Server.Blob;

public sealed class BlobCoreSystem : EntitySystem
{
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BlobCoreComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<BlobCoreComponent, DestructionEventArgs>(OnDestruction);
}

private void OnStartup(EntityUid uid, BlobCoreComponent observerComponent, ComponentStartup args)
{
ChangeBlobPoint(uid, 0, observerComponent);

if (TryComp<BlobTileComponent>(uid, out var blobTileComponent))
{
blobTileComponent.Core = uid;
}
}

private void OnDestruction(EntityUid uid, BlobCoreComponent component, DestructionEventArgs args)
{
if (component.Observer != null)
{
QueueDel(component.Observer.Value);
}

foreach (var blobTile in component.BlobTiles)
{
if (!TryComp<BlobTileComponent>(blobTile, out var blobTileComponent))
continue;
blobTileComponent.Core = null;

blobTileComponent.State = BlobTileState.Dead;
Dirty(blobTileComponent);
}
}

public bool TransformBlobTile(EntityUid? oldTileUid, EntityUid coreTileUid, string newBlobTileProto, EntityCoordinates coordinates, BlobCoreComponent? blobCore = null)
{
if (!Resolve(coreTileUid, ref blobCore))
return false;
if (oldTileUid != null)
{
QueueDel(oldTileUid.Value);
blobCore.BlobTiles.Remove(oldTileUid.Value);
}
var resourceBlob = EntityManager.SpawnEntity(newBlobTileProto, coordinates);
if (TryComp<BlobTileComponent>(resourceBlob, out var blobTileComponent))
blobTileComponent.Core = coreTileUid;
blobCore.BlobTiles.Add(resourceBlob);
return true;
}

public bool ChangeBlobPoint(EntityUid uid, FixedPoint2 amount, BlobCoreComponent? component = null)
{
if (!Resolve(uid, ref component))
return false;

component.Points += amount;

if (component.Observer != null)
_alerts.ShowAlert(component.Observer.Value, AlertType.BlobResource, (short) Math.Clamp(Math.Round(component.Points.Float() / 10f), 0, 16));

return true;
}

public bool TryUseAbility(EntityUid uid, EntityUid coreUid, BlobCoreComponent component, FixedPoint2 abilityCost)
{
if (component.Points < abilityCost)
{
_popup.PopupEntity(Loc.GetString("blob-not-enough-resources"), uid, uid);
return false;
}

ChangeBlobPoint(coreUid, -abilityCost, component);

return true;
}
}
29 changes: 29 additions & 0 deletions Content.Server/ADT/Blob/BlobFactoryComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Content.Server.Blob;

[RegisterComponent]
public sealed class BlobFactoryComponent : Component
{
[ViewVariables(VVAccess.ReadOnly)]
public float SpawnedCount = 0;

[DataField("spawnLimit"), ViewVariables(VVAccess.ReadWrite)]
public float SpawnLimit = 3;

[DataField("spawnRate"), ViewVariables(VVAccess.ReadWrite)]
public float SpawnRate = 10;

[DataField("blobSporeId"), ViewVariables(VVAccess.ReadWrite)]
public string Pod = "MobBlobPod";

[DataField("blobbernautId"), ViewVariables(VVAccess.ReadWrite)]
public string BlobbernautId = "MobBlobBlobbernaut";

[ViewVariables(VVAccess.ReadOnly)]
public EntityUid? Blobbernaut = default!;

public TimeSpan NextSpawn = TimeSpan.Zero;
}

public sealed class ProduceBlobbernautEvent : EntityEventArgs
{
}
65 changes: 65 additions & 0 deletions Content.Server/ADT/Blob/BlobFactorySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using Content.Shared.Destructible;
using Robust.Shared.Timing;

namespace Content.Server.Blob;

public sealed class BlobFactorySystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BlobFactoryComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<BlobFactoryComponent, BlobTileGetPulseEvent>(OnPulsed);
SubscribeLocalEvent<BlobFactoryComponent, ProduceBlobbernautEvent>(OnProduceBlobbernaut);
SubscribeLocalEvent<BlobFactoryComponent, DestructionEventArgs>(OnDestruction);
}

private void OnStartup(EntityUid uid, BlobFactoryComponent observerComponent, ComponentStartup args)
{

}

private void OnDestruction(EntityUid uid, BlobFactoryComponent component, DestructionEventArgs args)
{
if (TryComp<BlobbernautComponent>(component.Blobbernaut, out var blobbernautComponent))
{
blobbernautComponent.Factory = null;
}
}

private void OnProduceBlobbernaut(EntityUid uid, BlobFactoryComponent component, ProduceBlobbernautEvent args)
{
if (component.Blobbernaut != null)
return;

var xform = Transform(uid);

var blobbernaut = Spawn(component.BlobbernautId, xform.Coordinates);

component.Blobbernaut = blobbernaut;
if (TryComp<BlobbernautComponent>(blobbernaut, out var blobbernautComponent))
{
blobbernautComponent.Factory = uid;
}
}

private void OnPulsed(EntityUid uid, BlobFactoryComponent component, BlobTileGetPulseEvent args)
{
if (!TryComp<BlobTileComponent>(uid, out var blobTileComponent) || blobTileComponent.Core == null)
return;
if (component.SpawnedCount >= component.SpawnLimit)
return;

if (_gameTiming.CurTime < component.NextSpawn)
return;

var xform = Transform(uid);
Spawn(component.Pod, xform.Coordinates);
component.SpawnedCount += 1;
component.NextSpawn = _gameTiming.CurTime + TimeSpan.FromSeconds(component.SpawnRate);
}

}
21 changes: 21 additions & 0 deletions Content.Server/ADT/Blob/BlobMobComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Content.Shared.Damage;

namespace Content.Server.Blob;

[RegisterComponent]
public sealed class BlobMobComponent : Component
{
[ViewVariables(VVAccess.ReadOnly), DataField("healthOfPulse")]
public DamageSpecifier HealthOfPulse = new()
{
DamageDict = new ()
{
{ "Blunt", -2 },
{ "Slash", -2 },
{ "Piercing", -2 },
{ "Heat", -2 },
{ "Cold", -2 },
{ "Shock", -2 },
}
};
}
Loading
Loading