Система ключей (#7)
* new Dev map * добавлена генерация узора ключей раундстартом * каменная стена подгон KREKSa фиксы * add verbs to lock comp * more Loc work * some popups, logic to lock and unlock locks * return old Dev * ability to add locks into doors * check to locked lock, to insert or remove locks * doors examine * key can uses directly to door * really lockable! * lockable crates! * Bruh... Really big update * Key sprites, long wall template * KeyRingComponent * lock entity start * lockpicking! * Shiny 1 * Update keys.yml * Отображение только для держащего в руке * Final --------- Co-authored-by: Tornado Tech <54727692+Tornado-Technology@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.CrystallPunk.LockKey;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Doors;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands.Components;
|
||||
@@ -26,6 +28,7 @@ public sealed class LockSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _sharedPopupSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly SharedCPLockKeySystem _lockCP = default!; //CrystallPunk Lock System Adapt
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
@@ -40,6 +43,7 @@ public sealed class LockSystem : EntitySystem
|
||||
SubscribeLocalEvent<LockComponent, GotEmaggedEvent>(OnEmagged);
|
||||
SubscribeLocalEvent<LockComponent, LockDoAfter>(OnDoAfterLock);
|
||||
SubscribeLocalEvent<LockComponent, UnlockDoAfter>(OnDoAfterUnlock);
|
||||
SubscribeLocalEvent<LockComponent, BeforeDoorOpenedEvent>(OnBeforeDoorOpened); //CrystallPunk Lock System Adapt
|
||||
}
|
||||
|
||||
private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args)
|
||||
@@ -52,17 +56,28 @@ public sealed class LockSystem : EntitySystem
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
//CrystallPunk LockSystem Adapt
|
||||
|
||||
// Only attempt an unlock by default on Activate
|
||||
if (lockComp.Locked)
|
||||
{
|
||||
TryUnlock(uid, args.User, lockComp);
|
||||
args.Handled = true;
|
||||
}
|
||||
else if (lockComp.LockOnClick)
|
||||
{
|
||||
TryLock(uid, args.User, lockComp);
|
||||
args.Handled = true;
|
||||
}
|
||||
//if (lockComp.Locked)
|
||||
//{
|
||||
// TryUnlock(uid, args.User, lockComp);
|
||||
// args.Handled = true;
|
||||
//}
|
||||
//else if (lockComp.LockOnClick)
|
||||
//{
|
||||
// TryLock(uid, args.User, lockComp);
|
||||
// args.Handled = true;
|
||||
//}
|
||||
|
||||
//CrystallPunk LockSystem Adapt End
|
||||
}
|
||||
private void OnBeforeDoorOpened(EntityUid uid, LockComponent component, BeforeDoorOpenedEvent args)
|
||||
{
|
||||
if (!component.Locked)
|
||||
return;
|
||||
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnStorageOpenAttempt(EntityUid uid, LockComponent component, ref StorageOpenAttemptEvent args)
|
||||
@@ -78,10 +93,22 @@ public sealed class LockSystem : EntitySystem
|
||||
|
||||
private void OnExamined(EntityUid uid, LockComponent lockComp, ExaminedEvent args)
|
||||
{
|
||||
args.PushText(Loc.GetString(lockComp.Locked
|
||||
? "lock-comp-on-examined-is-locked"
|
||||
: "lock-comp-on-examined-is-unlocked",
|
||||
("entityName", Identity.Name(uid, EntityManager))));
|
||||
//CrystallPunk Lock System Adapt Start
|
||||
if (lockComp.LockSlotId != null && _lockCP.TryGetLockFromSlot(uid, out var lockEnt))
|
||||
{
|
||||
args.PushText(Loc.GetString("cp-lock-examine-lock-slot", ("lock", MetaData(lockEnt.Value).EntityName)));
|
||||
|
||||
args.PushMarkup(Loc.GetString(lockComp.Locked
|
||||
? "lock-comp-on-examined-is-locked"
|
||||
: "lock-comp-on-examined-is-unlocked",
|
||||
("entityName", Identity.Name(uid, EntityManager))));
|
||||
if (lockEnt.Value.Comp.LockpickeddFailMarkup)
|
||||
args.PushMarkup(Loc.GetString("cp-lock-examine-lock-lockpicked", ("lock", MetaData(lockEnt.Value).EntityName)));
|
||||
} else
|
||||
{
|
||||
args.PushText(Loc.GetString("cp-lock-examine-lock-null"));
|
||||
}
|
||||
//CrystallPunk Lock System Adapt End
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -226,20 +253,24 @@ public sealed class LockSystem : EntitySystem
|
||||
|
||||
private void AddToggleLockVerb(EntityUid uid, LockComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || !CanToggleLock(uid, args.User))
|
||||
return;
|
||||
//CrystallPunk Lock System Adapt
|
||||
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Act = component.Locked ?
|
||||
() => TryUnlock(uid, args.User, component) :
|
||||
() => TryLock(uid, args.User, component),
|
||||
Text = Loc.GetString(component.Locked ? "toggle-lock-verb-unlock" : "toggle-lock-verb-lock"),
|
||||
Icon = component.Locked ?
|
||||
new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/unlock.svg.192dpi.png")) :
|
||||
new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/lock.svg.192dpi.png")),
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
//if (!args.CanAccess || !args.CanInteract || !CanToggleLock(uid, args.User))
|
||||
// return;
|
||||
//
|
||||
//AlternativeVerb verb = new()
|
||||
//{
|
||||
// Act = component.Locked ?
|
||||
// () => TryUnlock(uid, args.User, component) :
|
||||
// () => TryLock(uid, args.User, component),
|
||||
// Text = Loc.GetString(component.Locked ? "toggle-lock-verb-unlock" : "toggle-lock-verb-lock"),
|
||||
// Icon = component.Locked ?
|
||||
// new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/unlock.svg.192dpi.png")) :
|
||||
// new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/lock.svg.192dpi.png")),
|
||||
//};
|
||||
//args.Verbs.Add(verb);
|
||||
|
||||
//CrystallPunk Lock System Adapt End
|
||||
}
|
||||
|
||||
private void OnEmagged(EntityUid uid, LockComponent component, ref GotEmaggedEvent args)
|
||||
|
||||
Reference in New Issue
Block a user