Upload from upload_mods.ps1
This commit is contained in:
986
Scripts/Blocks/BlockPlantGrowingRebirth.cs
Normal file
986
Scripts/Blocks/BlockPlantGrowingRebirth.cs
Normal file
@@ -0,0 +1,986 @@
|
||||
using System.Globalization;
|
||||
|
||||
public class BlockPlantGrowingRebirth : BlockPlant
|
||||
{
|
||||
protected float nextStageRate;
|
||||
public string nextStage;
|
||||
public ulong TickRate = 100UL;
|
||||
//public System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
|
||||
protected int lightLevelGrow = 3;
|
||||
protected static string PropGrowingFertileLevel = "PlantGrowing.FertileLevel";
|
||||
protected static string PropGrowingLightLevelStay = "PlantGrowing.LightLevelStay";
|
||||
protected static string PropGrowingLightLevelGrow = "PlantGrowing.LightLevelGrow";
|
||||
public byte sunLight = 0;
|
||||
public byte blockLight = 0;
|
||||
public int minTemp = 45;
|
||||
|
||||
public override bool HasBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-HasBlockActivationCommands START");
|
||||
bool flag = _world.GetTileEntity(_clrIdx, _blockPos) is TileEntityPlantGrowingRebirth;
|
||||
bool flag2 = this.CanPickup;
|
||||
if (EffectManager.GetValue(PassiveEffects.BlockPickup, null, 0f, _entityFocusing, null, _blockValue.Block.Tags, true, true, true, true, true, 1, false) > 0f)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-HasBlockActivationCommands 1");
|
||||
flag2 = true;
|
||||
}
|
||||
return flag2 || flag;
|
||||
}
|
||||
|
||||
private BlockActivationCommand[] cmds = new BlockActivationCommand[]
|
||||
{
|
||||
new BlockActivationCommand("Search", "search", true, false)
|
||||
};
|
||||
|
||||
public override void OnBlockLoaded(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
base.OnBlockLoaded(_world, _clrIdx, _blockPos, _blockValue);
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
_world.GetWBT().AddScheduledBlockUpdate(chunk.ClrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
}
|
||||
|
||||
public override void LateInit()
|
||||
{
|
||||
base.LateInit();
|
||||
if (this.Properties.Values.ContainsKey(PropGrowingFertileLevel))
|
||||
{
|
||||
this.fertileLevel = int.Parse(this.Properties.Values[PropGrowingFertileLevel]);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(PropGrowingLightLevelStay))
|
||||
{
|
||||
this.lightLevelStay = int.Parse(this.Properties.Values[PropGrowingLightLevelStay]);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey(PropGrowingLightLevelGrow))
|
||||
{
|
||||
this.lightLevelGrow = int.Parse(this.Properties.Values[PropGrowingLightLevelGrow]);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanGrowOn(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValueOfPlant)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn START");
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn fertileLevel: " + fertileLevel);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn block fertile level: " + _world.GetBlock(_clrIdx, _blockPos).Block.blockMaterial.FertileLevel);
|
||||
|
||||
bool bFertileLevel = this.fertileLevel == 0;
|
||||
bool bFertileLevel2 = _world.GetBlock(_clrIdx, _blockPos).Block.blockMaterial.FertileLevel >= this.fertileLevel;
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn bFertileLevel: " + bFertileLevel);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanGrowOn bFertileLevel2: " + bFertileLevel2);
|
||||
|
||||
return bFertileLevel || bFertileLevel2;
|
||||
}
|
||||
|
||||
public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt START");
|
||||
if (GameManager.Instance.IsEditMode())
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 1");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bCanPlaceBlock = base.CanPlaceBlockAt(_world, _clrIdx, _blockPos, _blockValue, _bOmitCollideCheck);
|
||||
bool bCanGrow = this.CanGrowOn(_world, _clrIdx, _blockPos - Vector3i.up, _blockValue);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt bCanPlaceBlock: " + bCanPlaceBlock);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt bCanGrow: " + bCanGrow);
|
||||
|
||||
if (!(bCanPlaceBlock && bCanGrow))
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 2");
|
||||
return false;
|
||||
}
|
||||
Vector3i blockPos = _blockPos + Vector3i.up;
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 3");
|
||||
byte light = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN);
|
||||
byte light2 = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.BLOCK);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt light: " + light);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt light2: " + light2);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt this.lightLevelStay: " + this.lightLevelStay);
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt this.lightLevelGrow: " + this.lightLevelGrow);
|
||||
|
||||
if ((int)light < this.lightLevelStay || (int)light < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 4");
|
||||
if ((int)light2 < this.lightLevelStay || (int)light2 < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-CanPlaceBlockAt 5");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual void addTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
TileEntityPlantGrowingRebirth tileEntityPlantGrowing = new TileEntityPlantGrowingRebirth(_chunk);
|
||||
tileEntityPlantGrowing.localChunkPos = World.toBlock(_blockPos);
|
||||
_chunk.AddTileEntity(tileEntityPlantGrowing);
|
||||
}
|
||||
|
||||
protected virtual void removeTileEntity(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-removeTileEntity START");
|
||||
_chunk.RemoveTileEntityAt<TileEntityPlantGrowingRebirth>((World)world, World.toBlock(_blockPos));
|
||||
}
|
||||
|
||||
public override void OnBlockRemoved(WorldBase world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockRemoved START, BLOCK: " + _blockValue.Block.GetBlockName());
|
||||
base.OnBlockRemoved(world, _chunk, _blockPos, _blockValue);
|
||||
TileEntityPlantGrowingRebirth tileEntityPlantGrowing = world.GetTileEntity(_chunk.ClrIdx, _blockPos) as TileEntityPlantGrowingRebirth;
|
||||
if (tileEntityPlantGrowing != null)
|
||||
{
|
||||
tileEntityPlantGrowing.OnDestroy();
|
||||
}
|
||||
this.removeTileEntity(world, _chunk, _blockPos, _blockValue);
|
||||
}
|
||||
|
||||
public override void OnBlockAdded(WorldBase _world, Chunk _chunk, Vector3i _blockPos, BlockValue _blockValue)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockAdded START, BLOCK: " + _blockValue.Block.GetBlockName());
|
||||
base.OnBlockAdded(_world, _chunk, _blockPos, _blockValue);
|
||||
this.addTileEntity(_world, _chunk, _blockPos, _blockValue);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer) return;
|
||||
if (GameManager.Instance.IsEditMode()) return;
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockAdded 1");
|
||||
|
||||
_blockValue.meta = 0;
|
||||
|
||||
//Log.Out("============================ON BLOCK ADDED=================================");
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockAdded MY POSITION: " + _blockPos);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-OnBlockAdded this.GetTickRate(): " + this.GetTickRate());
|
||||
//watch.Reset();
|
||||
//watch.Start();
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_chunk.ClrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
|
||||
public override bool UpdateTick(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bRandomTick, ulong _ticksIfLoaded, GameRandom _rnd)
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick START, _blockPos: " + _blockPos + " / BLOCK: " + _blockValue.Block.GetBlockName());
|
||||
|
||||
ulong GameTimerTicks = 0UL;
|
||||
ulong TotalTimerTicks = 0UL;
|
||||
ulong CurrentTimerTicks = 0UL;
|
||||
ulong TicksOverThreshold = 0UL;
|
||||
ulong CurrentStageRate = this.GetTickRate();
|
||||
|
||||
TileEntityPlantGrowingRebirth tileEntityPlantGrowing = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityPlantGrowingRebirth;
|
||||
|
||||
//watch.Stop();
|
||||
|
||||
bool advancedFarming = RebirthVariables.customAdvancedFarming;
|
||||
int cropGrowthTime = RebirthVariables.customAdvancedFarmingTime * 60;
|
||||
|
||||
if (RebirthVariables.testCropGrowth)
|
||||
{
|
||||
cropGrowthTime = 1;
|
||||
}
|
||||
|
||||
bool bflag = false;
|
||||
|
||||
string currentBiome = "";
|
||||
|
||||
BiomeDefinition biome = GameManager.Instance.World.GetBiome(_blockPos.x, _blockPos.z);
|
||||
if (biome != null)
|
||||
{
|
||||
currentBiome = biome.m_sBiomeName;
|
||||
}
|
||||
|
||||
if (currentBiome == "wasteland")
|
||||
{
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick sBiomeName: " + currentBiome);
|
||||
|
||||
if (tileEntityPlantGrowing != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1");
|
||||
tileEntityPlantGrowing.bUpdating = false;
|
||||
GameTimerTicks = tileEntityPlantGrowing.GameTimerTicks;
|
||||
tileEntityPlantGrowing.GameTimerTicks = GameTimer.Instance.ticks;
|
||||
TotalTimerTicks = GameTimer.Instance.ticks;
|
||||
CurrentTimerTicks = TotalTimerTicks - GameTimerTicks;
|
||||
|
||||
bool bHasSunLight = true;
|
||||
bool bHasBlockLight = true;
|
||||
|
||||
Vector3i blockPos = _blockPos + Vector3i.up;
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
|
||||
if (chunkCluster != null && advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1a");
|
||||
byte light = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN);
|
||||
byte light2 = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.BLOCK);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick sun light: " + light);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick block light: " + light2);
|
||||
|
||||
if ((int)light < this.lightLevelStay || (int)light < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1b");
|
||||
bHasSunLight = false;
|
||||
}
|
||||
if ((int)light2 < this.lightLevelStay || (int)light2 < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1c");
|
||||
bHasBlockLight = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsNight = false;
|
||||
if (!GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1d");
|
||||
bIsNight = true;
|
||||
}
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && RebirthUtilities.IsHiveDayActive())
|
||||
{
|
||||
bHasSunLight = false;
|
||||
bIsNight = true;
|
||||
}
|
||||
|
||||
float num = WeatherManager.Instance.GetCurrentTemperatureValue();
|
||||
float numClouds = 0;
|
||||
float numRain = 0;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
num = RebirthUtilities.GetWeatherInfo(_blockPos, "temp");
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numTemp: " + num);
|
||||
numClouds = RebirthUtilities.GetWeatherInfo(_blockPos, "clouds") / 10;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numClouds: " + numClouds);
|
||||
numRain = RebirthUtilities.GetWeatherInfo(_blockPos, "wet") * 10;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numRain: " + numRain);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numTemp: " + num);
|
||||
numRain = 10 * WeatherManager.Instance.GetCurrentRainfallValue();
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numRain: " + numRain);
|
||||
numClouds = 10 * WeatherManager.Instance.GetCurrentCloudThicknessPercent();
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numClouds: " + numClouds);
|
||||
}
|
||||
|
||||
num = num - (numRain + numClouds);
|
||||
|
||||
//bool hasHeat = RebirthUtilities.CheckForHeat(_world, _clrIdx, _blockPos, "campfire", 6, 3, 1);
|
||||
//bool hasHeat2 = RebirthUtilities.CheckForHeat(_world, _clrIdx, _blockPos, "cntWoodBurningStove_PickedUp", 10, 5, 1);
|
||||
bool hasHeat = RebirthUtilities.CheckForHeat(_blockPos, 6, "12", "campfire");
|
||||
bool hasHeat2 = RebirthUtilities.CheckForHeat(_blockPos, 10, "12", "cntWoodBurningStove_PickedUp");
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasHeat: " + hasHeat);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasHeat2: " + hasHeat2);
|
||||
|
||||
if (hasHeat)
|
||||
{
|
||||
num = num + 30;
|
||||
}
|
||||
else if (hasHeat2)
|
||||
|
||||
{
|
||||
num = num + 50;
|
||||
}
|
||||
|
||||
if (!bHasSunLight)
|
||||
{
|
||||
if (currentBiome == "pine_forest")
|
||||
{
|
||||
if (bIsNight)
|
||||
{
|
||||
num = num + 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num - 5;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick pine_forest Temperature: " + num);
|
||||
}
|
||||
if (currentBiome == "desert")
|
||||
{
|
||||
if (bIsNight)
|
||||
{
|
||||
num = num - 20;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num - 10;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick desert Temperature: " + num);
|
||||
}
|
||||
if (currentBiome == "snow")
|
||||
{
|
||||
if (bIsNight)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num + 10;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick snow Temperature: " + num);
|
||||
}
|
||||
if (currentBiome == "wasteland")
|
||||
{
|
||||
if (bIsNight)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
num = num + 5;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick wasteland Temperature: " + num);
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick Is Inside Temperature: " + num);
|
||||
}
|
||||
|
||||
if (num < minTemp && advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1e num: " + num);
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!tileEntityPlantGrowing.bWatered && advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1f");
|
||||
|
||||
//int hasWaterInTank = RebirthUtilities.CheckForWater(_world, _clrIdx, _blockPos, "FuriousRamsayWaterTank", 4, 1, 0);
|
||||
//int hasWaterInCollector = RebirthUtilities.CheckForWater(_world, _clrIdx, _blockPos, "FuriousRamsayDewCollector", 4, 1, 0);
|
||||
|
||||
int hasWaterInTank = RebirthUtilities.CheckForWater(_blockPos, 4, "250", "FuriousRamsayWaterTank");
|
||||
int hasWaterInCollector = RebirthUtilities.CheckForWater(_blockPos, 4, "250", "FuriousRamsayDewCollector");
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasWaterInTank: " + hasWaterInTank);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasWaterInCollector: " + hasWaterInCollector);
|
||||
|
||||
int depletion = 1;
|
||||
|
||||
bool isHeatResistant = false;
|
||||
string plantName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (plantName.ToLower().Contains("yucca") ||
|
||||
plantName.ToLower().Contains("cotton") ||
|
||||
plantName.ToLower().Contains("coffee") ||
|
||||
plantName.ToLower().Contains("aloe")
|
||||
)
|
||||
{
|
||||
isHeatResistant = true;
|
||||
}
|
||||
|
||||
if (num >= 80 && !isHeatResistant)
|
||||
{
|
||||
depletion = depletion * 2;
|
||||
}
|
||||
|
||||
Vector3i farmPlotPos = _blockPos;
|
||||
farmPlotPos.y = farmPlotPos.y - 1;
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick X farmPlotPos: " + farmPlotPos);
|
||||
|
||||
BlockValue blockFarmPlot = _world.GetBlock(_clrIdx, farmPlotPos);
|
||||
|
||||
TileEntity tileEntity = _world.GetTileEntity(_clrIdx, farmPlotPos);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick X tileEntity: " + tileEntity.GetTileEntityType());
|
||||
}
|
||||
|
||||
TileEntityFarmPlotRebirth tileEntityFarmPlotRebirth;
|
||||
if (tileEntity is TileEntityFarmPlotRebirth)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1g");
|
||||
tileEntityFarmPlotRebirth = (TileEntityFarmPlotRebirth)tileEntity;
|
||||
|
||||
if (tileEntityFarmPlotRebirth.waterCount >= depletion)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick deplete from farm plot");
|
||||
tileEntityFarmPlotRebirth.waterCount = tileEntityFarmPlotRebirth.waterCount - depletion;
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateFarmPlotRebirth>().Setup(_clrIdx, farmPlotPos, tileEntityFarmPlotRebirth.waterCount));
|
||||
depletion = 0;
|
||||
tileEntityPlantGrowing.bWatered = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tileEntityPlantGrowing.bWatered)
|
||||
{
|
||||
if (hasWaterInCollector >= depletion)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1h");
|
||||
RebirthUtilities.DepleteWater(_world, _clrIdx, _blockPos, "FuriousRamsayDewCollector", 4, 1, 0, depletion);
|
||||
tileEntityPlantGrowing.bWatered = true;
|
||||
}
|
||||
if (hasWaterInTank >= depletion)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1h");
|
||||
RebirthUtilities.DepleteWater(_world, _clrIdx, _blockPos, "FuriousRamsayWaterTank", 4, 1, 0, depletion);
|
||||
tileEntityPlantGrowing.bWatered = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1i");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1j");
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick GameTimerTicks: " + GameTimerTicks);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick GameTimer.Instance.ticks: " + GameTimer.Instance.ticks);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick CurrentTimerTicks: " + CurrentTimerTicks);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick this.TickRate: " + this.TickRate);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick this.GetTickRate(): " + CurrentStageRate);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick bHasSunLight: " + bHasSunLight);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick bHasBlockLight: " + bHasBlockLight);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1k");
|
||||
|
||||
if (_blockValue.Block.GetBlockName().ToLower().Contains("mushroom"))
|
||||
{
|
||||
bHasBlockLight = true;
|
||||
}
|
||||
|
||||
if ((((bHasSunLight && !bIsNight) || bHasBlockLight) && advancedFarming) || !advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1l");
|
||||
bool hasObserverTank = RebirthUtilities.HasObserver(_world, _clrIdx, _blockPos, "FuriousRamsayWaterTank", 4, 1, 0);
|
||||
bool hasObserverCollector = RebirthUtilities.HasObserver(_world, _clrIdx, _blockPos, "FuriousRamsayDewCollector", 4, 1, 0);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasObserverTank: " + hasObserverTank);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick hasObserverCollector: " + hasObserverCollector);
|
||||
|
||||
if (hasObserverTank || hasObserverCollector)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1m");
|
||||
tileEntityPlantGrowing.AccumulatedTicks = tileEntityPlantGrowing.AccumulatedTicks + this.TickRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1n");
|
||||
tileEntityPlantGrowing.AccumulatedTicks = tileEntityPlantGrowing.AccumulatedTicks + CurrentTimerTicks;
|
||||
}
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdatePlantedCropRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityPlantGrowing.AccumulatedTicks), false, -1, -1, -1, null, 192);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick AccumulatedTicks A: " + tileEntityPlantGrowing.AccumulatedTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1o");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks > CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 1p");
|
||||
TicksOverThreshold = tileEntityPlantGrowing.AccumulatedTicks - CurrentStageRate;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick TicksOverThreshold: " + TicksOverThreshold);
|
||||
}
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks >= CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 2");
|
||||
bflag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 3");
|
||||
bflag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick tileEntityPlantGrowing == null");
|
||||
}
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick bflag: " + bflag);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick this.nextStage: " + this.nextStage);
|
||||
|
||||
if (bflag && this.nextStage != "")
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 4");
|
||||
BlockValue blockValue = Block.GetBlockValue(this.nextStage, true);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick GetBlockName: " + blockValue.Block.GetBlockName());
|
||||
|
||||
string strNextStageRate = blockValue.Block.Properties.Values["NextStageRate"];
|
||||
string strNextStage = blockValue.Block.Properties.Values["NextStage"];
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick strNextStageRate: " + strNextStageRate);
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick strNextStage: " + strNextStage);
|
||||
|
||||
if (!blockValue.Block.GetBlockName().Contains("3"))
|
||||
{
|
||||
float flNextStageRate = StringParsers.ParseFloat(strNextStageRate, 0, -1, NumberStyles.Any);
|
||||
|
||||
if (advancedFarming)
|
||||
{
|
||||
flNextStageRate = cropGrowthTime;
|
||||
}
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks >= (flNextStageRate * 20) + CurrentStageRate)
|
||||
{
|
||||
blockValue = Block.GetBlockValue(blockValue.Block.Properties.Values["NextStage"], true);
|
||||
}
|
||||
}
|
||||
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(_blockPos);
|
||||
blockValue = BlockPlaceholderMap.Instance.Replace(blockValue, _world.GetGameRandom(), chunk, _blockPos.x, _blockPos.y, _blockPos.z, FastTags<TagGroup.Global>.none, false);
|
||||
blockValue.meta = _blockValue.meta;
|
||||
blockValue.damage = _blockValue.damage;
|
||||
blockValue.meta2 = 0;
|
||||
_blockValue = blockValue;
|
||||
|
||||
_blockValue.meta = (byte)(_blockValue.meta + 1 & 15);
|
||||
_blockValue = _blockValue.Block.OnBlockPlaced(_world, _clrIdx, _blockPos, _blockValue, _rnd);
|
||||
|
||||
Block block3 = blockValue.Block;
|
||||
|
||||
_world.SetBlockRPC(_clrIdx, _blockPos, blockValue);
|
||||
|
||||
DynamicMeshManager.ChunkChanged(_blockPos, -1, _blockValue.type);
|
||||
|
||||
tileEntityPlantGrowing = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityPlantGrowingRebirth;
|
||||
|
||||
if (tileEntityPlantGrowing != null)
|
||||
{
|
||||
if (TicksOverThreshold > 0)
|
||||
{
|
||||
tileEntityPlantGrowing.AccumulatedTicks = TicksOverThreshold;
|
||||
}
|
||||
else
|
||||
{
|
||||
tileEntityPlantGrowing.AccumulatedTicks = 0;
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick AccumulatedTicks B: " + tileEntityPlantGrowing.AccumulatedTicks);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdatePlantedCropRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityPlantGrowing.AccumulatedTicks), false, -1, -1, -1, null, 192);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//watch.Reset();
|
||||
//watch.Start();
|
||||
|
||||
if (tileEntityPlantGrowing != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 5");
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks <= CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 6");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 7");
|
||||
tileEntityPlantGrowing.AccumulatedTicks = 0UL;
|
||||
}
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageUpdatePlantedCropRebirth>().Setup(_clrIdx, _blockPos, _blockValue.Block.blockID, tileEntityPlantGrowing.AccumulatedTicks), false, -1, -1, -1, null, 192); ;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick tileEntityPlantGrowing.AccumulatedTicks C: " + tileEntityPlantGrowing.AccumulatedTicks);
|
||||
}
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick 8 ADD SCHEDULED BLOCK UPDATE");
|
||||
_world.GetWBT().AddScheduledBlockUpdate(_clrIdx, _blockPos, this.blockID, this.TickRate);
|
||||
}
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick END");
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText START");
|
||||
string activationText = Localization.Get("ttGatherNothing");
|
||||
|
||||
bool advancedFarming = RebirthVariables.customAdvancedFarming;
|
||||
|
||||
string myEntityName = "";
|
||||
string key = this.GetBlockName();
|
||||
string blockLocalization = Localization.Get(key);
|
||||
|
||||
|
||||
if (key.Contains("1"))
|
||||
{
|
||||
blockLocalization = string.Format(Localization.Get("pickupPrompt"), Localization.Get(key));
|
||||
}
|
||||
|
||||
//Log.Out("=========================GET ACTIVATION TEXT==============================");
|
||||
//Log.Out("key: " + key + "(" + blockLocalization + ")");
|
||||
|
||||
TileEntityPlantGrowingRebirth tileEntityPlantGrowing = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityPlantGrowingRebirth;
|
||||
bool canShowCycleTime = true;
|
||||
ulong GameTimerTicks = 0UL;
|
||||
ulong TotalTimerTicks = 0UL;
|
||||
ulong CurrentTimerTicks = 0UL;
|
||||
float TempTimerTicks = 0;
|
||||
ulong CurrentStageRate = this.GetTickRate();
|
||||
|
||||
if (tileEntityPlantGrowing == null)
|
||||
{
|
||||
canShowCycleTime = false;
|
||||
//Log.Out("=========================NO TILE ENTITY==============================");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 1");
|
||||
GameTimerTicks = tileEntityPlantGrowing.GameTimerTicks;
|
||||
TotalTimerTicks = GameTimer.Instance.ticks;
|
||||
CurrentTimerTicks = TotalTimerTicks - GameTimerTicks;
|
||||
|
||||
if (tileEntityPlantGrowing.AccumulatedTicks <= CurrentStageRate)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 2");
|
||||
TempTimerTicks = (CurrentStageRate - tileEntityPlantGrowing.AccumulatedTicks) / 1200;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 3");
|
||||
TempTimerTicks = -1;
|
||||
}
|
||||
|
||||
//Log.Out("GameTimerTicks: " + GameTimerTicks);
|
||||
//Log.Out("GameTimer.Instance.ticks: " + TotalTimerTicks);
|
||||
//Log.Out("CurrentTimerTicks = GameTimer.Instance.ticks - GameTimerTicks: " + CurrentTimerTicks);
|
||||
//Log.Out("this.GetTickRate(): " + CurrentStageRate);
|
||||
//Log.Out("TempTimerTicks = (this.GetTickRate() - CurrentTimerTicks)/1200: " + TempTimerTicks);
|
||||
//Log.Out("tileEntityPlantGrowing.AccumulatedTicks: " + tileEntityPlantGrowing.AccumulatedTicks);
|
||||
}
|
||||
|
||||
if (key.Contains("3"))
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 4");
|
||||
activationText = Localization.Get(key.Replace("Player", "") + "Desc");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 5");
|
||||
string timerText = "";
|
||||
|
||||
if (TempTimerTicks > 1)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 6");
|
||||
timerText = " " + (int)TempTimerTicks + "[-] " + Localization.Get("ttMinutes") + "";
|
||||
}
|
||||
else if (TempTimerTicks == 1)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 7");
|
||||
timerText = " " + (int)TempTimerTicks + "[-] " + Localization.Get("ttMinute") + "";
|
||||
}
|
||||
else if (TempTimerTicks == 0)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 8");
|
||||
//timerText = " less than 1[-] " + Localization.Get("ttMinute") + "";
|
||||
}
|
||||
else if (TempTimerTicks < 0)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 9 RELAUNCHING UPDATE TICK");
|
||||
timerText = " " + Localization.Get("ttCalculating");
|
||||
}
|
||||
ulong seconds = ((CurrentStageRate - tileEntityPlantGrowing.AccumulatedTicks) / 20) % 60;
|
||||
|
||||
if (seconds > 1)
|
||||
{
|
||||
timerText = timerText + " [d6d97e]" + seconds + "[-] " + Localization.Get("ttSeconds");
|
||||
}
|
||||
else
|
||||
{
|
||||
timerText = timerText + " [d6d97e]" + seconds + "[-] " + Localization.Get("ttSecond");
|
||||
}
|
||||
|
||||
//Log.Out("canShowCycleTime: " + canShowCycleTime);
|
||||
if (canShowCycleTime)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 10");
|
||||
if (key.Contains("1"))
|
||||
{
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNextCycle1") + timerText;
|
||||
}
|
||||
else
|
||||
{
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNextCycle2") + timerText;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 11");
|
||||
activationText = blockLocalization;
|
||||
}
|
||||
}
|
||||
|
||||
bool bHasSunLight = true;
|
||||
bool bHasBlockLight = true;
|
||||
|
||||
Vector3i blockPos = _blockPos + Vector3i.up;
|
||||
ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx];
|
||||
if (chunkCluster != null)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 12");
|
||||
|
||||
byte sunLightSource = 0;
|
||||
byte blockLightSource = 0;
|
||||
|
||||
sunLightSource = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN);
|
||||
blockLightSource = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.BLOCK);
|
||||
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText sun light: " + sunLightSource);
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText this.lightLevelStay: " + this.lightLevelStay);
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText this.lightLevelGrow: " + this.lightLevelGrow);
|
||||
|
||||
if ((int)sunLightSource < this.lightLevelStay || (int)sunLightSource < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 13");
|
||||
bHasSunLight = false;
|
||||
}
|
||||
if ((int)blockLightSource < this.lightLevelStay || (int)blockLightSource < this.lightLevelGrow)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 14");
|
||||
bHasBlockLight = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsNight = false;
|
||||
if (!GameManager.Instance.World.IsDaytime())
|
||||
{
|
||||
bIsNight = true;
|
||||
}
|
||||
|
||||
if (_blockValue.Block.GetBlockName().ToLower().Contains("mushroom"))
|
||||
{
|
||||
bHasBlockLight = true;
|
||||
}
|
||||
|
||||
int numDay = GameUtils.WorldTimeToDays(GameManager.Instance.World.worldTime) % 7;
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip() && numDay != 2)
|
||||
{
|
||||
bHasSunLight = false;
|
||||
bIsNight = true;
|
||||
}
|
||||
|
||||
if (!((bHasSunLight && !bIsNight) || bHasBlockLight) && advancedFarming)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 17");
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNeedLight");
|
||||
}
|
||||
|
||||
int hasWaterInTank = RebirthUtilities.CheckForWater(_world, _clrIdx, _blockPos, "FuriousRamsayWaterTank", 4, 1, 0);
|
||||
int hasWaterInCollector = RebirthUtilities.CheckForWater(_world, _clrIdx, _blockPos, "FuriousRamsayDewCollector", 4, 1, 0);
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText hasWater: " + hasWater);
|
||||
|
||||
int depletion = 1;
|
||||
|
||||
string currentBiome = "";
|
||||
|
||||
BiomeDefinition biome = GameManager.Instance.World.GetBiome(_blockPos.x, _blockPos.z);
|
||||
if (biome != null)
|
||||
{
|
||||
currentBiome = biome.m_sBiomeName;
|
||||
}
|
||||
|
||||
if (currentBiome == "desert")
|
||||
{
|
||||
depletion = depletion * 2;
|
||||
}
|
||||
|
||||
Vector3i farmPlotPos = _blockPos;
|
||||
farmPlotPos.y = farmPlotPos.y - 1;
|
||||
BlockValue blockFarmPlot = _world.GetBlock(_clrIdx, farmPlotPos);
|
||||
|
||||
TileEntity tileEntity = _world.GetTileEntity(_clrIdx, farmPlotPos);
|
||||
Chunk chunk = (Chunk)_world.GetChunkFromWorldPos(farmPlotPos);
|
||||
|
||||
int waterFarmPlot = 0;
|
||||
|
||||
TileEntityFarmPlotRebirth tileEntityFarmPlotRebirth;
|
||||
if (tileEntity is TileEntityFarmPlotRebirth)
|
||||
{
|
||||
tileEntityFarmPlotRebirth = (TileEntityFarmPlotRebirth)tileEntity;
|
||||
|
||||
waterFarmPlot = tileEntityFarmPlotRebirth.waterCount;
|
||||
}
|
||||
|
||||
if ((waterFarmPlot < depletion) && advancedFarming)
|
||||
{
|
||||
if (hasWaterInTank == -1 && hasWaterInCollector == -1)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 18");
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNeedWater");
|
||||
}
|
||||
else if (hasWaterInTank == 0 || hasWaterInCollector == 0)
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-GetActivationText 19");
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNoWaterInTank");
|
||||
}
|
||||
|
||||
if (currentBiome == "wasteland")
|
||||
{
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNoGrowWasteland");
|
||||
}
|
||||
}
|
||||
|
||||
float num = WeatherManager.Instance.GetCurrentTemperatureValue();
|
||||
float numClouds = 0;
|
||||
float numRain = 0;
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
num = RebirthUtilities.GetWeatherInfo(_blockPos, "temp");
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numTemp: " + num);
|
||||
numClouds = RebirthUtilities.GetWeatherInfo(_blockPos, "clouds") / 5;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numClouds: " + numClouds);
|
||||
numRain = RebirthUtilities.GetWeatherInfo(_blockPos, "wet") * 10;
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick numRain: " + numRain);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numTemp: " + num);
|
||||
numRain = 10 * WeatherManager.Instance.GetCurrentRainfallValue();
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numRain: " + numRain);
|
||||
numClouds = 10 * WeatherManager.Instance.GetCurrentCloudThicknessPercent();
|
||||
//Log.Out("BlockPlantGrowingRebirth-UpdateTick LOCAL numClouds: " + numClouds);
|
||||
}
|
||||
|
||||
num = num - (numRain + numClouds);
|
||||
|
||||
bool hasHeat = RebirthUtilities.CheckForHeat(_world, _clrIdx, _blockPos, "campfire", 6, 3, 1);
|
||||
bool hasHeat2 = RebirthUtilities.CheckForHeat(_world, _clrIdx, _blockPos, "cntWoodBurningStove_PickedUp", 10, 5, 1);
|
||||
|
||||
if (hasHeat)
|
||||
{
|
||||
num = num + 20;
|
||||
}
|
||||
else if (hasHeat2)
|
||||
|
||||
{
|
||||
num = num + 40;
|
||||
}
|
||||
|
||||
if (bIsNight)
|
||||
{
|
||||
num = num - 10;
|
||||
}
|
||||
|
||||
if (!bHasSunLight)
|
||||
{
|
||||
if (currentBiome == "pine_forest")
|
||||
{
|
||||
num = num - 5;
|
||||
}
|
||||
if (currentBiome == "desert")
|
||||
{
|
||||
num = num - 10;
|
||||
}
|
||||
if (currentBiome == "snow")
|
||||
{
|
||||
num = num + 10;
|
||||
}
|
||||
if (currentBiome == "wasteland")
|
||||
{
|
||||
num = num + 5;
|
||||
}
|
||||
}
|
||||
|
||||
string color = "[6bafb0]";
|
||||
|
||||
if ((num < minTemp) && advancedFarming)
|
||||
{
|
||||
activationText = blockLocalization + "\n" + Localization.Get("ttNoGrowTooCold");
|
||||
color = "[e0dd7e]";
|
||||
}
|
||||
|
||||
bool isHeatResistant = false;
|
||||
string plantName = _blockValue.Block.GetBlockName();
|
||||
|
||||
if (plantName.ToLower().Contains("yucca") ||
|
||||
plantName.ToLower().Contains("cotton") ||
|
||||
plantName.ToLower().Contains("coffee") ||
|
||||
plantName.ToLower().Contains("aloe")
|
||||
)
|
||||
{
|
||||
isHeatResistant = true;
|
||||
}
|
||||
|
||||
if ((num >= 80 && !isHeatResistant) && advancedFarming)
|
||||
{
|
||||
activationText = activationText + Localization.Get("ttUsesMoreWater");
|
||||
color = "[d47474]";
|
||||
}
|
||||
|
||||
if (advancedFarming)
|
||||
{
|
||||
activationText = activationText + "\n(" + Localization.Get("ttCropTempStart") + minTemp + Localization.Get("ttCropTempEnd") + ": " + color + num.ToString("0.00") + "[-] " + Localization.Get("ttTempUnit") + ")";
|
||||
}
|
||||
|
||||
return (activationText);
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (this.Properties.Values.ContainsKey("NextStageRate"))
|
||||
{
|
||||
this.nextStageRate = StringParsers.ParseFloat(this.Properties.Values["NextStageRate"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("NextStage"))
|
||||
{
|
||||
this.nextStage = this.Properties.Values["NextStage"];
|
||||
}
|
||||
if (this.Properties.Values.ContainsKey("TickRate"))
|
||||
{
|
||||
this.TickRate = (ulong)StringParsers.ParseFloat(this.Properties.Values["TickRate"], 0, -1, NumberStyles.Any) * 20;
|
||||
}
|
||||
}
|
||||
|
||||
public override ulong GetTickRate()
|
||||
{
|
||||
bool advancedFarming = RebirthVariables.customAdvancedFarming;
|
||||
int cropGrowthTime = RebirthVariables.customAdvancedFarmingTime * 60;
|
||||
|
||||
if (RebirthVariables.testCropGrowth)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
ulong stageRate = (ulong)(this.nextStageRate * 20f);
|
||||
|
||||
stageRate = (ulong)(cropGrowthTime * 20f);
|
||||
|
||||
return stageRate;
|
||||
}
|
||||
|
||||
public BlockPlantGrowingRebirth()
|
||||
{
|
||||
this.HasTileEntity = true;
|
||||
}
|
||||
|
||||
public override bool OnBlockActivated(string _commandName, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player)
|
||||
{
|
||||
return _commandName == this.cmds[0].text && this.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
|
||||
}
|
||||
|
||||
public override BlockActivationCommand[] GetBlockActivationCommands(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing)
|
||||
{
|
||||
return this.cmds;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user