forked from Nyanotrasen/Nyanotrasen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
857c65d
commit 9ee0ec4
Showing
36 changed files
with
1,086 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Content.Shared.Roles; | ||
using JetBrains.Annotations; | ||
|
||
namespace Content.Client.Jobs | ||
{ | ||
[UsedImplicitly] | ||
public class JanitorSpecial : JobSpecial | ||
{ | ||
// Dummy class that exists solely to avoid an exception on the client, | ||
// but allow the server-side counterpart to exist. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
Content.Server/GameObjects/Components/Observer/GhostRoleComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Content.Server/Holiday/Celebrate/DefaultHolidayCelebrate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Content.Server.Holiday.Interfaces; | ||
|
||
namespace Content.Server.Holiday.Celebrate | ||
{ | ||
public class DefaultHolidayCelebrate : IHolidayCelebrate | ||
{ | ||
public void Celebrate(HolidayPrototype holiday) | ||
{ | ||
// Nada. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Content.Server.Holiday.Interfaces; | ||
using JetBrains.Annotations; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Server.Holiday.Greet | ||
{ | ||
[UsedImplicitly] | ||
public class Custom : IHolidayGreet | ||
{ | ||
private string _greet; | ||
|
||
void IExposeData.ExposeData(ObjectSerializer serializer) | ||
{ | ||
serializer.DataField(ref _greet, "text", string.Empty); | ||
} | ||
|
||
public string Greet(HolidayPrototype holiday) | ||
{ | ||
return _greet; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Content.Server.Holiday.Interfaces; | ||
using Robust.Shared.Localization; | ||
|
||
namespace Content.Server.Holiday.Greet | ||
{ | ||
public class DefaultHolidayGreet : IHolidayGreet | ||
{ | ||
public string Greet(HolidayPrototype holiday) | ||
{ | ||
return Loc.GetString("Have a happy {0}!", holiday.Name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Content.Server.GameTicking; | ||
using Content.Server.Holiday.Interfaces; | ||
using Content.Server.Interfaces.Chat; | ||
using Content.Server.Interfaces.GameTicking; | ||
using Content.Shared; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.IoC; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.ViewVariables; | ||
|
||
namespace Content.Server.Holiday | ||
{ | ||
// ReSharper disable once ClassNeverInstantiated.Global | ||
public class HolidayManager : IHolidayManager | ||
{ | ||
[Dependency] private readonly IConfigurationManager _configManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly IGameTicker _gameTicker = default!; | ||
[Dependency] private readonly IChatManager _chatManager = default!; | ||
|
||
[ViewVariables] | ||
private readonly List<HolidayPrototype> _currentHolidays = new(); | ||
|
||
[ViewVariables] | ||
private bool _enabled = true; | ||
|
||
public void RefreshCurrentHolidays() | ||
{ | ||
_currentHolidays.Clear(); | ||
|
||
if (!_enabled) return; | ||
|
||
var now = DateTime.Now; | ||
|
||
foreach (var holiday in _prototypeManager.EnumeratePrototypes<HolidayPrototype>()) | ||
{ | ||
if(holiday.ShouldCelebrate(now)) | ||
_currentHolidays.Add(holiday); | ||
} | ||
} | ||
|
||
public void DoGreet() | ||
{ | ||
foreach (var holiday in _currentHolidays) | ||
{ | ||
_chatManager.DispatchServerAnnouncement(holiday.Greet()); | ||
} | ||
} | ||
|
||
public void DoCelebrate() | ||
{ | ||
foreach (var holiday in _currentHolidays) | ||
{ | ||
holiday.Celebrate(); | ||
} | ||
} | ||
|
||
public IEnumerable<HolidayPrototype> GetCurrentHolidays() | ||
{ | ||
return _currentHolidays; | ||
} | ||
|
||
public bool IsCurrentlyHoliday(string holiday) | ||
{ | ||
if (!_prototypeManager.TryIndex(holiday, out HolidayPrototype prototype)) | ||
return false; | ||
|
||
return _currentHolidays.Contains(prototype); | ||
} | ||
|
||
public void Initialize() | ||
{ | ||
_configManager.OnValueChanged(CCVars.HolidaysEnabled, OnHolidaysEnableChange, true); | ||
|
||
_gameTicker.OnRunLevelChanged += OnRunLevelChanged; | ||
} | ||
|
||
private void OnHolidaysEnableChange(bool enabled) | ||
{ | ||
_enabled = enabled; | ||
|
||
RefreshCurrentHolidays(); | ||
} | ||
|
||
private void OnRunLevelChanged(GameRunLevelChangedEventArgs eventArgs) | ||
{ | ||
if (!_enabled) return; | ||
|
||
switch (eventArgs.NewRunLevel) | ||
{ | ||
case GameRunLevel.PreRoundLobby: | ||
RefreshCurrentHolidays(); | ||
break; | ||
case GameRunLevel.InRound: | ||
DoGreet(); | ||
DoCelebrate(); | ||
break; | ||
case GameRunLevel.PostRound: | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#nullable enable | ||
using System; | ||
using Content.Server.Holiday.Celebrate; | ||
using Content.Server.Holiday.Greet; | ||
using Content.Server.Holiday.Interfaces; | ||
using Content.Server.Holiday.ShouldCelebrate; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization; | ||
using Robust.Shared.ViewVariables; | ||
using YamlDotNet.RepresentationModel; | ||
|
||
namespace Content.Server.Holiday | ||
{ | ||
[Prototype("holiday")] | ||
public class HolidayPrototype : IPrototype, IIndexedPrototype, IExposeData | ||
{ | ||
[ViewVariables] public string Name { get; private set; } = string.Empty; | ||
[ViewVariables] public string ID { get; private set; } = string.Empty; | ||
[ViewVariables] public byte BeginDay { get; set; } = 1; | ||
[ViewVariables] public Month BeginMonth { get; set; } = Month.Invalid; | ||
|
||
/// <summary> | ||
/// Day this holiday will end. Zero means it lasts a single day. | ||
/// </summary> | ||
[ViewVariables] public byte EndDay { get; set; } = 0; | ||
|
||
/// <summary> | ||
/// Month this holiday will end in. Invalid means it lasts a single month. | ||
/// </summary> | ||
[ViewVariables] public Month EndMonth { get; set; } = Month.Invalid; | ||
|
||
[ViewVariables] | ||
private IHolidayShouldCelebrate _shouldCelebrate = new DefaultHolidayShouldCelebrate(); | ||
|
||
[ViewVariables] | ||
private IHolidayGreet _greet = new DefaultHolidayGreet(); | ||
|
||
[ViewVariables] | ||
private IHolidayCelebrate _celebrate = new DefaultHolidayCelebrate(); | ||
|
||
public void LoadFrom(YamlMappingNode mapping) | ||
{ | ||
var serializer = YamlObjectSerializer.NewReader(mapping); | ||
ExposeData(serializer); | ||
} | ||
|
||
public void ExposeData(ObjectSerializer serializer) | ||
{ | ||
serializer.DataField(this, x => x.ID, "id", string.Empty); | ||
serializer.DataField(this, x => x.Name, "name", string.Empty); | ||
serializer.DataField(this, x => x.BeginDay, "beginDay", (byte)1); | ||
serializer.DataField(this, x => x.BeginMonth, "beginMonth", Month.Invalid); | ||
serializer.DataField(this, x => x.EndDay, "endDay", (byte)0); | ||
serializer.DataField(this, x => x.EndMonth, "endMonth", Month.Invalid); | ||
serializer.DataField(ref _shouldCelebrate, "shouldCelebrate", new DefaultHolidayShouldCelebrate()); | ||
serializer.DataField(ref _greet, "greet", new DefaultHolidayGreet()); | ||
serializer.DataField(ref _celebrate, "celebrate", new DefaultHolidayCelebrate()); | ||
} | ||
|
||
public bool ShouldCelebrate(DateTime date) | ||
{ | ||
return _shouldCelebrate.ShouldCelebrate(date, this); | ||
} | ||
|
||
public string Greet() | ||
{ | ||
return _greet.Greet(this); | ||
} | ||
|
||
/// <summary> | ||
/// Called before the round starts to set up any festive shenanigans. | ||
/// </summary> | ||
public void Celebrate() | ||
{ | ||
_celebrate.Celebrate(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Server.Holiday.Interfaces | ||
{ | ||
public interface IHolidayCelebrate : IExposeData | ||
{ | ||
void IExposeData.ExposeData(ObjectSerializer serializer) {} | ||
|
||
/// <summary> | ||
/// This method is called before a round starts. | ||
/// Use it to do any fun festive modifications. | ||
/// </summary> | ||
void Celebrate(HolidayPrototype holiday); | ||
} | ||
} |
Oops, something went wrong.