Ignore:
Timestamp:
Aug 7, 2022, 3:02:24 PM (2 years ago)
Author:
alloc
Message:

Major refactoring/cleanup

File:
1 moved

Legend:

Unmodified
Added
Removed
  • binary-improvements2/7dtd-server-fixes/src/ModApi.cs

    r390 r391  
    11using System.Collections.Generic;
    22using AllocsFixes.PersistentData;
     3using JetBrains.Annotations;
    34using Platform.Steam;
    45
    56namespace AllocsFixes {
    6         public class API : IModApi {
     7        [UsedImplicitly]
     8        public class ModApi : IModApi {
    79                public void InitMod (Mod _modInstance) {
    810                        ModEvents.GameStartDone.RegisterHandler (GameAwake);
    9                         ModEvents.GameShutdown.RegisterHandler (GameShutdown);
    1011                        ModEvents.SavePlayerData.RegisterHandler (SavePlayerData);
    1112                        ModEvents.PlayerSpawning.RegisterHandler (PlayerSpawning);
     
    1516                }
    1617
    17                 public void GameAwake () {
     18                private void GameAwake () {
    1819                        PersistentContainer.Load ();
    1920                }
    2021
    21                 public void GameShutdown () {
    22                 }
    23 
    24                 public void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) {
     22                private void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) {
    2523                        PersistentContainer.Instance.Players [_cInfo.InternalId, true].Update (_playerDataFile);
    2624                }
    2725
    28                 public void PlayerSpawning (ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) {
     26                private void PlayerSpawning (ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) {
    2927                        string owner = null;
    3028                        if (_cInfo.PlatformId is UserIdentifierSteam identifierSteam) {
     
    4240                }
    4341
    44                 public void PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) {
     42                private void PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) {
    4543                        Player p = PersistentContainer.Instance.Players [_cInfo.InternalId, false];
    4644                        if (p != null) {
     
    5351                }
    5452
    55                 public void PlayerSpawned (ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _spawnPos) {
     53                private void PlayerSpawned (ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _spawnPos) {
    5654                        PersistentContainer.Instance.Players [_cInfo.InternalId, true].SetOnline (_cInfo);
    5755                        PersistentContainer.Instance.Save ();
    5856                }
    5957
    60                 private const string ANSWER =
     58                private const string testChatAnswer =
    6159                        "     [ff0000]I[-] [ff7f00]W[-][ffff00]A[-][80ff00]S[-] [00ffff]H[-][0080ff]E[-][0000ff]R[-][8b00ff]E[-]";
    6260
    63                 public bool ChatMessage (ClientInfo _cInfo, EChatType _type, int _senderId, string _msg, string _mainName,
     61                private bool ChatMessage (ClientInfo _cInfo, EChatType _type, int _senderId, string _msg, string _mainName,
    6462                        bool _localizeMain, List<int> _recipientEntityIds) {
    6563                        if (string.IsNullOrEmpty (_msg) || !_msg.EqualsCaseInsensitive ("/alloc")) {
     
    6967                        if (_cInfo != null) {
    7068                                Log.Out ("Sent chat hook reply to {0}", _cInfo.InternalId);
    71                                 _cInfo.SendPackage (NetPackageManager.GetPackage<NetPackageChat> ().Setup (EChatType.Whisper, -1, ANSWER, "", false, null));
     69                                _cInfo.SendPackage (NetPackageManager.GetPackage<NetPackageChat> ().Setup (EChatType.Whisper, -1, testChatAnswer, "", false, null));
    7270                        } else {
    7371                                Log.Error ("ChatHookExample: Argument _cInfo null on message: {0}", _msg);
Note: See TracChangeset for help on using the changeset viewer.