Upload from upload_mods.ps1

This commit is contained in:
Nathaniel Cosford
2025-06-04 16:44:53 +09:30
commit f1fbbe67bb
1722 changed files with 165268 additions and 0 deletions

View File

@@ -0,0 +1,457 @@
using Platform;
using UnityEngine.Scripting;
#nullable disable
[Preserve]
public class BlockWorkstationRebirth : BlockParticle
{
[PublicizedFrom(EAccessModifier.Protected)]
public float TakeDelay;
public WorkstationData WorkstationData;
[PublicizedFrom(EAccessModifier.Private)]
public string[] toolTransformNames;
[PublicizedFrom(EAccessModifier.Protected)]
public float CraftingParticleLightIntensity;
[PublicizedFrom(EAccessModifier.Protected)]
public new BlockActivationCommand[] cmds = new BlockActivationCommand[2]
{
new BlockActivationCommand("open", "campfire", true),
new BlockActivationCommand("take", "hand", false)
};
public BlockWorkstationRebirth() => this.HasTileEntity = true;
public override void Init()
{
//Log.Out("BlockWorkstation-Init START");
base.Init();
this.TakeDelay = 2f;
this.Properties.ParseFloat("TakeDelay", ref this.TakeDelay);
string optionalValue = "1,2,3";
this.Properties.ParseString("Workstation.ToolNames", ref optionalValue);
this.toolTransformNames = optionalValue.Split(',', StringSplitOptions.None);
this.WorkstationData = new WorkstationData(this.GetBlockName(), this.Properties);
CraftingManager.AddWorkstationData(this.WorkstationData);
}
public override void OnBlockAdded(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
{
//Log.Out("BlockWorkstation-OnBlockAdded START");
base.OnBlockAdded(world, _chunk, _blockPos, _blockValue);
if (_blockValue.ischild)
{
//Log.Out("BlockWorkstation-OnBlockAdded IS CHILD");
return;
}
TileEntityWorkstationRebirth _te = new TileEntityWorkstationRebirth(_chunk);
_te.localChunkPos = World.toBlock(_blockPos);
_chunk.AddTileEntity((TileEntity)_te);
}
public override void OnBlockRemoved(
WorldBase world,
Chunk _chunk,
Vector3i _blockPos,
BlockValue _blockValue)
{
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
TileEntity tileEntity = world.GetTileEntity(_blockPos);
if (tileEntity is TileEntityWorkstationRebirth)
{
_chunk.RemoveTileEntityAt<TileEntityWorkstationRebirth>((World)world, World.toBlock(_blockPos));
}
else if (tileEntity is TileEntityWorkstation)
{
_chunk.RemoveTileEntityAt<TileEntityWorkstation>((World)world, World.toBlock(_blockPos));
}
}
public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea)
{
//Log.Out("BlockWorkstation-PlaceBlock START");
base.PlaceBlock(_world, _result, _ea);
TileEntityWorkstationRebirth tileEntity = (TileEntityWorkstationRebirth)_world.GetTileEntity(_result.blockPos);
if (tileEntity == null)
{
//Log.Out("BlockWorkstation-PlaceBlock CANNOT FIND TILE ENTITY");
return;
}
tileEntity.IsPlayerPlaced = true;
tileEntity.SetOwner(PlatformManager.InternalLocalUserIdentifier);
}
public override bool OnBlockActivated(
WorldBase _world,
int _cIdx,
Vector3i _blockPos,
BlockValue _blockValue,
EntityPlayerLocal _player)
{
//Log.Out("BlockWorkstation-OnBlockActivated A START");
TileEntity tileEntity = _player.world.GetTileEntity(_blockPos);
if (!(tileEntity is TileEntityWorkstationRebirth ||
tileEntity is TileEntityWorkstation))
{
return false;
}
_player.AimingGun = false;
Vector3i worldPos = tileEntity.ToWorldPos();
_world.GetGameManager().TELockServer(_cIdx, worldPos, tileEntity.entityId, _player.entityId);
return true;
}
public override void OnBlockValueChanged(
WorldBase _world,
Chunk _chunk,
int _clrIdx,
Vector3i _blockPos,
BlockValue _oldBlockValue,
BlockValue _newBlockValue)
{
base.OnBlockValueChanged(_world, _chunk, _clrIdx, _blockPos, _oldBlockValue, _newBlockValue);
this.checkParticles(_world, _clrIdx, _blockPos, _newBlockValue);
}
public override byte GetLightValue(BlockValue _blockValue) => 0;
[PublicizedFrom(EAccessModifier.Protected)]
public override void checkParticles(
WorldBase _world,
int _clrIdx,
Vector3i _blockPos,
BlockValue _blockValue)
{
if (_blockValue.ischild)
return;
bool flag = GameManager.Instance.HasBlockParticleEffect(_blockPos);
if (_blockValue.meta != (byte)0 && !flag)
{
this.addParticles(_world, _clrIdx, _blockPos.x, _blockPos.y, _blockPos.z, _blockValue);
if ((double)this.CraftingParticleLightIntensity <= 0.0)
return;
this.UpdateVisible(_world, _blockPos);
}
else
{
if (!(_blockValue.meta == (byte)0 & flag))
return;
this.removeParticles(_world, _blockPos.x, _blockPos.y, _blockPos.z, _blockValue);
}
}
public static bool IsLit(BlockValue _blockValue) => _blockValue.meta > (byte)0;
public override string GetActivationText(
WorldBase _world,
BlockValue _blockValue,
int _clrIdx,
Vector3i _blockPos,
EntityAlive _entityFocusing)
{
return Localization.Get("useWorkstation");
}
public override bool OnBlockActivated(
string _commandName,
WorldBase _world,
int _cIdx,
Vector3i _blockPos,
BlockValue _blockValue,
EntityPlayerLocal _player)
{
//Log.Out("BlockWorkstation-OnBlockActivated B START");
switch (_commandName)
{
case "open":
return this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
case "take":
this.TakeItemWithTimer(_cIdx, _blockPos, _blockValue, (EntityAlive)_player);
return true;
default:
return false;
}
}
public override bool HasBlockActivationCommands(
WorldBase _world,
BlockValue _blockValue,
int _clrIdx,
Vector3i _blockPos,
EntityAlive _entityFocusing)
{
return true;
}
public override BlockActivationCommand[] GetBlockActivationCommands(
WorldBase _world,
BlockValue _blockValue,
int _clrIdx,
Vector3i _blockPos,
EntityAlive _entityFocusing)
{
bool flag1 = _world.IsMyLandProtectedBlock(_blockPos, _world.GetGameManager().GetPersistentLocalPlayer());
TileEntity tileEntity = _world.GetTileEntity(_blockPos);
bool flag2 = false;
bool flag3 = false;
if (tileEntity is TileEntityWorkstationRebirth)
{
TileEntityWorkstationRebirth tileEntityWS = (TileEntityWorkstationRebirth)tileEntity;
if (tileEntity != null)
{
flag2 = tileEntityWS.IsPlayerPlaced;
}
PersistentPlayerData playerData = _world.GetGameManager().GetPersistentPlayerList().GetPlayerData(tileEntityWS.GetOwner());
if (playerData != null)
{
flag3 = true;
}
}
else if (tileEntity is TileEntityWorkstation)
{
TileEntityWorkstation tileEntityWS = (TileEntityWorkstation)tileEntity;
if (tileEntity != null)
{
flag2 = tileEntityWS.IsPlayerPlaced;
}
}
//Log.Out("BlockWorkstationRebirth-GetBlockActivationCommands flag1: " + flag1);
//Log.Out("BlockWorkstationRebirth-GetBlockActivationCommands flag2: " + flag2);
//Log.Out("BlockWorkstationRebirth-GetBlockActivationCommands flag3: " + flag3);
this.cmds[1].enabled = flag3 || (flag1 & flag2 && (double)this.TakeDelay > 0.0);
return this.cmds;
}
[PublicizedFrom(EAccessModifier.Private)]
public void TakeItemWithTimer(
int _cIdx,
Vector3i _blockPos,
BlockValue _blockValue,
EntityAlive _player)
{
if (_blockValue.damage > 0)
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttRepairBeforePickup"), string.Empty, "ui_denied");
else
{
TileEntity tileEntity = _player.world.GetTileEntity(_blockPos);
bool take = false;
if (tileEntity is TileEntityWorkstationRebirth)
{
TileEntityWorkstationRebirth tileEntityWS = (TileEntityWorkstationRebirth)tileEntity;
if (!(GameManager.Instance.World.GetTileEntity(_blockPos) as TileEntityWorkstationRebirth).IsEmpty)
{
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttWorkstationNotEmpty"), string.Empty, "ui_denied");
}
else
{
take = true;
}
}
else if (tileEntity is TileEntityWorkstation)
{
TileEntityWorkstation tileEntityWS = (TileEntityWorkstation)tileEntity;
if (!(GameManager.Instance.World.GetTileEntity(_blockPos) as TileEntityWorkstation).IsEmpty)
{
GameManager.ShowTooltip(_player as EntityPlayerLocal, Localization.Get("ttWorkstationNotEmpty"), string.Empty, "ui_denied");
}
else
{
take = true;
}
}
if (take)
{
LocalPlayerUI playerUi = (_player as EntityPlayerLocal).PlayerUI;
playerUi.windowManager.Open("timer", true);
XUiC_Timer childByType = playerUi.xui.GetChildByType<XUiC_Timer>();
TimerEventData _eventData = new TimerEventData();
_eventData.Data = (object)new object[4]
{
(object) _cIdx,
(object) _blockValue,
(object) _blockPos,
(object) _player
};
_eventData.Event += new TimerEventHandler(this.EventData_Event);
childByType.SetTimer(this.TakeDelay, _eventData);
}
}
}
[PublicizedFrom(EAccessModifier.Private)]
public void EventData_Event(TimerEventData timerData)
{
World world = GameManager.Instance.World;
object[] data = (object[])timerData.Data;
int _clrIdx = (int)data[0];
BlockValue blockValue = (BlockValue)data[1];
Vector3i vector3i = (Vector3i)data[2];
BlockValue block = world.GetBlock(vector3i);
EntityPlayerLocal entityPlayerLocal = data[3] as EntityPlayerLocal;
if (block.damage > 0)
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttRepairBeforePickup"), string.Empty, "ui_denied");
else if (block.type != blockValue.type)
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttBlockMissingPickup"), string.Empty, "ui_denied");
else
{
TileEntity tileEntity = entityPlayerLocal.world.GetTileEntity(vector3i);
bool proceeed = false;
if (tileEntity is TileEntityWorkstationRebirth)
{
TileEntityWorkstationRebirth tileEntityWS = (TileEntityWorkstationRebirth)tileEntity;
if (tileEntityWS.IsUserAccessing())
{
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttCantPickupInUse"), string.Empty, "ui_denied");
}
else
{
proceeed = true;
}
}
else if (tileEntity is TileEntityWorkstation)
{
TileEntityWorkstation tileEntityWS = (TileEntityWorkstation)tileEntity;
if (tileEntityWS.IsUserAccessing())
{
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get("ttCantPickupInUse"), string.Empty, "ui_denied");
}
else
{
proceeed = true;
}
}
if (proceeed)
{
LocalPlayerUI uiForPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal);
ItemStack itemStack = new ItemStack(block.ToItemValue(), 1);
if (!uiForPlayer.xui.PlayerInventory.AddItem(itemStack))
uiForPlayer.xui.PlayerInventory.DropItem(itemStack);
world.SetBlockRPC(_clrIdx, vector3i, BlockValue.Air);
}
}
}
public override void OnBlockEntityTransformBeforeActivated(
WorldBase _world,
Vector3i _blockPos,
BlockValue _blockValue,
BlockEntityData _ebcd)
{
base.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _blockValue, _ebcd);
this.UpdateVisible(_world, _blockPos);
}
public void UpdateVisible(WorldBase _world, Vector3i _blockPos)
{
TileEntity tileEntity = _world.GetTileEntity(_blockPos);
if (tileEntity is TileEntityWorkstationRebirth ||
tileEntity is TileEntityWorkstation)
{
this.UpdateVisible(tileEntity);
}
}
public void UpdateVisible(TileEntity tileEntity)
{
if (tileEntity is TileEntityWorkstationRebirth)
{
TileEntityWorkstationRebirth _te = (TileEntityWorkstationRebirth)tileEntity;
BlockEntityData blockEntity = _te.GetChunk().GetBlockEntity(_te.ToWorldPos());
if (blockEntity == null)
return;
Transform transform1 = blockEntity.transform;
if (!(bool)(UnityEngine.Object)transform1)
return;
ItemStack[] tools = _te.Tools;
int num = Utils.FastMin(tools.Length, this.toolTransformNames.Length);
for (int index = 0; index < num; ++index)
{
Transform transform2 = transform1.Find(this.toolTransformNames[index]);
if ((bool)(UnityEngine.Object)transform2)
transform2.gameObject.SetActive(!tools[index].IsEmpty());
}
Transform transform3 = transform1.Find("craft");
if (!(bool)(UnityEngine.Object)transform3)
return;
bool isCrafting = _te.IsCrafting;
transform3.gameObject.SetActive(isCrafting);
if ((double)this.CraftingParticleLightIntensity <= 0.0)
return;
Transform blockParticleEffect = GameManager.Instance.GetBlockParticleEffect(_te.ToWorldPos());
if ((bool)(UnityEngine.Object)blockParticleEffect)
{
Light componentInChildren = blockParticleEffect.GetComponentInChildren<Light>();
if (!(bool)(UnityEngine.Object)componentInChildren)
return;
componentInChildren.intensity = isCrafting ? this.CraftingParticleLightIntensity : 1f;
}
else
{
if (!isCrafting)
return;
_te.SetVisibleChanged();
}
}
else if (tileEntity is TileEntityWorkstation)
{
TileEntityWorkstation _te = (TileEntityWorkstation)tileEntity;
BlockEntityData blockEntity = _te.GetChunk().GetBlockEntity(_te.ToWorldPos());
if (blockEntity == null)
return;
Transform transform1 = blockEntity.transform;
if (!(bool)(UnityEngine.Object)transform1)
return;
ItemStack[] tools = _te.Tools;
int num = Utils.FastMin(tools.Length, this.toolTransformNames.Length);
for (int index = 0; index < num; ++index)
{
Transform transform2 = transform1.Find(this.toolTransformNames[index]);
if ((bool)(UnityEngine.Object)transform2)
transform2.gameObject.SetActive(!tools[index].IsEmpty());
}
Transform transform3 = transform1.Find("craft");
if (!(bool)(UnityEngine.Object)transform3)
return;
bool isCrafting = _te.IsCrafting;
transform3.gameObject.SetActive(isCrafting);
if ((double)this.CraftingParticleLightIntensity <= 0.0)
return;
Transform blockParticleEffect = GameManager.Instance.GetBlockParticleEffect(_te.ToWorldPos());
if ((bool)(UnityEngine.Object)blockParticleEffect)
{
Light componentInChildren = blockParticleEffect.GetComponentInChildren<Light>();
if (!(bool)(UnityEngine.Object)componentInChildren)
return;
componentInChildren.intensity = isCrafting ? this.CraftingParticleLightIntensity : 1f;
}
else
{
if (!isCrafting)
return;
_te.SetVisibleChanged();
}
}
}
}