item toggling giga rework + full ninja refactor (#28039)
* item toggle refactoring and some new systems * add ToggleClothing component/system * unhardcode magboots gravity logic * make magboots and speedboots use ItemToggle and stuff * remove now useless clothing components * update client/server magboots systems * add note to use ItemToggledEvent in ToggleActionEvent doc * refactor PowerCellDraw to use ItemToggle for ui open/close control * add TryUseCharges, refactor charges system * update magboot trigger code * make borg use ItemToggle, network SelectedModule instead of now removed Activated * add AccessToggle for borg * the giga ninja refactor * update ninja yml * update ItemToggle usage for some stuff * fix activatableui requires power * random fixing * yaml fixing * nuke ItemToggleDisarmMalus * make defib use ItemToggle * make things that use power not turn on if missing use charge * pro * fix sound prediction * bruh * proximity detector use ItemToggle * oop * big idiot syndrome * fix ninja spawn rule and make it generic * fix ninja spawn rule yml * move loading profiles into AntagLoadProfileRule * more ninja refactor * ninja yml fixes * the dreaded copy paste ops * remove useless NinjaRuleComponent and ue AntagSelection for greeting * fix invisibility * move IsCompleted to SharedObjectivesSystem * ability fixes * oop fix powercell instantly draining itself * sentient speedboots gaming * make reflect use ItemToggle * fix other test * loadprofilerule moved into its own pr * remove conflict with dragon refactor * remove all GenericAntag code from ninja * ) * probably * remove old enabled * great language bravo vince * GREAT LANGUAGE * who made this language * because it stinks * reparent blood-red magboots to magboots probbbly works * most of the review stuff * hasGrav doesnt mean what i thought it did * make health analyzer use itemtoggle, not fail test * fix mag/speed boots being wacky * UNTROLL * add ItemToggle to the random health analyzers * a * remove unused obsolete borg func * untrolling * :trollface: * fix test * fix * g * untroll --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -18,34 +18,32 @@ public abstract class SharedBatteryDrainerSystem : EntitySystem
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancel any drain doafters if the battery is removed or gets filled.
|
||||
/// Cancel any drain doafters if the battery is removed or, on the server, gets filled.
|
||||
/// </summary>
|
||||
protected virtual void OnDoAfterAttempt(EntityUid uid, BatteryDrainerComponent comp, DoAfterAttemptEvent<DrainDoAfterEvent> args)
|
||||
protected virtual void OnDoAfterAttempt(Entity<BatteryDrainerComponent> ent, ref DoAfterAttemptEvent<DrainDoAfterEvent> args)
|
||||
{
|
||||
if (comp.BatteryUid == null)
|
||||
{
|
||||
if (ent.Comp.BatteryUid == null)
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drain power from a power source (on server) and repeat if it succeeded.
|
||||
/// Client will predict always succeeding since power is serverside.
|
||||
/// </summary>
|
||||
private void OnDoAfter(EntityUid uid, BatteryDrainerComponent comp, DrainDoAfterEvent args)
|
||||
private void OnDoAfter(Entity<BatteryDrainerComponent> ent, ref DrainDoAfterEvent args)
|
||||
{
|
||||
if (args.Cancelled || args.Handled || args.Target == null)
|
||||
if (args.Cancelled || args.Handled || args.Target is not {} target)
|
||||
return;
|
||||
|
||||
// repeat if there is still power to drain
|
||||
args.Repeat = TryDrainPower(uid, comp, args.Target.Value);
|
||||
args.Repeat = TryDrainPower(ent, target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to drain as much power as possible into the powercell.
|
||||
/// Client always predicts this as succeeding since power is serverside and it can only fail once, when the powercell is filled or the target is emptied.
|
||||
/// </summary>
|
||||
protected virtual bool TryDrainPower(EntityUid uid, BatteryDrainerComponent comp, EntityUid target)
|
||||
protected virtual bool TryDrainPower(Entity<BatteryDrainerComponent> ent, EntityUid target)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -53,12 +51,13 @@ public abstract class SharedBatteryDrainerSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Sets the battery field on the drainer.
|
||||
/// </summary>
|
||||
public void SetBattery(EntityUid uid, EntityUid? battery, BatteryDrainerComponent? comp = null)
|
||||
public void SetBattery(Entity<BatteryDrainerComponent?> ent, EntityUid? battery)
|
||||
{
|
||||
if (!Resolve(uid, ref comp))
|
||||
if (!Resolve(ent, ref ent.Comp) || ent.Comp.BatteryUid == battery)
|
||||
return;
|
||||
|
||||
comp.BatteryUid = battery;
|
||||
ent.Comp.BatteryUid = battery;
|
||||
Dirty(ent, ent.Comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,4 +65,4 @@ public abstract class SharedBatteryDrainerSystem : EntitySystem
|
||||
/// DoAfter event for <see cref="BatteryDrainerComponent"/>.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class DrainDoAfterEvent : SimpleDoAfterEvent { }
|
||||
public sealed partial class DrainDoAfterEvent : SimpleDoAfterEvent;
|
||||
|
||||
Reference in New Issue
Block a user