public PlanPiecePrefab(Piece piece) : base(piece.gameObject.name + PlannedSuffix, piece.gameObject.name, PlanHammerPieceTableName) { 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 = PlanHammerPieceTableName; 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(); wearNTear.m_destroyedEffect = new EffectList(); wearNTear.m_destroyNoise = 0f; wearNTear.m_hitNoise = 0f; 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"); } Jotunn.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); }