public static void LogComponent_TankBlock(TankBlock tankBlock, string prefix) { Console.WriteLine(); Console.WriteLine($"{prefix}\tattachPoints:"); foreach (Vector3 vec in tankBlock.attachPoints) { Console.WriteLine($"{prefix}\t\t- {vec}"); } Console.WriteLine($"{prefix}\tfilledCells:"); foreach (Vector3 vec in tankBlock.filledCells) { Console.WriteLine($"{prefix}\t\t- {vec}"); } Console.WriteLine($"{prefix}\tpartialCells:"); foreach (Vector3 vec in tankBlock.partialCells) { Console.WriteLine($"{prefix}\t\t- {vec}"); } Console.WriteLine($"{prefix}\tapGroups:"); /*foreach (TankBlock.APGroup group in tankBlock.apGroups) * { * Console.WriteLine($"{prefix}\t\t- Count: {group.Count}"); * foreach (int i in group.Enumerate()) * { * Console.WriteLine($"{prefix}\t\t\t{i}"); * } * }*/ }
private void OnBlockRemoved(TankBlock otherblock, Tank tank) { if (!HasAnotherGodModule(tank)) { otherblock.GetComponent <Damageable>().SetInvulnerable(false, false); } }
public WeaponWrapper(TankBlock block) { this.block = block; this.weapon = block.gameObject.GetComponent <ModuleWeapon>(); this.drill = block.gameObject.GetComponent <ModuleDrill>(); this.hammer = block.gameObject.GetComponent <ModuleHammer>(); }
public static void DebugPrint(TankBlock block, string text) { if (debug && block.name.Contains("_C_BLOCK")) { Console.WriteLine(text); } }
public OutgridBlock(TankBlock block) { position = block.cachedLocalPosition; localPosition = block.trans.localPosition; localEulerAngles = block.trans.localEulerAngles; localScale = block.trans.localScale; }
public void AddBlock(TankBlock block, IntVector3 pos, OrthoRotation rot) { blocks.Add(block); block.trans.parent = transform; block.trans.localPosition = pos; block.trans.localRotation = rot; Dirty = true; for (int ap = 0; ap < block.attachPoints.Length; ap++) { IntVector3 filledCellForAPIndex = block.GetFilledCellForAPIndex(ap); IntVector3 v3 = block.attachPoints[ap] * 2f - filledCellForAPIndex - filledCellForAPIndex; IntVector3 index = pos + rot * filledCellForAPIndex; byte b = (rot * v3).APHalfBits(); ClusterAPBitField.TryGetValue(index, out byte ptr); ptr |= b; ClusterAPBitField[index] = ptr; } ModuleWeapon weapon = block.GetComponent <ModuleWeapon>(); if (weapon != null) { blockWeapons.Add(weapon); } ModuleDrill drill = block.GetComponent <ModuleDrill>(); if (drill != null) { blockDrills.Add(drill); } return; }
internal static void GetBlocks(TankBlock Start, ref List <TankBlock> GrabbedBlocks) // Borrowed from Control Blocks Overhaul { List <TankBlock> buffer = new List <TankBlock>(); buffer.Add(Start); int iteration = 0; do { int bC = buffer.Count; for (int i = 0; i < bC; i++) { foreach (TankBlock ConnectedBlock in buffer[i].ConnectedBlocksByAP) { if (ConnectedBlock != null && !GrabbedBlocks.Contains(ConnectedBlock)) { GrabbedBlocks.Add(ConnectedBlock); buffer.Add(ConnectedBlock); // Add to buffer } } } buffer.RemoveRange(0, bC); iteration++; }while (buffer.Count != 0); }
private void Detonate(TechSplitNamer obj) { if (base.block.tank.beam.IsActive) { base.block.tank.beam.EnableBeam(false, false, false); } blockA = block.ConnectedBlocksByAP[0]; blockB = block.ConnectedBlocksByAP[1]; cachedWorldPos = block.trans.position; cachedSplitRot = block.cachedLocalRotation; cachedWorldRot = block.trans.rotation; if (blockA != null) { cachedBlockAOffset = block.cachedLocalPosition - blockA.cachedLocalPosition; } if (blockB != null) { cachedBlockBOffset = block.cachedLocalPosition - blockB.cachedLocalPosition; } if (blockB == null) { blockA.AttachEvent.Subscribe(AfterDetonate); } else { blockB.AttachEvent.Subscribe(AfterDetonate); } Singleton.Manager <ManLooseBlocks> .inst.HostDetachBlock(base.block, false, true); block.damage.Explode(false); // Explode this Detonated = true; }
static void AttemptJoin(ModuleReactorHolder subject, TankBlock other) { if (other == null) { return; } var moduleHolder = other.GetComponent <ModuleReactorHolder>(); if (moduleHolder == null || moduleHolder.sharedEnergyNet == null) { return; } if (!moduleHolder.UseAPIDs) { moduleHolder.sharedEnergyNet.Join(subject); return; } else { for (int i = 0; i < moduleHolder.APIDs.Length; i++) { var check = moduleHolder.block.ConnectedBlocksByAP[moduleHolder.APIDs[i]]; if (check == subject.block) { moduleHolder.sharedEnergyNet.Join(subject); return; } } } }
public void RemoveBlock(TankBlock block) { foreach (KeyValuePair <string, BuffSegmentMk2> segPair in this.pathToSegment) { Type component = segPair.Value.effectComponent; object blockComponent = block.GetComponent(component); if (blockComponent != null) { if (this.typeToBlock[component].Contains(block)) { this.typeToBlock[component].Remove(block); Console.WriteLine("FFW! -Reg => " + block.name + " => " + segPair.Key); } segPair.Value.ManipulateObj(new List <TankBlock> { block }, "CLEAN"); if (segPair.Key == "ModuleWeaponGun.m_ShotCooldown") { float avg = segPair.Value.GetAverages("~"); BuffSpecificFix.ManipulateBarrels(new List <TankBlock> { block }, "CLEAN", this.weaponSpeedMemory, 1.0f); } if (component == typeof(ModuleWheels)) { BuffSpecificFix.RefreshWheels(this.typeToBlock[typeof(ModuleWheels)]); } } } this.allBlocks.Remove(block); }
static List <TankBlock> GetSafeBlockStep(TankBlock StartBlock) { List <TankBlock> tankBlocks = new List <TankBlock>(); //RecursiveBlockStep(StartBlock, tankBlocks); // Iterate GetBlocks(StartBlock, ref tankBlocks); return(tankBlocks); }
private void OnNewBlockAttached(TankBlock otherblock, Tank tank) { if (tank != block.tank) { throw new InvalidOperationException("This shouldnt happen"); } EnableBlockGodMode(otherblock.GetComponent <Damageable>()); }
static bool Prefix(ref TankBlock __instance) { ModuleBuffWrapperMk2 comp = __instance.gameObject.AddComponent <ModuleBuffWrapperMk2>(); comp.pointer = __instance; comp.Init(); return(true); }
private static bool Prefix(ref TankBlock __instance) { if (!antigravMatSwapBool) { ((MaterialSwapper)m_MaterialSwapper.GetValue(__instance)).SwapMaterialAntiGrav(false); } return(antigravMatSwapBool); }
private static void Prefix(ref TankBlock block, IntVector3 localPos) { var module = block.GetComponent <ModuleProcedural>(); if (module) { module.BeforeBlockAdded(localPos); } }
public int CanConnect(TankBlock thisBlock, TankBlock otherBlock, IList <AttachPoint> otherAttachPoints) { for (int i = 0; i < otherAttachPoints.Count; i++) { if (CanConnect(thisBlock, otherBlock, otherAttachPoints[i])) { return(i); } } return(-1); }
private void Update() { PaletteTextFilter.HandleInputFieldFocus(); if (block && !block.gameObject.activeInHierarchy || module && !module.block.gameObject.activeInHierarchy) { Clean(); } if (Input.GetMouseButtonDown(2)) { if (block) { block.visible.EnableOutlineGlow(false, cakeslice.Outline.OutlineEnableReason.ScriptHighlight); } try { Tank tank = null; if (block && module) { tank = block.tank; } var temp_block = Singleton.Manager <ManPointer> .inst.targetVisible.block; if (tank && temp_block.tank && tank != temp_block.tank) { Clean(); } block = temp_block; block.visible.EnableOutlineGlow(true, cakeslice.Outline.OutlineEnableReason.ScriptHighlight); } catch { Clean(); } if (block && block.tank && block.tank.GetComponentInChildren <ModuleOffgridStore>()) { module = block.tank.GetComponentInChildren <ModuleOffgridStore>(); targets.Clear(); AdvancedBuildingMod.transformGizmo.ClearTargets(); AdvancedBuildingMod.transformGizmo.AddTarget(block.trans); position = block.trans.localPosition; rotation = block.trans.localEulerAngles; scale = block.trans.localScale; } if (!block) { AdvancedBuildingMod.transformGizmo.enabled = false; } useGUILayout = block; } }
private static void AddLastRemovedBlock(BlockManager __instance, TankBlock removed) { List <TankBlock> lastRemovedBlocks = (List <TankBlock>)IngressPoint.s_LastRemovedBlocks.GetValue(null); BlockManager activeMgr = (BlockManager)IngressPoint.s_ActiveMgr.GetValue(null); if (activeMgr != __instance) { lastRemovedBlocks.Clear(); IngressPoint.s_ActiveMgr.SetValue(null, __instance); } lastRemovedBlocks.Add(removed); }
public TankBlock ToBlock(Vector3 position, Quaternion rotation, bool forceTransform = false) { TankBlock block = Singleton.Manager <ManSpawn> .inst.SpawnBlock(this.Type, position, rotation); if (forceTransform) { block.trans.localPosition = this.localPosition; block.trans.localEulerAngles = this.localEulerAngles; block.trans.localScale = this.localScale; } return(block); }
private Tank TraceMouse(out TankBlock block) { var mousePos = Input.mousePosition; RaycastHit ray; bool hit = Physics.Raycast(Singleton.camera.ScreenPointToRay(mousePos), out ray, float.MaxValue, Globals.inst.layerTank.mask, QueryTriggerInteraction.Ignore); if (!hit) { block = null; return(null); } block = ray.transform.GetComponent <TankBlock>(); return(ray.transform.GetComponent <Tank>()); }
public static int[] GetAPIndices(TankBlock block, Vector3 Position) { List <int> list = new List <int>(); for (int k = 0; k < block.attachPoints.Length; k++) { Vector3 input = block.attachPoints[k] - Position; if (input.sqrMagnitude < 1f && input.SetY(0f).sqrMagnitude > 0.1f) { list.Add(k); } } return(list.ToArray()); }
private void Clean() { if (block) { block.visible.EnableOutlineGlow(false, cakeslice.Outline.OutlineEnableReason.ScriptHighlight); } block = null; module = null; useGUILayout = false; Singleton.Manager <ManPointer> .inst.ChangeBuildMode(ManPointer.BuildingMode.Grab); AdvancedBuildingMod.transformGizmo.transformType = RuntimeGizmos.TransformType.Move; AdvancedBuildingMod.transformGizmo.enabled = false; SaveConfig(); }
private void AfterDetonate() { if (!Detonated) { Console.WriteLine("FusionBlock.ModuleMerger.AfterDetonate() has been called more than once!"); } Detonated = false; if (blockB == null) { blockA.AttachEvent.Unsubscribe(AfterDetonate); } else { blockB.AttachEvent.Unsubscribe(AfterDetonate); } TankBlock halfBlockA = ManSpawn.inst.SpawnBlock(SubstituteType, cachedWorldPos, cachedWorldRot); // Create substitute #1 TankBlock halfBlockB = ManSpawn.inst.SpawnBlock(SubstituteType, cachedWorldPos, cachedWorldRot * Quaternion.Euler(180, 0, 0)); // Create substitute #2 halfBlockA.SetSkinIndex(block.GetSkinIndex()); halfBlockB.SetSkinIndex(block.GetSkinIndex()); // Set that skins so they are pretty halfBlockA.visible.damageable.InitHealth(block.visible.damageable.Health / 2); halfBlockB.visible.damageable.InitHealth(block.visible.damageable.Health / 2); // Set the healths to halves of the whole ModuleFuseHalf fuseBlockA = halfBlockA.GetComponent <ModuleFuseHalf>(); if (fuseBlockA != null) { fuseBlockA.Timeout = DelayAfterDetonate; } ModuleFuseHalf fuseBlockB = halfBlockB.GetComponent <ModuleFuseHalf>(); if (fuseBlockB != null) { fuseBlockB.Timeout = DelayAfterDetonate; } block.visible.RemoveFromGame(); // Rid of this if (blockA != null && blockA.tank != null) { blockA.tank.blockman.AddBlockToTech(halfBlockA, blockA.cachedLocalPosition + cachedBlockAOffset, cachedSplitRot); // Put that block where it belongs } if (blockB != null && blockB.tank != null) { blockB.tank.blockman.AddBlockToTech(halfBlockB, blockB.cachedLocalPosition + cachedBlockBOffset, new OrthoRotation(cachedSplitRot * Quaternion.Euler(180, 0, 0))); // Put that other block where it belongs } }
private void Update() { if (Input.GetMouseButtonDown(2)) { win = new Rect(Input.mousePosition.x - 400f, Screen.height - Input.mousePosition.y, 200f, 200f); try { block = Singleton.Manager <ManPointer> .inst.targetVisible.block; } catch (Exception ex) { block = null; } visible = block; } }
public static void Postfix(ref Damageable __instance, ref float __result) { if (__result != 0.0f) { // block destroyed TankBlock block = __instance.Block; if (block) { Collider[] colliders = block.GetComponentsInChildren <Collider>(); foreach (Collider collider in colliders) { collider.enabled = false; } } } return; }
private void Update() { if (Input.GetMouseButtonDown(2)) { posX = Input.mousePosition.x; posY = Input.mousePosition.y; win = new Rect(posX - 400f, posY, 200f, 200f); try { block = Singleton.Manager <ManPointer> .inst.targetVisible.block; } catch (Exception ex) { block = null; } visible = block; } }
public static void Postfix(ref Explosion __instance) { ExplosionNerf.IngressPoint.DebugPrint("<ENM> ", "============================ NEW EXPLOSION ============================"); // ExplosionNerf.IngressPoint.DebugPrint("initial"); PatchDamage.hitBlock = null; PatchDamage.originalDamage = __instance.m_MaxDamageStrength; PatchExplosion.s_VisibleHits = (IDictionary)PatchExplosion.hitDict.GetValue(null); // ExplosionNerf.IngressPoint.DebugPrint("fetch"); PatchDamage.castSource = __instance; if (PatchExplosion.s_VisibleHits != null && PatchExplosion.s_VisibleHits.Count > 0) { Damageable directHit = (Damageable)PatchDamage.DirectHit.GetValue(__instance); // if (directHit != null && directHit.Block != null && (directHit.MaxHealth >= 1.0f || directHit.Block.GetComponent<ModuleShieldGenerator>() == null)) if (directHit != null && directHit.Block != null && directHit.Block.tank != null && directHit.Block.visible.damageable == directHit) { PatchDamage.hitBlock = directHit.Block; } // ExplosionNerf.IngressPoint.DebugPrint("condition"); Dictionary <int, object> newDictionary = CastDict(PatchExplosion.s_VisibleHits).ToDictionary(entry => (int)entry.Key, entry => entry.Value); // ExplosionNerf.IngressPoint.DebugPrint("cast"); List <object> myList = newDictionary.Values.ToList(); PatchDamage.YetToHit.Clear(); foreach (HashSet <TankBlock> table in PatchDamage.DeterminedInvincible.Values) { table.Clear(); } PatchDamage.DeterminedInvincible.Clear(); foreach (object obj in myList) { Visible visible = (Visible)obj.GetType().GetField("visible", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(obj); if (visible != null) { TankBlock tentative = visible.block; if (tentative != null) { PatchDamage.YetToHit.Add(tentative); } } } } }
private void ProcessDamage(float damage, Damageable hit) { float thisDamage = damage; TankBlock block = hit.Block; if (block == null) { thisDamage *= SceneryMultiplier; } else { if (block.damage.AboutToDie) { return; } if (block.tank == null) { thisDamage *= DetachedMultiplier; } else if (block.tank.Team == _Projectile.Shooter.Team) { if (block.tank == _Projectile.Shooter && _damageSelfTime > Time.time) { return; } if (_damageTeamTime > Time.time) { return; } thisDamage *= TeamMultiplier; } } if (thisDamage < 0f && !hit.IsAtFullHealth) { hit.Repair(thisDamage, true); } else if (thisDamage > 0f && hit.Health > 0f) { ManDamage.inst.DealDamage(hit, thisDamage, DamageType, _Projectile.Shooter); } }
public static JSONBlock FromBlock(TankBlock block) { var jBlock = new JSONBlock() { Type = block.BlockType, OrthoRotation = block.cachedLocalRotation.rot, Position = block.cachedLocalPosition, localPosition = block.trans.localPosition, localEulerAngles = block.trans.localEulerAngles, localScale = block.trans.localScale }; if (block.tank) { jBlock.IsRootBlock = block.tank.blockman.IsRootBlock(block); } return(jBlock); }
private void DoWindow(int id) { GUILayout.Label("X scale"); x = NuterraGUI.NumberField(x, 0.1f); //float.TryParse(GUILayout.TextField(x.ToString()), out x); GUILayout.Label("Y scale"); y = NuterraGUI.NumberField(y, 0.1f); //float.TryParse(GUILayout.TextField(y.ToString()), out y); GUILayout.Label("Z scale"); z = NuterraGUI.NumberField(z, 0.1f); //float.TryParse(GUILayout.TextField(z.ToString()), out z); if (GUILayout.Button("Close")) { visible = false; block = null; } GUI.DragWindow(); }
// Use this for initialization void Awake() { count = 0; if (gameObject.name == "Hero1") { characterID = 0; player = GetComponent<Player> (); } else if (gameObject.name == "Hero2"){ characterID = 1; player = GetComponent<Player> (); } else if (GetComponent<MiniCopterBlock> ()) { characterID = 2; miniCopterBlock = GetComponent<MiniCopterBlock> (); } else if (gameObject.GetComponent<TankBlock> ()) { characterID = 3; tankBlock = GetComponent<TankBlock> (); } else if (GetComponent<JumpBlock> ()) { characterID = 4; jumpBlock = GetComponent<JumpBlock> (); } else if (GetComponent<TelekineticBlock> ()) { characterID = 5; telekineticBlock = GetComponent<TelekineticBlock> (); } else if (GetComponent<SuperTelekineticBlock> ()) { characterID = 6; superTelekineticBlock = GetComponent<SuperTelekineticBlock> (); } else if (GetComponent<DestructablePlatform>()){ characterID = 7; destructablePlatform = GetComponent<DestructablePlatform>(); } else if (GetComponent<TurretBlock>()){ characterID = 8; turretBlock = GetComponent<TurretBlock> (); } else if (GetComponent<SuperTurretBlock>()){ characterID = 9; superTurretBlock = GetComponent<SuperTurretBlock> (); } else if (GetComponent<PistonButton>()){ characterID = 10; pistonButton = GetComponent<PistonButton> (); } else{ characterID = 100; } }