public PlanPiecePrefabConfig(Piece piece) : base(piece.gameObject.name + PlanPiecePrefabConfig.plannedSuffix, piece.gameObject.name, PlanHammerPrefabConfig.pieceTableName) { this.originalPiece = piece; Piece.m_name = Localization.instance.Localize("$item_plan_piece_name", originalPiece.m_name); Piece.m_description = Localization.instance.Localize("$item_plan_piece_description", originalPiece.m_name); Piece.m_resources = new Piece.Requirement[0]; Piece.m_craftingStation = null; Piece.m_placeEffect.m_effectPrefabs = new EffectList.EffectData[0]; Piece.m_comfort = 0; Piece.m_canBeRemoved = true; Piece.m_category = originalPiece.m_category; Piece.m_groundOnly = originalPiece.m_groundOnly; Piece.m_groundPiece = originalPiece.m_groundPiece; Piece.m_icon = originalPiece.m_icon; Piece.m_inCeilingOnly = originalPiece.m_inCeilingOnly; Piece.m_isUpgrade = originalPiece.m_isUpgrade; Piece.m_haveCenter = originalPiece.m_haveCenter; Piece.m_dlc = originalPiece.m_dlc; Piece.m_allowAltGroundPlacement = originalPiece.m_allowAltGroundPlacement; Piece.m_allowedInDungeons = originalPiece.m_allowedInDungeons; this.PieceTable = PlanHammerPrefabConfig.pieceTableName; WearNTear wearNTear = PiecePrefab.GetComponent <WearNTear>(); if (wearNTear == null) { wearNTear = PiecePrefab.AddComponent <WearNTear>(); } wearNTear.m_noSupportWear = true; wearNTear.m_noRoofWear = false; wearNTear.m_autoCreateFragments = false; wearNTear.m_supports = true; wearNTear.m_hitEffect = new EffectList(); PlanPiece planPieceScript = PiecePrefab.AddComponent <PlanPiece>(); planPieceScript.originalPiece = originalPiece; planToOriginalMap.Add(Piece, originalPiece); if (logComponents) { StringBuilder sb = new StringBuilder("Components in prefab: " + PiecePrefab.name + "\n"); sb.Append("Components in prefab: " + PiecePrefab.name + "\n"); sb.Append($" Prefab: {PiecePrefab.name} -> {PiecePrefab.gameObject}\n"); foreach (Component component in PiecePrefab.GetComponents <Component>()) { sb.Append($" {component.GetType()} -> {component.name}\n"); } logger.LogWarning(sb.ToString()); } DisablePiece(PiecePrefab); }
static bool Player_CheckCanRemovePiece_Prefix(Piece piece, ref bool __result) { PlanPiece PlanPiece = piece.GetComponent <PlanPiece>(); if (PlanPiece) { __result = true; return(false); } return(true); }
static bool WearNTear_Destroy_Prefix(WearNTear __instance) { PlanPiece planPiece = __instance.GetComponent <PlanPiece>(); if (planPiece && planPiece.m_nView.IsOwner()) { //Don't // create noise // create fragments // play destroyed effects planPiece.Refund(all: true); ZNetScene.instance.Destroy(__instance.gameObject); return(false); } return(true); }