-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoomProperties.cs
More file actions
46 lines (40 loc) · 1.65 KB
/
LoomProperties.cs
File metadata and controls
46 lines (40 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Diagnostics.CodeAnalysis;
using ExitGames.Client.Photon;
using Photon.Pun;
#pragma warning disable CS8618
namespace LoomConfig
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static class LoomProperties
{
internal const string LOOM_CLAP_PLAYER_DAMAGE = "LoomClapPlayerDamage";
// Method names jokingly suggested by OrigamiCoder lol
public static void SetLoomProperties()
{
if (SemiFunc.IsNotMasterClient() || !SemiFunc.IsMultiplayer()) return;
var playerDamage = LoomConfig.configClapPlayerDamage.Value;
if (playerDamage == GetClapPlayerDamage())
{
LoomConfig.Debug("playerDamage is the same, no need to sync");
return;
}
LoomConfig.Debug($"Setting Custom Room (Loom) Properties | playerDamage: {playerDamage}");
PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable
{
{ LOOM_CLAP_PLAYER_DAMAGE, playerDamage }
});
}
public static object? GetLoomProperties(string key)
{
if (!PhotonNetwork.CurrentRoom.CustomProperties.ContainsKey(key)) return null;
var damage = PhotonNetwork.CurrentRoom.CustomProperties[key];
LoomConfig.Debug($"Getting Custom Room (Loom) Properties | key: {key} | damage: {damage}");
return damage;
}
public static int GetClapPlayerDamage()
{
var damage = GetLoomProperties(LOOM_CLAP_PLAYER_DAMAGE);
return damage == null ? -1 : (int)damage;
}
}
}