-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCartManager.cs
More file actions
73 lines (62 loc) · 2.1 KB
/
CartManager.cs
File metadata and controls
73 lines (62 loc) · 2.1 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using HarmonyLib;
using Photon.Pun;
using System.Linq;
using UnityEngine;
namespace PocketCartPlus
{
//class for managing network rpcs relating to each cart
public class CartManager : MonoBehaviour
{
internal PhotonView photonView = null!;
internal bool HasItems()
{
return EquipPatch.AllCartItems.Any(i => i.MyCart == MyCart);
}
internal bool isStoringItems = false;
internal bool isShowingItems = false;
internal static int CartsStoringItems = 0;
internal PhysGrabCart MyCart = null!;
internal string storedBy = string.Empty;
internal static CartManager firstInstance = null!;
private static Color textColor = new(209f / 255f, 205f / 255f, 205f / 255f);
private void Start()
{
Plugin.Spam("CartManager instance created!");
photonView = gameObject.GetComponent<PhotonView>();
MyCart = gameObject.GetComponent<PhysGrabCart>();
if (firstInstance == null)
firstInstance = this;
}
private void Destroy()
{
Plugin.Spam("CartManager destroyed!");
}
[PunRPC]
internal void HideCartItems(string steamID)
{
if (isStoringItems)
return;
storedBy = steamID;
isStoringItems = true;
Plugin.Spam("HideCartItems detected!");
MyCart.itemsInCart.Do(c =>
{
Plugin.Spam($"AddToEquip [ {c.gameObject.name} ]");
CartItem.AddToEquip(c, MyCart);
});
EquipPatch.AllCartItems.RemoveAll(c => c.grabObj == null);
isStoringItems = false;
if (storedBy == PlayerAvatar.instance.steamID)
{
CartsStoringItems++;
}
}
[PunRPC]
internal void ShowCartItems()
{
Plugin.Message("ShowCartItems detected!");
Plugin.Spam("Starting cart coroutine!");
MyCart.StartCoroutine(UpdateVisualsPatch.WaitToDisplay(this));
}
}
}