public void Update() { if (m_nView.IsValid()) { bool haveSupport = m_nView.GetZDO().GetFloat("support") >= m_wearNTear.GetMinSupport(); if (haveSupport != hasSupport) { hasSupport = haveSupport; UpdateTextures(); } } }
public void UpdateSeedTotem() { if (!m_nview.IsValid()) { return; } bool flag = IsEnabled(); UpdateMaterials(flag); UpdateHoverText(); }
static void Postfix(ZNetView ___m_nview) { if (___m_nview.IsValid()) { ___m_nview.Register <Vector3>(Constants.Z_CallHomeCommand, RPC_CallHome); } }
private static IEnumerator DropNow(Ragdoll ragdoll, ZNetView nview, EffectList removeEffect) { if (dropDelay.Value < 0) { context.StartCoroutine(DestroyNow(ragdoll, nview, removeEffect)); yield break; } Dbgl($"delaying dropping loot"); yield return(new WaitForSeconds(dropDelay.Value)); if (!modEnabled.Value) { yield break; } if (!nview.IsValid() || !nview.IsOwner()) { context.StartCoroutine(DropNow(ragdoll, nview, removeEffect)); yield break; } Dbgl($"dropping loot"); Vector3 averageBodyPosition = ragdoll.GetAverageBodyPosition(); Traverse.Create(ragdoll).Method("SpawnLoot", new object[] { averageBodyPosition }).GetValue(); context.StartCoroutine(DestroyNow(ragdoll, nview, removeEffect)); }
static void Postfix(CookingStation __instance, ZNetView ___m_nview) { if (!modEnabled.Value || !___m_nview.IsValid() || !___m_nview.IsOwner() || !EffectArea.IsPointInsideArea(__instance.transform.position, EffectArea.Type.Burning, 0.25f)) { return; } for (int i = 0; i < __instance.m_slots.Length; i++) { string itemName = ___m_nview.GetZDO().GetString("slot" + i, ""); float num = ___m_nview.GetZDO().GetFloat("slot" + i, 0f); if (itemName != "" && itemName != __instance.m_overCookedItem.name && itemName != null) { CookingStation.ItemConversion itemConversion = Traverse.Create(__instance).Method("GetItemConversion", new object[] { itemName }).GetValue <CookingStation.ItemConversion>(); if (num > itemConversion.m_cookTime && itemName == itemConversion.m_to.name) { if (autoPop.Value) { Traverse.Create(__instance).Method("SpawnItem", new object[] { itemName }).GetValue(); ___m_nview.GetZDO().Set("slot" + i, ""); ___m_nview.GetZDO().Set("slot" + i, 0f); ___m_nview.InvokeRPC(ZNetView.Everybody, "SetSlotVisual", new object[] { i, "" }); } else if (preventBurning.Value) { ___m_nview.GetZDO().Set("slot" + i, itemConversion.m_cookTime); } } } } }
private void UndoSpawn() { Debug.Log("Easyspawner: Undo spawn action"); if (spawnActions.Count <= 0) { return; } List <GameObject> spawnedGameObjects = spawnActions.Pop(); Debug.Log("Easyspawner: Destroying " + spawnedGameObjects.Count + " objects"); string objectName = "objects"; foreach (GameObject GO in spawnedGameObjects) { if (GO != null) { objectName = GO.name.Remove(GO.name.Length - 7); ZNetView zNetV = GO.GetComponent <ZNetView>(); if (zNetV && zNetV.IsValid() && zNetV.IsOwner()) { zNetV.Destroy(); } } } Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Undo spawn of " + spawnedGameObjects.Count + " " + objectName); Debug.Log("Easyspawner: Spawn undone"); }
public string GetHoverText() { if (!m_nview.IsValid() || Player.m_localPlayer == null) { return(""); } return(Localization.instance.Localize(m_hoverText)); }
static bool Prefix(MineRock5 __instance, HitData hit, ZNetView ___m_nview) { if (!modEnabled.Value) { return(true); } if (!___m_nview.IsValid() || !___m_nview.IsOwner()) { return(false); } return(CheckCanDamage(__instance.gameObject, hit)); }
public static void Prefix(Humanoid character, bool repeat, ZNetView ___m_nview, bool ___m_picked, Pickable __instance) { if (!___m_nview.IsValid() || ___m_picked) { return; } var mult = 1.0f + character.GetSkillFactor((Skills.SkillType)SKILL_TYPE) * (float)maxDropMultiplier.Value; Debug.Log("Gathering multiplier set to " + mult); __instance.SetMultiplier(mult); }
public void Awake() { m_pieceRayMask = LayerMask.GetMask("piece"); m_pivot = transform.Find("New/pivot"); m_nview = GetComponent <ZNetView>(); WearNTear wearNTear = GetComponent <WearNTear>(); wearNTear.m_onDestroyed += OnDestroyed; if (m_nview && m_nview.IsValid()) { InvokeRepeating("LookForSupport", PulleyUpdateTime, PulleyUpdateTime); } }
static bool Prefix(Destructible __instance, HitData hit, ZNetView ___m_nview, bool ___m_destroyed) { if (!modEnabled.Value) { return(true); } if (!___m_nview.IsValid() || !___m_nview.IsOwner() || ___m_destroyed) { return(false); } return(CheckCanDamage(__instance.gameObject, hit)); }
static void Postfix(Door __instance, ZNetView ___m_nview) { if (!modEnabled.Value || !___m_nview.IsValid() || !newDoors.Any() || !newDoors.ContainsKey(__instance.transform.position)) { return; } ___m_nview.GetZDO().Set("LockedDoor", true); ___m_nview.GetZDO().Set("DoorLocked", true); ___m_nview.GetZDO().Set("DoorGUID", newDoors[__instance.transform.position] + ""); Dbgl($"Set door {newDoors[__instance.transform.position]} as lockable at {__instance.transform.position}"); newDoors.Remove(__instance.transform.position); }
public void Update() { if (!m_nview || !m_nview.IsValid()) { return; } if (m_follower) { return; } if (m_baseRoot && !activatedPendingPieces) { activatedPendingPieces = ActivatePendingPieces(); } }
public void LookForSupport() { if (!m_pulley && m_nview && m_nview.IsValid()) { ZDOID pulleyID = m_nview.GetZDO().GetZDOID(PulleyBaseHash); if (pulleyID != ZDOID.None) { Jotunn.Logger.LogDebug("Looking for pulley " + pulleyID); GameObject pulleyObject = ZNetScene.instance.FindInstance(pulleyID); if (pulleyObject) { SetPulley(pulleyObject.GetComponent <Pulley>()); } } } if (!m_pulley && Physics.Raycast(transform.position - transform.up, transform.up * -1, out var hitInfo, 2000f, m_pieceRayMask)) { SetPulley(hitInfo.collider.GetComponentInParent <Pulley>()); } if (m_pulley) { CancelInvoke("LookForSupport"); } }
public static void Prefix(GameObject prefab, int offset, ref int stack, ZNetView ___m_nview, bool ___m_picked, Pickable __instance) { if (!___m_nview.IsValid()) { return; } var mult = __instance.GetMultiplier(); Debug.Log("Gathering multiplier read as " + mult); stack = (int)mult * stack; Debug.Log("Gathering boosted stack size to " + stack); __instance.ClearMultiplier(); }
static bool Prefix(ItemDrop.ItemData item, ref ItemDrop.ItemData ___m_rightItem, ref ZNetView ___m_nview, ref VisEquipment ___m_visEquipment) { if (!___m_nview.IsValid() || !___m_nview.IsOwner()) { return(true); } if (!MobManager.IsAliveMob(___m_nview.GetZDO().GetString(Constants.Z_CharacterId))) { return(true); } ___m_rightItem = item; ___m_rightItem.m_equiped = item != null; ___m_visEquipment.SetRightItem(item?.m_dropPrefab?.name); ___m_visEquipment.GetType().GetMethod("UpdateEquipmentVisuals", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(___m_visEquipment, new object[] { }); return(false); }
private GameObject GetValidHoverObject(Player player) { if (!player || !player.GetHoverObject()) { return(null); } GameObject hoverObject = player.GetHoverObject(); ZNetView zNetView = hoverObject.GetComponentInParent <ZNetView>(); if (!zNetView || !zNetView.IsValid()) { return(null); } return(hoverObject); }
static void Postfix(CookingStation __instance, ZNetView ___m_nview) { Traverse traverse = Traverse.Create(__instance); if (!modEnabled.Value || !___m_nview.IsValid() || !___m_nview.IsOwner() || (__instance.m_requireFire && !traverse.Method("IsFireLit").GetValue <bool>()) || (__instance.m_useFuel && traverse.Method("GetFuel").GetValue <float>() <= 0f)) { return; } //Dbgl($"Updating {__instance.name}"); for (int i = 0; i < __instance.m_slots.Length; i++) { string itemName = ___m_nview.GetZDO().GetString("slot" + i, ""); float cookedTime = ___m_nview.GetZDO().GetFloat("slot" + i, 0f); int status = ___m_nview.GetZDO().GetInt("slotstatus" + i, 0); if (itemName == "") { continue; } CookingStation.ItemConversion itemConversion = traverse.Method("GetItemConversion", new object[] { itemName }).GetValue <CookingStation.ItemConversion>(); //Dbgl($"Updating slot {i} {cookedTime}/{itemConversion.m_cookTime} {status}"); if (itemName != "" && status != 2) { //Dbgl($"Updating slot {i} {itemName} {cookedTime}"); if (itemConversion != null && cookedTime > itemConversion.m_cookTime && itemName == itemConversion.m_to.name) { if (autoPop.Value) { Dbgl($"Popping {__instance.name} slot {i} {itemName}"); Traverse.Create(__instance).Method("SpawnItem", new object[] { itemName, i, __instance.m_slots[i].position }).GetValue(); ___m_nview.GetZDO().Set("slot" + i, ""); ___m_nview.GetZDO().Set("slot" + i, 0f); ___m_nview.InvokeRPC(ZNetView.Everybody, "SetSlotVisual", new object[] { i, "" }); } else if (preventBurning.Value) { ___m_nview.GetZDO().Set("slot" + i, itemConversion.m_cookTime); } } } } }
static bool Prefix(Tameable __instance, ref bool __result, Humanoid user, bool hold, ZNetView ___m_nview, ref Character ___m_character, ref float ___m_lastPetTime) { if (!MobConfigManager.IsControllableMob(__instance.name)) { return(true); } if (!___m_nview.IsValid()) { __result = false; return(true); } string hoverName = ___m_character.GetHoverName(); if (___m_character.IsTamed()) { if (hold) { TextInput.instance.RequestText(new MyTextReceiver(___m_character), "Name", 15); __result = false; return(false); } if (Time.time - ___m_lastPetTime > 1f) { ___m_lastPetTime = Time.time; __instance.m_petEffect.Create(___m_character.GetCenterPoint(), Quaternion.identity); if (__instance.m_commandable) { typeof(Tameable).GetMethod("Command", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { user }); } else { user.Message(MessageHud.MessageType.Center, hoverName + " $hud_tamelove"); } __result = true; return(false); } __result = false; return(false); } __result = false; return(false); }
// Display when a tamed animal is following you by hovering the mouse over the animal. // Private methods are accessible because the assemblies have been run through a publicizer (https://github.com/CabbageCrow/AssemblyPublicizer) static bool Prefix(Tameable __instance, ref string __result, Character ___m_character, MonsterAI ___m_monsterAI, ZNetView ___m_nview) { // Construct the logic that fits your case if (___m_nview.IsValid() && ___m_character.IsTamed() && (bool)___m_monsterAI.GetFollowTarget()) { // Some code duplication here. Could use transpiler patch to avoid, but they're complicated. // Probably not a big deal. var str = Localization.instance.Localize(___m_character.m_name); str += Localization.instance.Localize(" ( $hud_tame, " + __instance.GetStatusString() + ", Following )"); // Set result and skip original function execution using harmony concept (https://harmony.pardeike.net/articles/patching-prefix.html) __result = str + Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] $hud_pet"); return(false); } // Continue with original method if our case is not met return(true); }
// Token: 0x060003E3 RID: 995 RVA: 0x00020838 File Offset: 0x0001EA38 private void RemoveStartEffects() { if (this.m_startEffectInstances != null && ZNetScene.instance != null) { foreach (GameObject gameObject in this.m_startEffectInstances) { if (gameObject) { ZNetView component = gameObject.GetComponent <ZNetView>(); if (component.IsValid()) { component.ClaimOwnership(); component.Destroy(); } } } this.m_startEffectInstances = null; } }
private static IEnumerator DestroyNow(Ragdoll ragdoll, ZNetView nview, EffectList m_removeEffect) { Dbgl($"delaying destroying ragdoll"); yield return(new WaitForSeconds(Mathf.Max(destroyDelay.Value - dropDelay.Value, 0))); if (!modEnabled.Value) { yield break; } if (!nview.IsValid() || !nview.IsOwner()) { yield break; } Dbgl($"destroying ragdoll"); Vector3 averageBodyPosition = ragdoll.GetAverageBodyPosition(); m_removeEffect.Create(averageBodyPosition, Quaternion.identity, null, 1f, -1); ZNetScene.instance.Destroy(ragdoll.gameObject); }
static bool Prefix(MonsterAI __instance, float dt, ref ZNetView ___m_nview, ref Character ___m_character, ref float ___m_timeSinceHurt, ref float ___m_jumpInterval, ref float ___m_jumpTimer, ref float ___m_randomMoveUpdateTimer, ref bool ___m_alerted) { if (!___m_nview.IsValid()) { return(true); } var uniqueId = ___m_nview.GetZDO().GetString(Constants.Z_CharacterId); if (string.IsNullOrEmpty(uniqueId)) { return(true); } if (!MobManager.IsRegisteredMob(uniqueId)) { return(true); } var mobAI = GetOrCreateMob(uniqueId, __instance, ___m_nview); if (null == mobAI) { return(true); } if (!___m_nview.IsOwner()) { return(false); } if (__instance.IsSleeping()) { Invoke(__instance, "UpdateSleep", new object[] { dt }); Common.Dbgl($"{___m_character.GetHoverName()}: Sleep updated"); return(false); } BaseAI_UpdateAI_ReversePatch.UpdateAI(__instance, dt, ___m_nview, ref ___m_jumpInterval, ref ___m_jumpTimer, ref ___m_randomMoveUpdateTimer, ref ___m_timeSinceHurt, ref ___m_alerted); mobAI.UpdateAI(dt); return(false); }
public static void Reset(Vector3 centerLocation, float radius) { radius = Mathf.Clamp(radius, 2f, 50f); try { foreach (TerrainModifier terrainModifier in TerrainModifier.GetAllInstances()) { if (terrainModifier != null && Utils.DistanceXZ(Player.m_localPlayer.transform.position, terrainModifier.transform.position) < radius) { ZNetView component = terrainModifier.GetComponent <ZNetView>(); if (component != null && component.IsValid()) { component.ClaimOwnership(); component.Destroy(); } } } } catch (Exception) { } }
static void Prefix(ref ZNetView ___m_nview, ref HitData hit) { if (!___m_nview.IsValid() || !___m_nview.IsOwner()) { return; } var uniqueId = ___m_nview.GetZDO().GetString(Constants.Z_CharacterId); if (string.IsNullOrEmpty(uniqueId)) { return; } if (MobManager.IsAliveMob(uniqueId)) { var attacker = hit.GetAttacker(); if (MobManager.IsAliveMob(uniqueId)) { MobManager.AliveMobs[uniqueId].Attacker = attacker; } } }
public void Awake() { m_nview = GetComponent <ZNetView>(); m_nview.Register <string>("AddCore", RPC_AddCore); m_nview.Register("DropCores", RPC_DropCores); InvokeRepeating("UpdateStatus", 1f, 1f); smelter = GetComponent <Smelter>(); if (!smelter) { Debug.LogError("No smelter attached?! @ " + base.transform.position); } else { original_m_secPerProduct = smelter.m_secPerProduct; } if (m_nview.IsValid() && m_nview.IsOwner()) { MigrateKeys(); UpdateSmelterValues(); } }
public void Awake() { m_nview = GetComponent <ZNetView>(); if (!m_nview || !m_nview.IsValid()) { return; } WearNTear wearNTear = GetComponent <WearNTear>(); wearNTear.m_onDestroyed += OnDestroyed; m_pulleyControlls = transform.Find("wheel_collider").gameObject.AddComponent <PulleyControlls>(); pivotLeft = transform.Find("New/pivot_left"); pivotRight = transform.Find("New/pivot_right"); planet1 = pivotRight.Find("planet_1"); planet2 = pivotRight.Find("planet_2"); planet3 = pivotRight.Find("planet_3"); planet4 = pivotRight.Find("planet_4"); crank = transform.Find("New/crank"); m_controlGuiPos = transform.Find("ControlGui"); }
static bool Prefix(Tameable __instance, ref string __result, ZNetView ___m_nview, Character ___m_character) { if (!MobConfigManager.IsControllableMob(__instance.name)) { return(true); } if (!___m_character.IsTamed()) { return(true); } if (!___m_nview.IsValid()) { __result = string.Empty; return(true); } string aiStatus = ___m_nview.GetZDO().GetString(Constants.Z_AiStatus) ?? Traverse.Create(__instance).Method("GetStatusString").GetValue() as string; string str = Localization.instance.Localize(___m_character.GetHoverName()); str += Localization.instance.Localize(" ( $hud_tame, " + aiStatus + " )"); __result = str + Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] $hud_pet" + "\n[<color=yellow>Hold E</color>] to change name"); return(false); }
static bool Prefix(TeleportWorld __instance, ref ZNetView ___m_nview, ref string __result) { string destPortalTag = "None"; string tag = __instance.GetText(); if (tag == "") { tag = "Empty tag"; } if (___m_nview == null || !___m_nview.IsValid()) { Debug.LogError("HoverTextPatch: ___m_nview is not valid"); } else { ZDOID targetZDOID = ___m_nview.GetZDO().GetZDOID("target"); if (!targetZDOID.IsNone()) { var destPortalZDO = ZDOMan.instance.GetZDO(targetZDOID); if (destPortalZDO == null || !destPortalZDO.IsValid()) { Debug.Log("HoverText: destPortalZDO is null or invalid"); destPortalTag = "None"; // Reset the target since it's bad... Debug.Log("HoverText: Clearing out the target"); ___m_nview.GetZDO().Set("target", ZDOID.None); ZDOMan.instance.ForceSendZDO(___m_nview.GetZDO().m_uid); } else { destPortalTag = destPortalZDO.GetString("tag", "Empty tag"); } } } __result = Localization.instance.Localize($"Portal Tag: {tag}\nDestination Portal Tag: {destPortalTag}\n[<color=yellow><b>$KEY_Use</b></color>] Configure Portal"); return(false); }
private void DeleteHoverObject(Player player) { if (!player || !player.m_hovering) { return; } ZNetView zNetView = player.m_hovering.GetComponentInParent <ZNetView>(); if (!zNetView || !zNetView.IsValid()) { return; } UnityEngine.Object.Instantiate <GameObject>( ZNetScene.instance.GetPrefab("fx_guardstone_permitted_removed"), player.m_hovering.transform.position, player.m_hovering.transform.rotation); Logger.LogInfo(string.Format("Deleted {0} (uid: {1})", player.m_hovering.name, zNetView.GetZDO().m_uid)); zNetView.GetZDO().SetOwner(ZDOMan.instance.GetMyID()); ZNetScene.instance.Destroy(zNetView.gameObject); }