Skip to content

Commit

Permalink
Планетарная тюрьма (#187)
Browse files Browse the repository at this point in the history
* Тюрьма (#150)

* Prison Init

* Новая карта для планетарных тюрем

* Готовая планетарная тюрьма

* Незначительное изменение тайлов

---------

Co-authored-by: Vigers Ray <[email protected]>

* Космическая тюрьма и всё остальное говно

* фиксы

* фикс PrisonlDoctor

* фикс PrisonDoctor

* день длится 20 минут

---------

Co-authored-by: SplikZerys <[email protected]>
  • Loading branch information
VigersRay and SplikZerys authored Jul 12, 2024
1 parent 501bb8c commit ffd3e3d
Show file tree
Hide file tree
Showing 241 changed files with 367,217 additions and 99 deletions.
9 changes: 9 additions & 0 deletions Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ private ValueList<Vector2> GetMapObject(Vector2 localPos, Angle angle, float sca

private bool TryGetBeacon(IEnumerable<IMapObject> mapObjects, Matrix3x2 mapTransform, Vector2 mousePos, UIBox2i area, out ShuttleBeaconObject foundBeacon, out Vector2 foundLocalPos)
{
Logger.Info("TryGetBeacon");

// In pixels
const float BeaconSnapRange = 32f;
float nearestValue = float.MaxValue;
Expand All @@ -579,21 +581,28 @@ private bool TryGetBeacon(IEnumerable<IMapObject> mapObjects, Matrix3x2 mapTrans
if (!_shuttles.CanFTLBeacon(beaconObj.Coordinates))
continue;

Logger.Info("Can FTL Beacon");

var position = Vector2.Transform(beaconCoords.Position, mapTransform);
var localPos = ScalePosition(position with {Y = -position.Y});

// If beacon not on screen then ignore it.
if (!area.Contains(localPos.Floored()))
continue;

Logger.Info("area contains localPos.Floored()");

var distance = (localPos - mousePos).Length();

if (distance > BeaconSnapRange * UIScale ||
distance > nearestValue)
{
Logger.Info("distance > BeaconSnapRange");
continue;
}

Logger.Info("Found beacon");

foundLocalPos = localPos;
nearestValue = distance;
foundBeacon = beaconObj;
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Roles/RoleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Content.Server._Sunrise.Fugitive;
using Content.Server._Sunrise.PlanetPrison;
using Content.Shared.Roles;

namespace Content.Server.Roles;
Expand All @@ -18,6 +20,10 @@ public override void Initialize()
SubscribeAntagEvents<TraitorRoleComponent>();
SubscribeAntagEvents<ZombieRoleComponent>();
SubscribeAntagEvents<ThiefRoleComponent>();
// Sunrise-start
SubscribeAntagEvents<FugitiveRoleComponent>();
SubscribeAntagEvents<PlanetPrisonerRoleComponent>();
// Sunrise-end
}

public string? MindGetBriefing(EntityUid? mindId)
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Shuttles/Components/FTLBeaconComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ namespace Content.Server.Shuttles.Components;
[RegisterComponent]
public sealed partial class FTLBeaconComponent : Component
{

[DataField]
public bool BlockRotate;
}
8 changes: 8 additions & 0 deletions Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ private void OnBeaconFTLMessage(Entity<ShuttleConsoleComponent> ent, ref Shuttle
return;
}

// Sunrise-Start
if (!TryComp<FTLBeaconComponent>(beaconEnt, out var beaconComponent))
return;
var angle = args.Angle.Reduced();
if (beaconComponent.BlockRotate)
{
angle = Angle.Zero;
}
// Sunrise-End
var targetCoordinates = new EntityCoordinates(targetXform.MapUid!.Value, _transform.GetWorldPosition(targetXform));

ConsoleFTL(ent, targetCoordinates, angle, targetXform.MapID);
Expand Down
17 changes: 17 additions & 0 deletions Content.Server/_Sunrise/Fugitive/FugitiveComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Robust.Shared.Audio;

namespace Content.Server._Sunrise.Fugitive
{
[RegisterComponent]
public sealed partial class FugitiveComponent : Component
{
[DataField("spawnSound")]
public SoundSpecifier SpawnSoundPath = new SoundPathSpecifier("/Audio/Effects/clang.ogg");

[DataField("firstMindAdded")]
public bool FirstMindAdded = false;

[DataField("roundStart")]
public bool RoundStart = false;
}
}
11 changes: 11 additions & 0 deletions Content.Server/_Sunrise/Fugitive/FugitiveCountdownComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Content.Server._Sunrise.Fugitive
{
[RegisterComponent]
public sealed partial class FugitiveCountdownComponent : Component
{
public TimeSpan? AnnounceTime = null;

[DataField("AnnounceCD")]
public TimeSpan AnnounceCD = TimeSpan.FromMinutes(5);
}
}
9 changes: 9 additions & 0 deletions Content.Server/_Sunrise/Fugitive/FugitiveRoleComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Content.Shared.Roles;

namespace Content.Server._Sunrise.Fugitive;

[RegisterComponent]
public sealed partial class FugitiveRoleComponent : AntagonistRoleComponent
{

}
7 changes: 7 additions & 0 deletions Content.Server/_Sunrise/Fugitive/FugitiveRuleComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Server._Sunrise.Fugitive;

[RegisterComponent, Access(typeof(FugitiveSystem))]
public sealed partial class FugitiveRuleComponent : Component
{
public List<(EntityUid, string)> FugitiveMinds = new();
}
101 changes: 101 additions & 0 deletions Content.Server/_Sunrise/Fugitive/FugitiveSpawner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using Content.Server.Mind;
using Content.Server.Popups;
using Content.Server.Store.Systems;
using Content.Server.Stunnable;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Implants;
using Content.Shared.Implants.Components;
using Content.Shared.Maps;
using Content.Shared.Store.Components;
using Content.Shared.Tag;
using Robust.Server.Audio;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using static Content.Shared.Examine.ExamineSystemShared;

namespace Content.Server._Sunrise.Fugitive
{
public sealed class FugitiveSpawnerSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly AudioSystem _audioSystem = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly TileSystem _tile = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
[Dependency] private readonly StoreSystem _store = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedSubdermalImplantSystem _subdermalImplant = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FugitiveSpawnerComponent, PlayerAttachedEvent>(OnPlayerAttached);
}

private void OnPlayerAttached(EntityUid uid, FugitiveSpawnerComponent component, PlayerAttachedEvent args)
{
var xform = Transform(uid);
var fugitive = Spawn(component.Prototype, xform.Coordinates);

if (TryComp<_Sunrise.Fugitive.FugitiveCountdownComponent>(fugitive, out var cd))
cd.AnnounceTime = _timing.CurTime + cd.AnnounceCD;

_popupSystem.PopupEntity(Loc.GetString("fugitive-spawn", ("name", fugitive)), fugitive,
Filter.Pvs(fugitive).RemoveWhereAttachedEntity(entity => !_examine.InRangeUnOccluded(
fugitive, entity, ExamineRange, null)), true,
Shared.Popups.PopupType.LargeCaution);

_stun.TryParalyze(fugitive, TimeSpan.FromSeconds(2), false);
_audioSystem.PlayPvs(component.SpawnSoundPath, uid, AudioParams.Default.WithVolume(-6f));

if (!_mapManager.TryGetGrid(xform.GridUid, out var map))
return;
var currentTile = map.GetTileRef(xform.Coordinates);
_tile.PryTile(currentTile);

if (!_mindSystem.TryGetMind(args.Player.UserId, out var mindId, out var mind))
return;

_mindSystem.TransferTo(mindId.Value, fugitive, ghostCheckOverride: true);

_popupSystem.PopupEntity(Loc.GetString("fugitive-spawn", ("name", uid)), uid,
Filter.Pvs(uid).RemoveWhereAttachedEntity(entity => !_examine.InRangeUnOccluded(uid, entity, ExamineRange, null)), true, Shared.Popups.PopupType.LargeCaution);

foreach (var implantId in component.Implants)
{
var implantEnt = Spawn(implantId, xform.Coordinates);

if (!TryComp<SubdermalImplantComponent>(implantEnt, out var implantComp))
return;

_subdermalImplant.ForceImplant(fugitive, implantEnt, implantComp);
}

if (TryComp<ContainerManagerComponent>(fugitive, out var containerManagerComponent))
{
if (containerManagerComponent.Containers.TryGetValue("implant", out var container))
{
foreach (var containedEntity in container.ContainedEntities)
{
if (!TryComp<StoreComponent>(containedEntity, out var storeComponent))
continue;
_tagSystem.AddTag(containedEntity, "FugitiveUplink");
_store.TryAddCurrency(new Dictionary<string, FixedPoint2>
{ {"Telecrystal", _random.Next(5, 10)} }, containedEntity, storeComponent);
}
}
}

Del(uid);
}
}
}
19 changes: 19 additions & 0 deletions Content.Server/_Sunrise/Fugitive/FugitiveSpawnerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server._Sunrise.Fugitive
{
[RegisterComponent]
public sealed partial class FugitiveSpawnerComponent : Component
{
[DataField("spawnSound")]
public SoundSpecifier SpawnSoundPath = new SoundPathSpecifier("/Audio/Effects/clang.ogg");

[ViewVariables(VVAccess.ReadWrite),
DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string Prototype = "MobHumanFugitive";

public List<string> Implants = new() { "UplinkImplant", "FreedomImplant"};
}
}
Loading

0 comments on commit ffd3e3d

Please sign in to comment.