private void SaveAndSyncChestPickup(On.RoR2.ChestBehavior.orig_PickFromList orig, ChestBehavior self, List <PickupIndex> dropList) { orig(self, dropList); if (ShouldIgnoreChestBehaviour(self)) { return; } var dropPickup = self.GetFieldValue <PickupIndex>("dropPickup"); if (dropPickup == null || dropPickup == PickupIndex.none) { Debug.LogWarning($"Failed to get pickupIndex of Chest {self.netId}"); return; } if (NetworkServer.active) { if (!NetworkChestSync.instance) { var instance = Instantiate(chestSyncPrefab); NetworkServer.Spawn(instance); } StartCoroutine(SyncChestPickup(self.netId, PickupCatalog.GetPickupDef(dropPickup).internalName, syncInterval)); } }
public ChestData(ChestBehavior chest) { var stateMachine = chest.GetComponent <EntityStateMachine>(); var purchaseInteraction = chest.GetComponent <PurchaseInteraction>(); name = chest.name.Replace("(Clone)", ""); transform = new SerializableTransform(chest.transform); index = chest.GetFieldValue <PickupIndex>("dropPickup").value; isEquipment = index >= (int)ItemIndex.Count; opened = stateMachine.state.GetType().IsEquivalentTo(typeof(EntityStates.Barrel.Opened)) ? true : false; cost = purchaseInteraction.cost; costType = (int)purchaseInteraction.costType; }