internal void SCP914Upgrade(ref SCP914UpgradeEvent ev) { Vector3 tpPos = ev.Machine.output.position - ev.Machine.intake.position; foreach (KeyValuePair <Scp914PlayerUpgrade, Scp914Knob> kv in Roles) { if (ev.KnobSetting != kv.Value) { continue; } foreach (ReferenceHub hub in ev.Players) { if (kv.Key.ToUpgrade == hub.characterClassManager.CurClass) { Vector3 oldPos = hub.transform.position; hub.characterClassManager.SetPlayersClass(kv.Key.UpgradedTo, hub.gameObject); Timing.RunCoroutine(TeleportToOutput(hub, oldPos, tpPos, hub.inventory)); } } } if (UpgradeHand) // Upgrade hand items like a boss { foreach (ReferenceHub hub in ev.Players) { ev.Machine.UpgradeHeldItem(hub.inventory, hub.characterClassManager, ev.Machine.players); // use default game functions yeehaw } } foreach (KeyValuePair <Scp914ItemUpgrade, Scp914Knob> kvp in Items) { if (ev.KnobSetting != kvp.Value) { continue; } foreach (Pickup item in ev.Items) { if (kvp.Key.ToUpgrade == item.ItemId) { SpawnItem(kvp.Key.UpgradedTo, item.transform.position + tpPos, Vector3.zero); item.Delete(); } } } }
internal void SCP914Upgrade(ref SCP914UpgradeEvent ev) { try { if (!Enable914) { return; } Vector3 tpPos = ev.Machine.output.position - ev.Machine.intake.position; Dictionary <ItemType, ItemType> upgradeItems = new Dictionary <ItemType, ItemType>(); foreach (KeyValuePair <Scp914ItemUpgrade, Scp914Knob> ikvp in Items) { if (ev.KnobSetting != ikvp.Value) { continue; } upgradeItems.Add(ikvp.Key.ToUpgrade, ikvp.Key.UpgradedTo); } if (UpgradeHand) { foreach (ReferenceHub hub in ev.Players) { if (upgradeItems.ContainsKey(hub.inventory.NetworkcurItem)) { hub.inventory.NetworkcurItem = upgradeItems[hub.inventory.NetworkcurItem]; } else { ev.Machine.UpgradeHeldItem(hub.inventory, hub.characterClassManager, ev.Machine.players); } } } foreach (Pickup item in ev.Items) { if (upgradeItems.ContainsKey(item.ItemId)) { Vector3 pos = item.gameObject.transform.position + tpPos; SpawnItem(upgradeItems[item.ItemId], pos, Vector3.zero); item.Delete(); } else { ev.Machine.UpgradeItem(item); } } Dictionary <RoleType, RoleType> upgrades = new Dictionary <RoleType, RoleType>(); foreach (KeyValuePair <Scp914PlayerUpgrade, Scp914Knob> kvp in Roles) { if (ev.KnobSetting != kvp.Value) { continue; } upgrades.Add(kvp.Key.ToUpgrade, kvp.Key.UpgradedTo); } foreach (ReferenceHub player in ev.Players) { if (upgrades.ContainsKey(player.characterClassManager.CurClass)) { Vector3 oldPos = player.gameObject.transform.position; player.characterClassManager.NetworkCurClass = upgrades[player.characterClassManager.CurClass]; Timing.RunCoroutine(TeleportToOutput(player, oldPos, tpPos, player.inventory)); } } } catch (Exception e) { Plugin.Error(e.ToString()); } }