64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
using UnityEngine.Scripting;
|
|
|
|
#nullable disable
|
|
[Preserve]
|
|
public class BlockForgeRebirth : BlockWorkstationRebirth
|
|
{
|
|
public BlockForgeRebirth() => this.CraftingParticleLightIntensity = 1.6f;
|
|
|
|
public override void OnBlockEntityTransformAfterActivated(
|
|
WorldBase _world,
|
|
Vector3i _blockPos,
|
|
int _cIdx,
|
|
BlockValue _blockValue,
|
|
BlockEntityData _ebcd)
|
|
{
|
|
base.OnBlockEntityTransformAfterActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd);
|
|
this.MaterialUpdate(_world, _blockPos, _blockValue);
|
|
}
|
|
|
|
[PublicizedFrom(EAccessModifier.Protected)]
|
|
public override void checkParticles(
|
|
WorldBase _world,
|
|
int _clrIdx,
|
|
Vector3i _blockPos,
|
|
BlockValue _blockValue)
|
|
{
|
|
base.checkParticles(_world, _clrIdx, _blockPos, _blockValue);
|
|
if (_blockValue.ischild)
|
|
return;
|
|
this.MaterialUpdate(_world, _blockPos, _blockValue);
|
|
}
|
|
|
|
public override string GetActivationText(
|
|
WorldBase _world,
|
|
BlockValue _blockValue,
|
|
int _clrIdx,
|
|
Vector3i _blockPos,
|
|
EntityAlive _entityFocusing)
|
|
{
|
|
return Localization.Get("useForge");
|
|
}
|
|
|
|
[PublicizedFrom(EAccessModifier.Private)]
|
|
public void MaterialUpdate(WorldBase _world, Vector3i _blockPos, BlockValue _blockValue)
|
|
{
|
|
Chunk chunkFromWorldPos = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
|
if (chunkFromWorldPos == null)
|
|
return;
|
|
BlockEntityData blockEntity = chunkFromWorldPos.GetBlockEntity(_blockPos);
|
|
if (blockEntity == null || !blockEntity.bHasTransform)
|
|
return;
|
|
Renderer[] componentsInChildren = (Renderer[])blockEntity.transform.GetComponentsInChildren<MeshRenderer>(true);
|
|
if (componentsInChildren.Length == 0)
|
|
return;
|
|
Material material = componentsInChildren[0].material;
|
|
if (!(bool)material)
|
|
return;
|
|
float num = _blockValue.meta == (byte)0 ? 0.0f : 20f;
|
|
material.SetFloat("_EmissionMultiply", num);
|
|
for (int index = 1; index < componentsInChildren.Length; ++index)
|
|
componentsInChildren[index].material = material;
|
|
}
|
|
}
|