[Fix] Some fixes (#484)
* fix mood not resolved * fixed cpr sound stream * fix welded airlock not showing lights * update rep weights * tweak player reputation weights * fix for mood fix
This commit is contained in:
@@ -102,6 +102,7 @@ public sealed class AirlockSystem : SharedAirlockSystem
|
||||
(state == DoorState.Closing
|
||||
|| state == DoorState.Opening
|
||||
|| state == DoorState.Denying
|
||||
|| state == DoorState.Welded
|
||||
|| (state == DoorState.Open && comp.OpenUnlitVisible)
|
||||
|| (_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.ClosedLights, out var closedLights, args.Component) && closedLights))
|
||||
&& !boltedVisible && !emergencyLightsVisible; ;
|
||||
|
||||
@@ -344,7 +344,10 @@ namespace Content.Server.Body.Systems
|
||||
if (args.Target != null && CanCPR(args.Target.Value, component, args.User))
|
||||
args.Repeat = true;
|
||||
else
|
||||
{
|
||||
component.CPRPerformedBy = null;
|
||||
component.CPRPlayingStream?.Stop();
|
||||
}
|
||||
|
||||
RaiseLocalEvent(args.User, new MoodEffectEvent("SavedLife"));
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ public sealed class MoodSystem : EntitySystem
|
||||
private void OnRemoveEffect(EntityUid uid, MoodComponent component, MoodRemoveEffectEvent args)
|
||||
{
|
||||
if (component.UncategorisedEffects.TryGetValue(args.EffectId, out _))
|
||||
RemoveTimedOutEffect(uid, component, args.EffectId);
|
||||
RemoveTimedOutEffect(uid, args.EffectId);
|
||||
else
|
||||
{
|
||||
foreach (var (category, id) in component.CategorisedEffects)
|
||||
{
|
||||
if (id == args.EffectId)
|
||||
{
|
||||
RemoveTimedOutEffect(uid, component, args.EffectId, category);
|
||||
RemoveTimedOutEffect(uid, args.EffectId, category);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public sealed class MoodSystem : EntitySystem
|
||||
}
|
||||
|
||||
if (prototype.Timeout != 0)
|
||||
Timer.Spawn(TimeSpan.FromMinutes(prototype.Timeout), () => RemoveTimedOutEffect(uid, component, prototype.ID, prototype.Category));
|
||||
Timer.Spawn(TimeSpan.FromMinutes(prototype.Timeout), () => RemoveTimedOutEffect(uid, prototype.ID, prototype.Category));
|
||||
}
|
||||
//Apply uncategorised effect
|
||||
else
|
||||
@@ -125,14 +125,17 @@ public sealed class MoodSystem : EntitySystem
|
||||
amount += effectValue;
|
||||
|
||||
if (prototype.Timeout != 0)
|
||||
Timer.Spawn(TimeSpan.FromMinutes(prototype.Timeout), () => RemoveTimedOutEffect(uid, component, prototype.ID));
|
||||
Timer.Spawn(TimeSpan.FromMinutes(prototype.Timeout), () => RemoveTimedOutEffect(uid, prototype.ID));
|
||||
}
|
||||
|
||||
SetMood(uid, amount, component);
|
||||
}
|
||||
|
||||
private void RemoveTimedOutEffect(EntityUid uid, MoodComponent comp, string prototypeId, string? category = null)
|
||||
private void RemoveTimedOutEffect(EntityUid uid, string prototypeId, string? category = null)
|
||||
{
|
||||
if (!TryComp<MoodComponent>(uid, out var comp))
|
||||
return;
|
||||
|
||||
var amount = comp.CurrentMoodLevel;
|
||||
|
||||
if (category == null)
|
||||
|
||||
@@ -129,20 +129,25 @@ public sealed class ReputationManager : EntitySystem
|
||||
return success;
|
||||
}
|
||||
|
||||
public int GetPlayerWeight(float reputation)
|
||||
public int GetPlayerWeight(float rep)
|
||||
{
|
||||
return reputation switch
|
||||
{
|
||||
> 1000 => 9,
|
||||
> 700 => 8,
|
||||
> 500 => 7,
|
||||
> 300 => 6,
|
||||
> 100 => 5,
|
||||
> 50 => 4,
|
||||
> 15 => 3,
|
||||
< 0 => 1,
|
||||
_ => 2
|
||||
};
|
||||
// Min-max return values
|
||||
const int minValue = 30;
|
||||
const int maxValue = 50;
|
||||
|
||||
// Min-max reputation values
|
||||
const float minReputation = 0f;
|
||||
const float maxReputation = 1000f;
|
||||
|
||||
if (rep < minReputation)
|
||||
return 20;
|
||||
|
||||
var normalizedReputation = (rep - minReputation) / (maxReputation - minReputation);
|
||||
var result = (int)(minValue + (normalizedReputation * (maxValue - minValue)));
|
||||
|
||||
result = Math.Max(minValue, Math.Min(maxValue, result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ICommonSession PickPlayerBasedOnReputation(List<ICommonSession> prefList)
|
||||
|
||||
Reference in New Issue
Block a user