public Log(LogType type, string fileName) { StructureType = type; LogFile = new FileReader(fileName); string[] logFileStrings = LogFile.ReadFile(); Program.MainForm.InitProgressLevel(logFileStrings.Length, 0, "Processing Log..."); RootBlock = new BlockValue(StructureType.RootBlockType,ref logFileStrings); Program.MainForm.EndProgress(); }
public static bool WaterCheck(ClientInfo _cInfo, EntityPlayer _player, int x, int y, int z) { for (int i = x - 1; i <= (x + 1); i++) { for (int j = z - 1; j <= (z + 1); j++) { for (int k = y - 0; k <= (y + 2); k++) { BlockValue Block = GameManager.Instance.World.GetBlock(new Vector3i(i, k, j)); string _blockName = Block.Block.GetBlockName(); if (_blockName != "waterMoving" || _blockName != "water") { return(false); } } } } return(true); }
public void DestroySupportTower(Vector3i _blockPos) { DebugMsg("BlockDummyBoat DestroySupportTower: Destroying water support tower blocks"); BlockValue newBlockValue = Block.GetBlockValue("water"); Vector3i waterSupportPos = _blockPos; waterSupportPos.y -= 1; BlockValue curBlockValue = GameManager.Instance.World.GetBlock(waterSupportPos); Block curBlock = Block.list[curBlockValue.type]; while (curBlock.GetBlockName() == "waterSupportBlock") { //DebugMsg("Destroying tower block: " + curBlock.GetBlockName() + " | pos =" + waterSupportPos.ToString()); GameManager.Instance.World.SetBlockRPC(waterSupportPos, newBlockValue); waterSupportPos.y -= 1; curBlockValue = GameManager.Instance.World.GetBlock(waterSupportPos); curBlock = Block.list[curBlockValue.type]; } }
public override void Update() { this.time += 0.05f; //If we are close, be done with it. This is to help prevent the NPC from standing on certain workstations that its supposed to path too. float dist = Vector3.Distance(this.position, this.theEntity.position); if (dist < 2f) { DisplayLog("I am within 1f of the block: " + dist); BlockValue block = GameManager.Instance.World.GetBlock(new Vector3i(this.position)); if (block.type != BlockValue.Air.type || block.Block.GetBlockName() != "PathingCube") { DisplayLog("I am close enough to this block: " + block.Block.GetBlockName()); this.time = 90f; return; } } }
private void EventData_Event(object obj) { World world = GameManager.Instance.World; var eventData = obj as TimerEventData; object[] objArray = (object[])eventData.Data; int _clrIdx = (int)objArray[0]; BlockValue blockValue = (BlockValue)objArray[1]; Vector3i vector3i = (Vector3i)objArray[2]; BlockValue block = world.GetBlock(vector3i); EntityPlayerLocal entityPlayerLocal = objArray[3] as EntityPlayerLocal; if (block.damage > 0) { GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttRepairBeforePickup", string.Empty), "ui_denied"); } else if (block.type != blockValue.type) { GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttBlockMissingPickup", string.Empty), "ui_denied"); } else { TileEntitySecureLootContainer tileEntity = world.GetTileEntity(_clrIdx, vector3i) as TileEntitySecureLootContainer; if (tileEntity.IsUserAccessing()) { GameManager.ShowTooltipWithAlert(entityPlayerLocal, Localization.Get("ttCantPickupInUse", string.Empty), "ui_denied"); } else { LocalPlayerUI uiForPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayerLocal); ItemStack itemStack = new ItemStack(block.ToItemValue(), 1); if (!uiForPlayer.xui.PlayerInventory.AddItem(itemStack, true)) { uiForPlayer.xui.PlayerInventory.DropItem(itemStack); } world.SetBlockRPC(_clrIdx, vector3i, BlockValue.Air); } } }
private bool WillCollide(Entity entity, Vector3 toward) { // I should return block or entity ? // TODO: I should check the whole body boundingRect // only input position, not entity ? World world = GameManager.Instance.World; Vector3 pos = entity.GetPosition() + toward; Vector3i vector3i = World.worldToBlockPos(pos); BlockValue block = world.GetBlock(vector3i); int type = block.type; if (Block.list[type].IsMovementBlocked(world, vector3i, block, FaceFrom(toward))) { // Debug.Log("WillCollide !"); return(true); // EntityplayerLocal.pushOutOfBlocks() } return(false); }
public BlockPos Parent() { // in place, requires validation first ? if (! Value.ischild) return this; // if (! Value.Block.isMultiBlock) return this; int current_type = Value.Block.blockID; Vector3i ppos = Value.Block.multiBlockPos.GetParentPos(Pos, Value); BlockValue pexisting = GameManager.Instance.World.GetBlock(ppos); if (pexisting.Block.blockID != current_type) { Printer.Log(85, "Parent: changed blockID !", Pos, Value.Block,Value, "=>", ppos, pexisting, pexisting.Block); // throw new Exception(); return null; } if (pexisting.ischild) { Printer.Log(85, "Parent is child !", Pos, Value.Block,Value, "=>", ppos, pexisting, pexisting.Block); return null; } Value = pexisting; Pos = ppos; return this; }
private IEnumerator _Search(EntityPlayer player, int cycle=1, int repeat=1) { // TODO: check player motion since last reset ! World World = GameManager.Instance.World; for (int k=0; k<cycle; k++) { yield return SearchYield; _ResetTooFar(player); for (int q=0; q<repeat; q++) { Searcher.Next(); if (! Searcher.ok) {Printer.Log(85, "Searcher not ok !", Searcher.x, Searcher.y); yield break;} BlockValue existing = World.GetBlock(Searcher.Position); if (existing.ischild) continue; // inserts a single will help ! if (Positions.Count >= maxSize) continue; if (Selector != null && !Selector(existing.Block)) continue; Vector3i pos = Vectors.Copy(Searcher.Position); Printer.Log(85, "Found decoration:", existing.Block, pos, existing); Positions.Enqueue(pos); } } }
public static void AddFallingBlocks_Prefix(World __instance, IList <Vector3i> _list) { try { if (FallingBlocks.IsEnabled && _list != null) { for (int i = 0; i < _list.Count; i++) { BlockValue blockValue = __instance.GetBlock(_list[i]); if (!(blockValue.Block is BlockSleepingBag) && !(blockValue.Block is BlockPlant) && !(blockValue.Block is BlockDoor) && !(blockValue.Block is BlockCropsGrown) && !(blockValue.Block is BlockBackpack) && !(blockValue.Block is BlockDrawBridge) && !blockValue.Block.IsTerrainDecoration && !blockValue.Block.GetBlockName().ToLower().Contains("fence")) { GameManager.Instance.World.SetBlockRPC(_list[i], BlockValue.Air); } } if (_list.Count > FallingBlocks.Max_Blocks && FallingBlocks.OutputLog) { EntityPlayer closestPlayer = __instance.GetClosestPlayer(_list[0].x, _list[0].y, _list[0].z, -1, 75); if (closestPlayer != null) { Log.Out(string.Format("[SERVERTOOLS] Removed '{0}' falling blocks around '{1}'. The closest player entity id was '{2}' named '{3}' @ '{4}'", _list.Count, _list[0], closestPlayer.entityId, closestPlayer.EntityName, closestPlayer.position)); } else { closestPlayer = __instance.GetClosestPlayer(_list[_list.Count - 1].x, _list[_list.Count - 1].y, _list[_list.Count - 1].z, -1, 75); if (closestPlayer != null) { Log.Out(string.Format("[SERVERTOOLS] Removed '{0}' falling blocks around '{1}'. The closest player entity id was '{2}' named '{3}' @ '{4}'", _list.Count, _list[_list.Count - 1], closestPlayer.entityId, closestPlayer.EntityName, closestPlayer.position)); } else { Log.Out(string.Format("[SERVERTOOLS] Removed '{0}' falling blocks around '{1}'. No players were located near by", _list.Count, _list[0])); } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Injections.AddFallingBlocks_Prefix: {0}", e.Message)); } }
private static bool CheckStuck(float x, float y, float z) { for (float k = y - 0.25f; k <= (y + 1f); k++) { for (float i = x - 0.25f; i <= (x + 0.25f); i++) { for (float j = z - 0.25f; j <= (z + 0.25f); j++) { BlockValue block = GameManager.Instance.World.GetBlock(new Vector3i(i, k, j)); MaterialBlock _material = Block.list[block.type].blockMaterial; if (block.type == BlockValue.Air.type || _material.IsLiquid || _material.IsPlant || block.Block.IsTerrainDecoration || block.Block.isMultiBlock) { return(false); } } } } return(true); }
private bool CheckWaterInRange() { bool resultado = false; // check from 1 to 4 (min to max distance), if the block is water... if water is in range, returns true otherwise returns false. // the player CANNOT fish on a toilet or in water in hole // so i'll correct the function so that it checks if it is at least 2 blocks deep and has 2 water blocks to each side. // because I dont want them fishing on a pond for (int i = 1; i <= 4; i++) { Vector3i vv = Vector3i.FromVector3Rounded(epLocalPlayer.GetLookRay().GetPoint(i)); BlockValue valor = GameManager.Instance.World.GetBlock(vv); Block block = Block.list[valor.type]; if (block.blockMaterial.IsLiquid && (block.GetBlockName() == "water" || block.GetBlockName() == "waterMoving")) { //check deepness int deepNessAux = 1; for (int j = 1; j <= 10; i++) { vv.y = vv.y - 1; valor = GameManager.Instance.World.GetBlock(vv); block = Block.list[valor.type]; if (block.blockMaterial.IsLiquid && (block.GetBlockName() == "water" || block.GetBlockName() == "waterMoving")) { deepNessAux++; } else { break; } } deepNess = deepNessAux; //DisplayChatAreaText("Deepness = " + deepNess); //"waterMovingBucket" and "waterSource8" will not be considered valid blocks for fishing return(true); } } return(resultado); }
public bool _FindSetAndOffsetAssignedBoat(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, ref EntityCustomBoat _assignedBoat) { // Try to find closest Boat _assignedBoat = GetClosestBoat(_blockPos); if (_assignedBoat != null) { if (!_assignedBoat.bHasBoatDummy) { DebugMsg("BlockDummyBoat _FindSetAndOffsetAssignedBoat: Found closest Boat but it is not flagged to have a Dummy Boat Block, skipping: _blockPos = " + _blockPos.ToString() + " | Boat pos = " + _assignedBoat.position.ToString("0.000")); return(false); } if (_assignedBoat.bHasBoatDummy && _assignedBoat.boatDummyBlockEntityData != null && _assignedBoat.boatDummyPos != _blockPos) { DebugMsg("BlockDummyBoat _FindSetAndOffsetAssignedBoat: Found closest Boat but it already as an assigned Dummy Boat Block, skipping: _blockPos = " + _blockPos.ToString() + " | Boat pos = " + _assignedBoat.position.ToString("0.000")); return(false); } float closestBoatDistance = Vector3.Distance(_blockPos.ToVector3(), _assignedBoat.position); if (closestBoatDistance > 3 && _assignedBoat.boatDummyPos != _blockPos) { DebugMsg("BlockDummyBoat _FindSetAndOffsetAssignedBoat: Found closest Boat but it's too far, skipping: _blockPos = " + _blockPos.ToString() + " | Boat pos = " + _assignedBoat.position.ToString("0.000")); return(false); } DebugMsg("BlockDummyBoat _FindSetAndOffsetAssignedBoat: Found closest Boat: _blockPos = " + _blockPos.ToString() + " | Boat pos = " + _assignedBoat.position.ToString("0.000")); _assignedBoat.boatDummyPos = _blockPos; // Rotate boat to block Quaternion newQuat = Quaternion.AngleAxis(CustomVehiclesUtils.BlockYRotToEularYRot((int)_blockValue.rotation), Vector3.up); _assignedBoat.transform.rotation = newQuat; _assignedBoat.SetRotation(newQuat.eulerAngles); return(true); } else { DebugMsg("BlockDummyBoat FindSetAndOffsetAssignedBoat: Could not find closest Boat: _blockPos = " + _blockPos.ToString()); } return(false); }
/// <summary> /// This method is called directly from the core 7D2D game engine, due to the patch script. /// </summary> /// <param name="position">This will be set to the current position of the zombie that needs to spawn a corpse.</param> /// <param name="corpseBlock">This will be set to the corpse block that is about to be spawned.</param> /// <returns>The new position that the zombie corpse should spawn at.</returns> public static Vector3 GetUpdatedPosition(Vector3 position, BlockValue corpseBlock) { try { Vector3i newPosition = POSITIONER.FindSpawnLocationStartingFrom(World.worldToBlockPos(position), corpseBlock); return(new Vector3(newPosition.x, newPosition.y, newPosition.z)); } catch (Exception e) { Debug.Log("Corpse Disintigration Fix: Uncaught exception: " + e.Message + ", in: " + e.TargetSite); Debug.Log("Corpse Disintigration Fix: Stack trace follows:"); Debug.Log(e.StackTrace); if (CONFIG.DEBUG_MODE) { throw e; } } return(position); }
public static bool CheckFeatureStatus(string strFeature) { BlockValue ConfigurationFeatureBlock = Block.GetBlockValue("ConfigFeatureBlock"); if (ConfigurationFeatureBlock.type == 0) { //AdvLogging.DisplayLog("Configuration", "Feature: " + strFeature + " No Configuration Block"); return(false); } bool result = false; if (ConfigurationFeatureBlock.Block.Properties.Contains(strFeature)) { result = ConfigurationFeatureBlock.Block.Properties.GetBool(strFeature); } // AdvLogging.DisplayLog("Configuration", "Feature: " + strFeature + " Result: " + result); return(result); }
public static void AddFallingBlock_Prefix(World __instance, Vector3i _blockPos) { try { if (FallingBlocks.IsEnabled && _blockPos != null) { BlockValue blockValue = __instance.GetBlock(_blockPos); if (!(blockValue.Block is BlockSleepingBag) && !(blockValue.Block is BlockPlant) && !(blockValue.Block is BlockDoor) && !(blockValue.Block is BlockCropsGrown) && !(blockValue.Block is BlockBackpack) && !(blockValue.Block is BlockDrawBridge) && !blockValue.Block.IsTerrainDecoration && !blockValue.Block.GetBlockName().ToLower().Contains("fence")) { GameManager.Instance.World.SetBlockRPC(_blockPos, BlockValue.Air); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Injections.AddFallingBlock_Prefix: {0}", e.Message)); } }
/*public override void OnBlockPlaceBefore(WorldBase _world, ref BlockPlacement.Result _bpResult, EntityAlive _ea, Random _rnd) * { * base.OnBlockPlaceBefore(_world, ref _bpResult, _ea, _rnd); * }*/ public void RemoveChilds(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue) { ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx]; if (chunkCluster == null) { return; } byte rotation = _blockValue.rotation; for (int i = this.multiBlockPos.Length - 1; i >= 0; i--) { Vector3i other = this.multiBlockPos.Get(i, _blockValue.type, (int)rotation); if ((other.x != 0 || other.y != 0 || other.z != 0) && chunkCluster.GetBlock(_blockPos + other).type == _blockValue.type) { //chunkCluster.SetBlock(_blockPos + other, true, Block.GetBlockValue("water"), true, MarchingCubes.DensityAir, false, false, false); chunkCluster.SetBlock(_blockPos + other, Block.GetBlockValue("water"), false, false); } } }
public bool FindSetAndOffsetAssignedBoat(int _cIdx, Vector3i _blockPos, BlockValue _blockValue, BlockEntityData _ebcd) { if (_ebcd == null) { DebugMsg("BlockDummyBoat FindSetAndOffsetAssignedBoat: BlockEntityData is NULL, aborting: _blockPos = " + _blockPos.ToString()); } EntityCustomBoat assignedBoat = null; if (_FindSetAndOffsetAssignedBoat(_cIdx, _blockPos, _blockValue, ref assignedBoat)) { DebugMsg("BlockDummyBoat FindSetAndOffsetAssignedBoat: Found Boat Dummy Block BlockEntityData: _blockPos = " + _blockPos.ToString()); assignedBoat.boatDummyBlockEntityData = _ebcd; // Adjust Boat and dummy block transform assignedBoat.bNeedBoatDummyBlockOffset = true; assignedBoat.AdjustBoatAndDummyBoatBlockPositions(); return(true); } return(false); }
public static void lootContainerOpened(TileEntityLootContainer _te, LocalPlayerUI _playerUI, int _entityIdThatOpenedIt) { if (_playerUI != null) { bool flag = true; string lootContainerName = string.Empty; if (_te.entityId != -1) { Entity entity = GameManager.Instance.World.GetEntity(_te.entityId); if (entity != null) { lootContainerName = Localization.Get(EntityClass.list[entity.entityClass].entityClassName, ""); if (entity is EntityVehicle) { flag = false; } } } else { BlockValue block = GameManager.Instance.World.GetBlock(_te.ToWorldPos()); lootContainerName = Localization.Get(Block.list[block.type].GetBlockName(), ""); } if (flag) { ((XUiC_LootWindowGroup)((XUiWindowGroup)_playerUI.windowManager.GetWindow("looting")).Controller).SetTileEntityChest(lootContainerName, _te); _playerUI.windowManager.Open("looting", true, false, true); } LootContainer lootContainer = LootContainer.lootList[_te.lootListIndex]; if (lootContainer != null && _playerUI.entityPlayer != null) { lootContainer.ExecuteBuffActions(_te.entityId, _playerUI.entityPlayer); } } if (SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer) { GameManager.Instance.lootManager.LootContainerOpened(_te, _entityIdThatOpenedIt); _te.bTouched = true; _te.SetModified(); } }
public override void Update() { this.time += 0.05f; if (!EntityUtilities.CheckProperty(this.theEntity.entityId, "PathingBlocks")) { return; } EntityMoveHelper moveHelper = this.theEntity.moveHelper; //If we are close, be done with it. This is to help prevent the NPC from standing on certain workstations that its supposed to path too. float dist = Vector3.Distance(this.position, this.theEntity.position); if (dist < 2f) { DisplayLog("I am within 1f of the block: " + dist); BlockValue block = GameManager.Instance.World.GetBlock(new Vector3i(this.position)); if (block.type != BlockValue.Air.type || block.Block.GetBlockName() != "PathingCube") { DisplayLog("I am close enough to this block: " + block.Block.GetBlockName()); // Test code here // if (block.Block.GetBlockName() == "bedroll") // { // Debug.Log("At a bedroll"); // if (this.theEntity.emodel != null && this.theEntity.emodel.avatarController != null) // { // DisplayLog("Turning into crawler"); // int sleeperPose = (int)this.theEntity.rand.RandomRange(0, 9); // this.theEntity.emodel.avatarController.TriggerSleeperPose(sleeperPose); // // this.theEntity.emodel.avatarController.TurnIntoCrawler(true); //// this.theEntity.emodel.avatarController.GetAnimator().enabled =false; // } // } // Call the stop, and set the to 40, which kills the task. // EntityUtilities.Stop(this.theEntity.entityId); this.time = 90f; return; } } }
public void RemoveChilds(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue) { DebugMsg("BlockDummyBoat RemoveChilds"); ChunkCluster chunkCluster = _world.ChunkClusters[_clrIdx]; if (chunkCluster == null) { DebugMsg("BlockDummyBoat RemoveChilds: Chunk is NULL"); return; } byte rotation = _blockValue.rotation; for (int i = this.multiBlockPos.Length - 1; i >= 0; i--) { Vector3i other = this.multiBlockPos.Get(i, _blockValue.type, (int)rotation); if ((other.x != 0 || other.y != 0 || other.z != 0) && chunkCluster.GetBlock(_blockPos + other).type == _blockValue.type) { chunkCluster.SetBlock(_blockPos + other, Block.GetBlockValue("water"), false, false); } } }
private static bool GroundCheck(float x, float y, float z) { for (float k = y - 1f; k <= (y + 2f); k++) { for (float i = x - 1.5f; i <= (x + 1.5f); i++) { for (float j = z - 1.5f; j <= (z + 1.5f); j++) { BlockValue _block = GameManager.Instance.World.GetBlock(new Vector3i(i, k, j)); string _name = _block.Block.GetBlockName().ToLower(); if (_block.type == BlockValue.Air.type || _block.Block.isMultiBlock || _block.Block.IsTerrainDecoration || _block.Block.IsDecoration || _name.Contains("ladder") || _name.Contains("trellis") || _name.Contains("arch") || _name.ToLower().Contains("ramp")) { return(false); } } } } return(true); }
/** Try to find a slime block near Self, and try to move it * Done: propagate to adjacent slime blocks (but may be detected as empty by BlockWaterTransitionSimple.IsEmpty) */ public override void ExecuteUncatch(MinEventParams _params) { if (_params.Self == null) { return; } // Vector3i pos = Vectors.ToInt(_params.Self.GetPosition()); Vector3i pos = World.worldToBlockPos(_params.Self.GetPosition()); BlockValue block = GameManager.Instance.World.GetBlock(pos); if (block.Block.GetBlockName() == "waterSlime") { Move(pos, block); } pos = pos - Vectors.UnitY; block = GameManager.Instance.World.GetBlock(pos); if (block.Block.GetBlockName() == "waterSlime") { Move(pos, block); } }
//Used for severs, block will be NOT be powered directly. Also used in SP if AllowRemotePower is true in the xml. public static bool HasActivePower(WorldBase _world, int _cIdx, Vector3i _blockPos) { Vector3i[] locations = PowerInputLocations(_blockPos); foreach (Vector3i vector in locations) { BlockValue inputBlockValue = _world.GetBlock(vector); Type inputBlockType = Block.list[inputBlockValue.type].GetType(); if (inputBlockType == typeof(BlockPowered)) { TileEntityPowered tileEntityPowered = (TileEntityPowered)_world.GetTileEntity(_cIdx, vector); if (tileEntityPowered != null) { if (tileEntityPowered.IsPowered) { return(true); } } } } return(false); }
public static void RemoveOneClaim(string _playerId, Vector3i _position) { PersistentPlayerData _persistentPlayerData = PersistentOperations.GetPersistentPlayerData(_playerId); if (_persistentPlayerData != null) { World world = GameManager.Instance.World; BlockValue _blockValue = world.GetBlock(_position); Block _block = _blockValue.Block; if (_block != null && _block is BlockLandClaim) { world.SetBlockRPC(0, _position, BlockValue.Air); ConnectionManager.Instance.SendPackage(NetPackageManager.GetPackage <NetPackageEntityMapMarkerRemove>().Setup(EnumMapObjectType.LandClaim, _position.ToVector3()), false, -1, -1, -1, -1); world.ObjectOnMapRemove(EnumMapObjectType.LandClaim, _position.ToVector3()); LandClaimBoundsHelper.RemoveBoundsHelper(_position.ToVector3()); } GameManager.Instance.persistentPlayers.m_lpBlockMap.Remove(_position); _persistentPlayerData.LPBlocks.Remove(_position); SavePersistentPlayerDataXML(); } }
public static void Multiple(IList <Vector3i> _blocks) { try { if (_blocks != null && _blocks.Count > 0) { int _count = 0; for (int i = 0; i < _blocks.Count; i++) { BlockValue _blockValue = GameManager.Instance.World.GetBlock(_blocks[i]); Block _block = _blockValue.Block; if (_block is BlockSleepingBag || _block.IsDecoration || _block.IsPlant() || _block.isMultiBlock || _blockValue.Equals(BlockValue.Air)) { continue; } else { GameManager.Instance.World.SetBlockRPC(_blocks[i], BlockValue.Air); _count++; } } if (OutputLog && _count >= Max_Blocks) { EntityPlayer _closestPlayer = GameManager.Instance.World.GetClosestPlayer(_blocks[0].x, _blocks[0].y, _blocks[0].z, -1, 75); if (_closestPlayer != null) { Log.Out(string.Format("[SERVERTOOLS] Removed {0} falling blocks at {1}. The closest player entity id was {2} named {3} @ {4}", _count, _blocks[0], _closestPlayer.entityId, _closestPlayer.EntityName, _closestPlayer.position)); } else { Log.Out(string.Format("[SERVERTOOLS] Removed {0} falling blocks at {1}. No players were located near by", _count, _blocks[0])); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in FallingBlocks.Exec: {0}", e.Message)); } }
public static bool IsFlying(Vector3 _position) { AboveGround = true; BelowGround = true; for (float i = _position.x - 1; i <= (_position.x + 1); i++) { for (float j = _position.y - 3; j <= (_position.y + 2); j++) { for (float k = _position.z - 1; k <= (_position.z + 1); k++) { BlockValue blockValue = GameManager.Instance.World.GetBlock(new Vector3i(i, j, k)); Block block = blockValue.Block; if (AboveGround) { if (blockValue.type != BlockValue.Air.type || block.isMultiBlock || block.IsCollideMovement) { AboveGround = false; } } else if (BelowGround) { if (blockValue.type == BlockValue.Air.type || block.isMultiBlock || !block.IsCollideMovement || block is BlockDoor || block is BlockDoorSecure) { BelowGround = false; } } else { return(false); } } } } if (!AboveGround || !BelowGround) { return(false); } return(true); }
private void updateBlockRadiusEffects() { Vector3i blockPosition = base.GetBlockPosition(); int num = World.toChunkXZ(blockPosition.x); int num2 = World.toChunkXZ(blockPosition.z); this.startedThisFrame = new List <string>(); for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { Chunk chunk = (Chunk)this.world.GetChunkSync(num + j, num2 + i); if (chunk != null) { DictionaryList <Vector3i, TileEntity> tileEntities = chunk.GetTileEntities(); for (int k = 0; k < tileEntities.list.Count; k++) { TileEntity tileEntity = tileEntities.list[k]; if (tileEntity.IsActive(this.world)) { BlockValue block = this.world.GetBlock(tileEntity.ToWorldPos()); Block block2 = Block.list[block.type]; if (block2.RadiusEffects != null) { float distanceSq = base.GetDistanceSq(tileEntity.ToWorldPos().ToVector3()); for (int l = 0; l < block2.RadiusEffects.Length; l++) { BlockRadiusEffect blockRadiusEffect = block2.RadiusEffects[l]; if (distanceSq <= blockRadiusEffect.radius * blockRadiusEffect.radius && !this.Buffs.HasBuff(blockRadiusEffect.variable)) { this.Buffs.AddBuff(blockRadiusEffect.variable, -1, true, false, false); } } } } } } } } }
public bool getPlayerUnderground(EntityPlayer _player) { int x = (int)_player.position.x; int y = (int)_player.position.y; int z = (int)_player.position.z; for (int i = x - 2; i <= (x + 2); i++) { for (int j = z - 2; j <= (z + 2); j++) { for (int k = y - 3; k <= (y + 2); k++) { BlockValue Block = GameManager.Instance.World.GetBlock(new Vector3i(i, k, j)); if (Block.type == BlockValue.Air.type || _player.IsInElevator() || _player.IsInWater()) { return(false); } } } } return(true); }
/** * This is the activation text that displays when the player looks at this block. */ public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { TileEntityBlockTransformer tileEntityBlockTransformer = _world.GetTileEntity(_clrIdx, _blockPos) as TileEntityBlockTransformer; if (tileEntityBlockTransformer == null) { return(string.Empty); } string arg = Localization.Get(Block.list[_blockValue.type].GetBlockName(), ""); PlayerActionsLocal playerInput = ((EntityPlayerLocal)_entityFocusing).playerInput; string keybindString = UIUtils.GetKeybindString(playerInput.Activate, playerInput.PermanentActions.Activate); if (!tileEntityBlockTransformer.bTouched) { return(string.Format(Localization.Get("lootTooltipNew", ""), keybindString, arg)); } if (tileEntityBlockTransformer.IsEmpty()) { return(string.Format(Localization.Get("lootTooltipEmpty", ""), keybindString, arg)); } return(string.Format(Localization.Get("lootTooltipTouched", ""), keybindString, arg)); }
private static void BlockTranslations(Prefab prefab, Vector3i pos) { // ENTITIES var entities = new List <int>(); prefab.CopyEntitiesIntoWorld(GameManager.Instance.World, pos, entities, !(Options.ContainsKey("noent") || Options.ContainsKey("editmode"))); //BLOCK TRANSLATIONS if (Options.ContainsKey("notrans") || Options.ContainsKey("editmode")) { return; } var map = LootContainer.lootPlaceholderMap; for (var px = 0; px < prefab.size.x; px++) { for (var py = 0; py < prefab.size.y; py++) { for (var pz = 0; pz < prefab.size.z; pz++) { var bv = prefab.GetBlock(px, py, pz); // LOOT PLACEHOLDERS if (bv.type == 0) { continue; } var bvr = new BlockValue(map.Replace(bv, new Random(Guid.NewGuid().GetHashCode())).rawData); if (bv.type == bvr.type) { continue; } prefab.SetBlock(px, py, pz, bvr); } } } }
// The method will scan a distance of MaxDistance around the entity, finding the nearest block that matches in the list. public static List <Vector3> ScanForBlockInListHelper(Vector3 centerPosition, List <String> lstBlocks, int MaxDistance) { if (lstBlocks.Count == 0) { return(null); } List <Vector3> localLists = new List <Vector3>(); Vector3i TargetBlockPosition = new Vector3i(); for (var x = (int)centerPosition.x - MaxDistance; x <= centerPosition.x + MaxDistance; x++) { for (var z = (int)centerPosition.z - MaxDistance; z <= centerPosition.z + MaxDistance; z++) { for (var y = (int)centerPosition.y - MaxDistance; y <= centerPosition.y + MaxDistance; y++) { TargetBlockPosition.x = x; TargetBlockPosition.y = y; TargetBlockPosition.z = z; BlockValue block = GameManager.Instance.World.GetBlock(TargetBlockPosition); if (block.ischild) { continue; } // if its not a listed block, then keep searching. if (!lstBlocks.Contains(block.Block.GetBlockName())) { continue; } localLists.Add(TargetBlockPosition.ToVector3()); } } } return(localLists); }