mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 16:17:27 +00:00
* Nubody (#42419) * Nubody * fix test fails * gibbing * lung test returns * doc comment * hand organ test * giblet test * yaml formatting * returning * relocate * trimming * re-smite * oops thusd tweak * arachnids have slower metabolism i guess * never mind the old behaviour is bad actually * rider whyyy * style changes and allat * fix collision --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * C# files done * Visual nubody (humanoid appearance refactor) (#42476) * initial visual nubody * oops overlay * im so pheeming rn * conversion... * tests * comeback of the underwear * oops eyes * blabbl * zeds * yaml linted * search and visible count constraints * reordering * preserve previously selected markings colors * fix test * some ui niceties * ordering * make DB changes backwards-compatible/downgrade-friendly * fix things again * fix migration * vulpkanin markings limit increase * wrapping * code cleanup and more code cleanup and more code cleanup and more code cleanup and * fix slop ports * better sampling API * make filter work + use the method i made for its intended purpose * fix test fails real quick * magic mirror cleanup, remove TODO * don't 0-init the organ profile data * remove deltastates --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Let vox eat trash again (#42503) * C# complete port * Getting closer * Harpy Nubody Port * Port Feroxi, Kitsune. Fix some yml typos and remove ipcs stuff * Port Oni * Port Rest, except Motorkind * Port Motorkind * Remove more surgery, restore too much deleted stuff * Fix Typos and change some organ names. Need to split eyes next * Harpy HAve Wings again * Some fixes, More Surgeyr Removal, Copying of eye organs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use correct Body imports * Markings Refactoring, Harpy Layering * Motorkind doesn't crash anymore. Some layer remappings. * Allow Organs to have Markings Displacements again. (#43604) * first shtep * readd markings support --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix STalk eyes and several layerings * Fix sexed organs (#42554) * Fix markings for several species, fit them for sexed organs and rename some files to fit them for it * Additional IPC-related removals * Vulpkanin eyes are now correct again * Fix Subtle Cultist Marks on species * Fix Asakim Sprites (sexed) and make CD imports work * Migration, error fixes, and Height * Fix humanoid profile voice being broken (#42550) Fix humanoid appearance voice being broken * Change Kitsune SexChanged Event to with ref * Fix asakim issue, Respirator fix * Simplify hands UI code (#42534) * Simplify hands UI code * i remembered about SortedHands in the component * minor cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Set size of Analyzer back to 350, Kitsune can't gib themselves no more. Migration * yml linter errors and an rudimentary onAdd Organ Functionality * Fixing it trying to remove nothing * midpoint migration * Why do you put so many organs everywhere * More missing prototypes * Migration of more organs * Forgot lungs * Move character preview handling into a specialized control (#41252) * Move character preview handling into a specialized control Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> * Restore job name that I accidentally removed from character picker buttons * Just resolve dependencies the standard way --------- Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Janet Blackquill <uhhadd@gmail.com> * Drop ICharacterProfile/ICharacterAppearance interfaces (#42661) * Ensure profile loading only returns valid species (#42842) (Stable merge) (#42865) Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> * Changes to make it work for us. * No more bald Harpy * OperatingTables instead of null * Adding Delta V Comments, commenting out instead of deleting * Fix broken Height Scale. * Remove HumanoidSilicon Mention * Did an error. Readded, uncommented. * Clean up Marking data structure, add tests for Zombie transformation (#42756) * Clean up Marking data structure, add tests for Zombie transformation * empty * AAAAAAAAAAAAAAAA --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix markings colour setting (#42771) * Fix: Markings Color For Downstream * Comment out A Leg. Remove Todo * Revert to original hidden species code --------- Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Co-authored-by: Absotively <jen@jenpollock.ca> Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Myra <vasilis@pikachu.systems>
134 lines
5.7 KiB
C#
134 lines
5.7 KiB
C#
using Content.Shared.Database;
|
|
using Content.Shared.Mobs.Components;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Shared.Mobs.Systems;
|
|
|
|
public partial class MobStateSystem
|
|
{
|
|
#region Public API
|
|
|
|
/// <summary>
|
|
/// Check if an Entity can be set to a particular MobState
|
|
/// </summary>
|
|
/// <param name="entity">Target Entity</param>
|
|
/// <param name="mobState">MobState to check</param>
|
|
/// <param name="component">MobState Component owned by the target</param>
|
|
/// <returns>If the entity can be set to that MobState</returns>
|
|
public bool HasState(EntityUid entity, MobState mobState, MobStateComponent? component = null)
|
|
{
|
|
return _mobStateQuery.Resolve(entity, ref component, false) &&
|
|
component.AllowedStates.Contains(mobState);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Run a MobState update check. This will trigger update events if the state has been changed.
|
|
/// </summary>
|
|
/// <param name="entity">Target Entity we want to change the MobState of</param>
|
|
/// <param name="component">MobState Component attached to the entity</param>
|
|
/// <param name="origin">Entity that caused the state update (if applicable)</param>
|
|
public void UpdateMobState(EntityUid entity, MobStateComponent? component = null, EntityUid? origin = null)
|
|
{
|
|
if (!_mobStateQuery.Resolve(entity, ref component))
|
|
return;
|
|
|
|
var ev = new UpdateMobStateEvent {Target = entity, Component = component, Origin = origin};
|
|
RaiseLocalEvent(entity, ref ev);
|
|
ChangeState(entity, component, ev.State, origin: origin);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Change the MobState without triggering UpdateMobState events.
|
|
/// WARNING: use this sparingly when you need to override other systems (MobThresholds)
|
|
/// </summary>
|
|
/// <param name="entity">Target Entity we want to change the MobState of</param>
|
|
/// <param name="mobState">The new MobState we want to set</param>
|
|
/// <param name="component">MobState Component attached to the entity</param>
|
|
/// <param name="origin">Entity that caused the state update (if applicable)</param>
|
|
public void ChangeMobState(EntityUid entity, MobState mobState, MobStateComponent? component = null,
|
|
EntityUid? origin = null)
|
|
{
|
|
if (!_mobStateQuery.Resolve(entity, ref component))
|
|
return;
|
|
|
|
ChangeState(entity, component, mobState, origin: origin);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Virtual API
|
|
|
|
/// <summary>
|
|
/// Called when a new MobState is entered.
|
|
/// </summary>
|
|
/// <param name="entity">The owner of the MobState Component</param>
|
|
/// <param name="component">MobState Component owned by the target</param>
|
|
/// <param name="state">The new MobState</param>
|
|
protected virtual void OnEnterState(EntityUid entity, MobStateComponent component, MobState state)
|
|
{
|
|
OnStateEnteredSubscribers(entity, component, state);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when this entity changes MobState
|
|
/// </summary>
|
|
/// <param name="entity">The owner of the MobState Component</param>
|
|
/// <param name="component">MobState Component owned by the target</param>
|
|
/// <param name="oldState">The previous MobState</param>
|
|
/// <param name="newState">The new MobState</param>
|
|
protected virtual void OnStateChanged(EntityUid entity, MobStateComponent component, MobState oldState,
|
|
MobState newState)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when a new MobState is exited.
|
|
/// </summary>
|
|
/// <param name="entity">The owner of the MobState Component</param>
|
|
/// <param name="component">MobState Component owned by the target</param>
|
|
/// <param name="state">The old MobState</param>
|
|
protected virtual void OnExitState(EntityUid entity, MobStateComponent component, MobState state)
|
|
{
|
|
OnStateExitSubscribers(entity, component, state);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Private Implementation
|
|
|
|
//Actually change the MobState
|
|
private void ChangeState(EntityUid target, MobStateComponent component, MobState newState, EntityUid? origin = null)
|
|
{
|
|
var oldState = component.CurrentState;
|
|
//make sure we are allowed to enter the new state
|
|
if (oldState == newState || !component.AllowedStates.Contains(newState))
|
|
return;
|
|
|
|
OnExitState(target, component, oldState);
|
|
component.CurrentState = newState;
|
|
OnEnterState(target, component, newState);
|
|
|
|
var ev = new MobStateChangedEvent(target, component, oldState, newState, origin);
|
|
OnStateChanged(target, component, oldState, newState);
|
|
RaiseLocalEvent(target, ev, true);
|
|
if (origin != null && HasComp<ActorComponent>(origin) && HasComp<ActorComponent>(target) && oldState < newState)
|
|
_adminLogger.Add(LogType.Damaged, LogImpact.High, $"{ToPrettyString(origin):player} caused {ToPrettyString(target):player} state to change from {oldState} to {newState}");
|
|
else
|
|
_adminLogger.Add(LogType.Damaged, oldState == MobState.Alive ? LogImpact.Low : LogImpact.Medium, $"{ToPrettyString(target):user} state changed from {oldState} to {newState}");
|
|
Dirty(target, component);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event that gets triggered when we want to update the mobstate. This allows for systems to override MobState changes
|
|
/// </summary>
|
|
/// <param name="Target">The Entity whose MobState is changing</param>
|
|
/// <param name="Component">The MobState Component owned by the Target</param>
|
|
/// <param name="State">The new MobState we want to set</param>
|
|
/// <param name="Origin">Entity that caused the state update (if applicable)</param>
|
|
[ByRefEvent]
|
|
public record struct UpdateMobStateEvent(EntityUid Target, MobStateComponent Component, MobState State,
|
|
EntityUid? Origin = null);
|