Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ngines into v229.1.4
  • Loading branch information
sleepyyapril committed Nov 15, 2024
2 parents 492f307 + 8739096 commit 493f7f7
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 2 deletions.
54 changes: 54 additions & 0 deletions Content.Server/AutoVote/AutoVoteSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Robust.Shared.Configuration;
using Content.Server.Voting.Managers;
using Content.Shared.GameTicking;
using Content.Shared.Voting;
using Content.Shared.CCVar;
using Robust.Server.Player;
using Content.Server.GameTicking;

namespace Content.Server.AutoVote;

public sealed class AutoVoteSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] public readonly IVoteManager _voteManager = default!;
[Dependency] public readonly IPlayerManager _playerManager = default!;

public bool _shouldVoteNextJoin = false;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RoundRestartCleanupEvent>(OnReturnedToLobby);
SubscribeLocalEvent<PlayerJoinedLobbyEvent>(OnPlayerJoinedLobby);
}

public void OnReturnedToLobby(RoundRestartCleanupEvent ev) => CallAutovote();

public void OnPlayerJoinedLobby(PlayerJoinedLobbyEvent ev)
{
if (!_shouldVoteNextJoin)
return;

CallAutovote();
_shouldVoteNextJoin = false;
}

private void CallAutovote()
{
if (!_cfg.GetCVar(CCVars.AutoVoteEnabled))
return;

if (_playerManager.PlayerCount == 0)
{
_shouldVoteNextJoin = true;
return;
}

if (_cfg.GetCVar(CCVars.MapAutoVoteEnabled))
_voteManager.CreateStandardVote(null, StandardVoteType.Map);
if (_cfg.GetCVar(CCVars.PresetAutoVoteEnabled))
_voteManager.CreateStandardVote(null, StandardVoteType.Preset);
}
}
2 changes: 1 addition & 1 deletion Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace Content.Server.Chat.Systems;

// Dear contributor. When I was introducing changes to this system only god and I knew what I was doing.
// Now only god knows. Please don't touch this code ever again. If you do have to, increment this counter as a warning for others:
// TOTAL_HOURS_WASTED_HERE_EE = 17
// TOTAL_HOURS_WASTED_HERE_EE = 18

// TODO refactor whatever active warzone this class and chatmanager have become
/// <summary>
Expand Down
15 changes: 15 additions & 0 deletions Content.Server/Polymorph/Systems/PolymorphSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

Expand All @@ -31,6 +32,7 @@ public sealed partial class PolymorphSystem : EntitySystem
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
Expand Down Expand Up @@ -201,6 +203,19 @@ private void OnDestruction(Entity<PolymorphedEntityComponent> ent, ref Destructi

var child = Spawn(configuration.Entity, _transform.GetMapCoordinates(uid, targetTransformComp), rotation: _transform.GetWorldRotation(uid));

// Copy specified components over
foreach (var compName in configuration.CopiedComponents)
{
if (!_compFact.TryGetRegistration(compName, out var reg)
|| !EntityManager.TryGetComponent(uid, reg.Idx, out var comp))
continue;

var copy = _serialization.CreateCopy(comp, notNullableOverride: true);
copy.Owner = child;
AddComp(child, copy, true);
}

// Ensure the resulting entity is sentient (why? this sucks)
MakeSentientCommand.MakeSentient(child, EntityManager);

var polymorphedComp = _compFact.GetComponent<PolymorphedEntityComponent>();
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Traits/TraitSystem.Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override void OnPlayerSpawn(EntityUid uid,
ISerializationManager serializationManager)
{
foreach (var (name, _) in Components)
entityManager.RemoveComponent(uid, (Component) factory.GetComponent(name));
entityManager.RemoveComponentDeferred(uid, factory.GetComponent(name).GetType());
}
}

Expand Down
18 changes: 18 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2640,5 +2640,23 @@ public static readonly CVarDef<float>
/// </summary>
public static readonly CVarDef<bool> DebugPow3rDisableParallel =
CVarDef.Create("debug.pow3r_disable_parallel", true, CVar.SERVERONLY);

/*
* AUTOVOTE SYSTEM
*/

/// Enables the automatic voting system.
public static readonly CVarDef<bool> AutoVoteEnabled =
CVarDef.Create("vote.autovote_enabled", false, CVar.SERVERONLY);

/// Automatically starts a map vote when returning to the lobby.
/// Requires auto voting to be enabled.
public static readonly CVarDef<bool> MapAutoVoteEnabled =
CVarDef.Create("vote.map_autovote_enabled", true, CVar.SERVERONLY);

/// Automatically starts a gamemode vote when returning to the lobby.
/// Requires auto voting to be enabled.
public static readonly CVarDef<bool> PresetAutoVoteEnabled =
CVarDef.Create("vote.preset_autovote_enabled", true, CVar.SERVERONLY);
}
}
11 changes: 11 additions & 0 deletions Content.Shared/Polymorph/PolymorphPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ public sealed partial record PolymorphConfiguration
[DataField(serverOnly: true)]
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan Cooldown = TimeSpan.Zero;

/// <summary>
/// The exact names of components to copy over when this polymorph is applied.
/// </summary>
[DataField(serverOnly: true)]
public HashSet<string> CopiedComponents = new()
{
"LanguageKnowledge",
"LanguageSpeaker",
"Grammar"
};
}

public enum PolymorphInventoryChange : byte
Expand Down
20 changes: 20 additions & 0 deletions Resources/Changelog/Changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7885,3 +7885,23 @@ Entries:
id: 6518
time: '2024-11-13T23:27:00.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1188
- author: sleepyyapril
changes:
- type: Add
message: Added the automatic voting system.
id: 6519
time: '2024-11-14T02:05:45.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1213
- author: Mnemotechnician
changes:
- type: Tweak
message: >-
Added languages to certain entities that lacked them, including MMIs and
positronic brains.
- type: Add
message: >-
Polymorphing into another entity now preserves your languages and
grammar.
id: 6520
time: '2024-11-14T20:03:33.0000000+00:00'
url: https://github.com/Simple-Station/Einstein-Engines/pull/1223
9 changes: 9 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@
behaviors:
- !type:GibBehavior { }
- type: NonSpreaderZombie
- type: LanguageKnowledge
speaks: [Hissing]
understands: [Hissing]

- type: entity
name: glockroach
Expand Down Expand Up @@ -2104,6 +2107,9 @@
- type: RandomBark
barkType: penguin
barkMultiplier: 0.6
- type: LanguageKnowledge
speaks: [Penguin]
understands: [Penguin]

- type: entity
name: grenade penguin
Expand Down Expand Up @@ -2224,6 +2230,9 @@
minTime: 10
maxTime: 50 # It's a sssnake...
barkType: hissing
- type: LanguageKnowledge
speaks: [Hissing]
understands: [Hissing]

# Code unique spider prototypes or combine them all into one spider and get a
# random sprite state when you spawn it.
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/glimmer_creatures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@
- type: NPCRetaliation
attackMemoryLength: 10
- type: NPCRangedCombat
# other
- type: LanguageSpeaker
- type: UniversalLanguageSpeaker # Should it speak unversal or some other language?
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@
powersToAdd:
- XenoglossyPower
- TelepathyPower
- type: LanguageSpeaker
- type: UniversalLanguageSpeaker
4 changes: 4 additions & 0 deletions Resources/Prototypes/Entities/Objects/Devices/pda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
- DoorBumpOpener
- type: Input
context: "human"
- type: LanguageSpeaker
- type: LanguageKnowledge
speaks: [TauCetiBasic, RobotTalk]
understands: [TauCetiBasic, RobotTalk]

- type: entity
parent: BasePDA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
- type: GuideHelp
guides:
- Cyborgs
- type: LanguageSpeaker
- type: LanguageKnowledge
speaks: [TauCetiBasic, RobotTalk]
understands: [TauCetiBasic, RobotTalk]

- type: entity
parent: MMI
Expand Down Expand Up @@ -124,3 +128,7 @@
guides:
- Cyborgs
- type: Organ # Estacao Pirata - IPCs
- type: LanguageSpeaker
- type: LanguageKnowledge
speaks: [RobotTalk]
understands: [RobotTalk]
13 changes: 13 additions & 0 deletions Resources/Prototypes/Language/animal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,16 @@
- iss
- ss
- is

- type: language
id: Penguin
obfuscation:
!type:SyllableObfuscation
minSyllables: 2
maxSyllables: 3
replacement: # I'm out of ideas
- pen
- peng
- won
- wonk
- wong
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
reagents:
- ReagentId: Nothing
Quantity: 1
- type: LanguageSpeaker
- type: LanguageKnowledge
speaks: [TauCetiBasic] # So that them foreigners can't understand what the broken mail is saying
understands: []

# This empty parcel is allowed to exist and evade the tests for the admin
# mailto command.
Expand Down

0 comments on commit 493f7f7

Please sign in to comment.