static void DeployableTrap_OnReceiveArmTrap_Post(DeployableTrap __instance) { #region quit if (__instance.CurrentTrapType == DeployableTrap.TrapType.Runic) { return; } #endregion // Cache Collider collider = __instance.m_interactionToggle.m_interactionCollider; Material material = __instance.CurrentVisual.FindChild("TrapVisual").GetComponentInChildren <MeshRenderer>().material; // Disarm material.color = TRAP_START_COLOR; collider.enabled = false; switch (__instance.CurrentTrapType) { case DeployableTrap.TrapType.TripWireTrap: collider.As <BoxCollider>().SetSizeZ(_wireTrapDepth); break; case DeployableTrap.TrapType.PressurePlateTrap: collider.As <SphereCollider>().radius = _pressureTrapRadius; break; } // Arm float setupTime = Time.time; __instance.ExecuteUntil ( () => Time.time - setupTime >= _trapsArmDelay, () => material.color = Utility.Lerp3(TRAP_START_COLOR, TRAP_TRANSITION_COLOR, TRAP_ARMED_COLOR, (Time.time - setupTime) / _trapsArmDelay), () => { material.color = TRAP_ARMED_COLOR; collider.enabled = true; } ); }
static void DeployableTrap_StartInit_Post(DeployableTrap __instance) { // Friendly fire Character.Factions[] factions = __instance.TargetFactions; Character.Factions playerFaction = Character.Factions.Player; Character.Factions noneFaction = Character.Factions.NONE; if (_trapsFriendlyFire && !factions.Contains(playerFaction)) { if (factions.Contains(noneFaction)) { factions[factions.IndexOf(noneFaction)] = playerFaction; } else { Array.Resize(ref factions, factions.Length + 1); factions.SetLast(playerFaction); } } else if (!_trapsFriendlyFire && factions.Contains(playerFaction)) { factions[factions.IndexOf(playerFaction)] = noneFaction; } // Rune trap only #region quit if (__instance.CurrentTrapType != DeployableTrap.TrapType.Runic) { return; } #endregion // Cache ParticleSystem.MainModule particleSystemMain = __instance.CurrentVisual.GetComponentInChildren <ParticleSystem>().main; SphereCollider collider = __instance.m_interactionToggle.m_interactionCollider as SphereCollider; // Disarm particleSystemMain.startColor = RUNIC_TRAP_START_COLOR; collider.enabled = false; collider.radius = _runicTrapRadius; // Arm float setupTime = Time.time; __instance.ExecuteUntil ( () => Time.time - setupTime >= _trapsArmDelay, () => particleSystemMain.startColor = Utility.Lerp3(RUNIC_TRAP_START_COLOR, RUNIC_TRAP_TRANSITION_COLOR, RUNIC_TRAP_ARMED_COLOR, (Time.time - setupTime) / _trapsArmDelay), () => { particleSystemMain.startColor = RUNIC_TRAP_ARMED_COLOR; collider.enabled = true; } ); }