A class in Root.Township, the global namespace.
Gives an item its physical material (iron, wood and so on): sets renderer materials, scales impact damage and hardness, updates durability, and syncs and saves the choice. Server picks a random one from its distribution on spawn.
Constructors
| Member | What it is |
|---|
PhysicalMaterialPart() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|
private DurabilityModule durabilityModule | Parent durability module updated with the new material on every change. |
private ImpactGenerator[] impactors | Impact generators whose damage multiplier and hardness level follow the material. |
private MonoBehaviour[] listenToPhysicalMaterial | Components implementing IListenToPhysicalMaterial that are told about every material change. |
private static Logger logger | NLog logger for this class. |
private PhysicalMaterialChannel materialChannel | Which of the material's render materials this part's renderers use. |
private Distribution materialDistribution | Server: when set, a random material is picked from it by spawn attributes at generation. |
private PhysicalMaterial physicalMaterial | Backing field for PhysicalMaterial. The inspector value is applied on server start. |
private Renderer[] renderers | Renderers given the material's render material. Skipped on headless servers. |
private MethodSync syncMaterial | Method sync that sends the material hash to chunks on change and to each player on connect. |
Properties
Events
Methods
| Member | What it is |
|---|
override void Initialize() | Creates the material sync. |
override void InitializeAsServer(SpawnData spawnData) | Server: applies the starting material. |
override void OnConnected(Player player) | Sends the current material to a joining player. |
void SetMaterial(PhysicalMaterial physicalMaterial) | Applies a material: impactors, listeners, renderers (not on headless) and durability. Server: syncs to clients. Null is ignored. |
protected override void Generate(SpawnData spawnData) | Picks a random material from the distribution using the spawn attributes. |
7 private and internal methods
| Member | What it is |
|---|
private bool Alta.Inventory.IInterfereWithDocking.CheckAllowed(IInterfereWithDocking other) | Explicit IInterfereWithDocking method: only allows docking with another part of the same physical material. |
private void Alta.Utilities.ISpawnArguments.CheckArguments(string[] arguments) | Explicit ISpawnArguments method: sets the material to the first spawn argument that names a physical material. |
private bool Alta.Utilities.Atlas.IPreventAtlasing.IsPreventAtlasing(Renderer renderer) | Explicit IPreventAtlasing method: true for renderers this part recolours, so they aren't atlased. |
private void OnValidate() | Empty. |
private void IBuildRendererPostBake.PostBake() | Explicit build step: strips null entries from renderers. |
private void Alta.Networking.IEntityReplaceHandler.ReplacedWith(NetworkEntity entity, ReplaceAvoidFlags replaceAvoidFlags) | Explicit IEntityReplaceHandler method: copies this material onto the replacement entity unless the replace is internal. |
private void Sync(IPlayer player, Stream stream) | Writes the material hash; remote clients read it and call SetMaterial. |
Used in
Members of other types that take, return or hold a PhysicalMaterialPart:
ForgedModel<TB, TA>.physicalMaterialPart, MeltingModelPart.physicalMaterialPart, MetalHeatPoint.materialPart, ChiselingTool.materialPart, GenericCraftingComponent.part, GenericCraftingResult.parts, GenericCraftingResult.Parts, Arrow.physicalMaterial, Pickup.physicalMaterial, Pickup.PhysicalMaterial, Shooter.physicalMaterial, SpawnerBase.materialPart.