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; } ); }
public void Serialize(TrapEffectRecipe recipe, DeployableTrap trap) { var items = (Item[])At.GetField(recipe, "m_compatibleItems"); var tags = (TagSourceSelector[])At.GetField(recipe, "m_compatibleTags"); trap.GetCompatibleFilters(); var compatibleTags = ((List <Tag>[])At.GetField <DeployableTrap>("COMPATIBLE_TAGS"))[(int)trap.CurrentTrapType]; if (items != null) { foreach (var item in items) { switch (trap.CurrentTrapType) { case DeployableTrap.TrapType.PressurePlateTrap: if (!item.HasTag(TagSourceManager.PlateTrapComponent) && !HasAnyTag(item, compatibleTags)) { continue; } break; case DeployableTrap.TrapType.TripWireTrap: if (!item.HasTag(TagSourceManager.TripWireTrapComponent) && !HasAnyTag(item, compatibleTags)) { continue; } break; } this.CompatibleItemIDs.Add(item.Name); } } if (tags != null) { foreach (var tag in tags) { this.CompatibleItemTags.Add(tag.Tag.TagName); } } if (recipe.TrapEffectsPrefab) { this.StandardEffects = new List <DM_Effect>(); foreach (var effect in recipe.TrapEffectsPrefab.GetComponents <Effect>()) { this.StandardEffects.Add(DM_Effect.ParseEffect(effect)); } } if (recipe.HiddenTrapEffectsPrefab) { this.HiddenEffects = new List <DM_Effect>(); foreach (var effect in recipe.HiddenTrapEffectsPrefab.GetComponents <Effect>()) { this.HiddenEffects.Add(DM_Effect.ParseEffect(effect)); } } }
public static bool Prefix(DeployableTrap __instance, Effect _effect) { var self = __instance; if (_effect is Shooter shooter && PvP.Instance.CurrentGame == PvP.GameModes.BattleRoyale) { shooter.Setup(Instance.AllFactions.ToArray(), (!(self.FX_HolderTrans != null)) ? self.transform : self.FX_HolderTrans); return(false); }
// Utility static private void ResetColor(DeployableTrap __instance) { if (__instance.CurrentTrapType == DeployableTrap.TrapType.Runic) { ParticleSystem.MainModule particleSystemMain = GetRunicTrapParticleSystemMainModule(__instance); particleSystemMain.startColor = RUNIC_TRAP_START_COLOR; } else { Material material = GetTrapMainMaterial(__instance); material.color = TRAP_START_COLOR; } }
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; } ); }
static private Material GetTrapMainMaterial(DeployableTrap __instance) => __instance.CurrentVisual.FindChild("TrapVisual").GetComponentInChildren <MeshRenderer>().material;
static private ParticleSystem.MainModule GetRunicTrapParticleSystemMainModule(DeployableTrap __instance) => __instance.CurrentVisual.GetComponentInChildren <ParticleSystem>().main;
static bool DeployableTrap_Disassemble_Pre(DeployableTrap __instance) { ResetColor(__instance); return(true); }
static bool DeployableTrap_CleanUp_Pre(DeployableTrap __instance) { ResetColor(__instance); return(true); }