Changeset 391 for binary-improvements2/7dtd-server-fixes/src/ModApi.cs
- Timestamp:
- Aug 7, 2022, 3:02:24 PM (2 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/7dtd-server-fixes/src/ModApi.cs
r390 r391 1 1 using System.Collections.Generic; 2 2 using AllocsFixes.PersistentData; 3 using JetBrains.Annotations; 3 4 using Platform.Steam; 4 5 5 6 namespace AllocsFixes { 6 public class API : IModApi { 7 [UsedImplicitly] 8 public class ModApi : IModApi { 7 9 public void InitMod (Mod _modInstance) { 8 10 ModEvents.GameStartDone.RegisterHandler (GameAwake); 9 ModEvents.GameShutdown.RegisterHandler (GameShutdown);10 11 ModEvents.SavePlayerData.RegisterHandler (SavePlayerData); 11 12 ModEvents.PlayerSpawning.RegisterHandler (PlayerSpawning); … … 15 16 } 16 17 17 p ublicvoid GameAwake () {18 private void GameAwake () { 18 19 PersistentContainer.Load (); 19 20 } 20 21 21 public void GameShutdown () { 22 } 23 24 public void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) { 22 private void SavePlayerData (ClientInfo _cInfo, PlayerDataFile _playerDataFile) { 25 23 PersistentContainer.Instance.Players [_cInfo.InternalId, true].Update (_playerDataFile); 26 24 } 27 25 28 p ublicvoid PlayerSpawning (ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) {26 private void PlayerSpawning (ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) { 29 27 string owner = null; 30 28 if (_cInfo.PlatformId is UserIdentifierSteam identifierSteam) { … … 42 40 } 43 41 44 p ublicvoid PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) {42 private void PlayerDisconnected (ClientInfo _cInfo, bool _bShutdown) { 45 43 Player p = PersistentContainer.Instance.Players [_cInfo.InternalId, false]; 46 44 if (p != null) { … … 53 51 } 54 52 55 p ublicvoid PlayerSpawned (ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _spawnPos) {53 private void PlayerSpawned (ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _spawnPos) { 56 54 PersistentContainer.Instance.Players [_cInfo.InternalId, true].SetOnline (_cInfo); 57 55 PersistentContainer.Instance.Save (); 58 56 } 59 57 60 private const string ANSWER=58 private const string testChatAnswer = 61 59 " [ff0000]I[-] [ff7f00]W[-][ffff00]A[-][80ff00]S[-] [00ffff]H[-][0080ff]E[-][0000ff]R[-][8b00ff]E[-]"; 62 60 63 p ublicbool 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, 64 62 bool _localizeMain, List<int> _recipientEntityIds) { 65 63 if (string.IsNullOrEmpty (_msg) || !_msg.EqualsCaseInsensitive ("/alloc")) { … … 69 67 if (_cInfo != null) { 70 68 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)); 72 70 } else { 73 71 Log.Error ("ChatHookExample: Argument _cInfo null on message: {0}", _msg);
Note:
See TracChangeset
for help on using the changeset viewer.