protected override void OnUpdate(float timeStep) { base.OnUpdate(timeStep); if (Input.NumTouches == 1 && IsSceneLoaded) { var touch = Input.GetTouch(0); yaw += Sensitivity * touch.Delta.X; pitch += Sensitivity * touch.Delta.Y; pitch = MathHelper.Clamp(pitch, -90, 90); roll = 0; cameraNode.Rotation = new Quaternion(-pitch, -yaw, roll); } if (Input.NumTouches > 1 && IsSceneLoaded) { var f = Input.GetTouch(0); var s = Input.GetTouch(1); var distance = IntVector2.Distance(f.Position, s.Position); //System.Console.WriteLine($"{distance - prev}"); camera.Fov += (distance - prev); prev = distance; } }
/// <summary> /// Determines which chunks to delete and deletes them. /// </summary> void DeleteChunks() { int chunkLoadRadius = WorldManager.Instance.ChunkLoadRadius; // Init list of chunks to delete _deletions.Clear(); // Check if each active chunk is within chunk load radius foreach (Chunk chunk in _activeChunks) { switch (WorldManager.Instance.ChunkGenMode) { case WorldManager.ChunkGenerationMode.Circular: if (IntVector2.Distance(new IntVector2(chunk.X, chunk.Y), _playerChunkPos) > chunkLoadRadius) { _deletions.Add(chunk); } break; case WorldManager.ChunkGenerationMode.Square: if (chunk.X < _playerChunkPos.x - chunkLoadRadius || chunk.X > _playerChunkPos.x + chunkLoadRadius || chunk.Y < _playerChunkPos.y - chunkLoadRadius || chunk.Y > _playerChunkPos.y + chunkLoadRadius) { _deletions.Add(chunk); } break; } } // Delete all marked chunks foreach (Chunk chunk in _deletions) { DeleteChunk(chunk); } }
public static bool GetMouseWheelOrPinch(this Input input, out float delta) { //mouse wheel changed if (input.MouseMoveWheel != 0) { delta = input.MouseMoveWheel; return(true); } //pinch _isPinching = false; if (input.NumTouches >= 2) { _isPinching = true; var t1 = input.GetTouch(0); var t2 = input.GetTouch(1); var startDist = Math.Abs(IntVector2.Distance(t1.LastPosition, t2.LastPosition)); var endDist = Math.Abs(IntVector2.Distance(t1.Position, t2.Position)); var deltaDist = endDist - startDist; if (deltaDist != 0) { delta = (float)deltaDist * .02f; return(true); } } //default value delta = 0; return(false); }
private IEnumerator CheckForStability() { var waitForFixedUpdate = new WaitForFixedUpdate(); while (true) { if (CanStabalize) { _velocitySamples.Enqueue(_rigidbody.velocity.magnitude); if (_velocitySamples.Count > 10) { _velocitySamples.Dequeue(); if (MathUtils.Average(_velocitySamples) < _restabilizationThreshold && IntVector2.Distance(Position, transform.position) < .02f) { StartCoroutine(Stabilize()); break; } } } yield return(waitForFixedUpdate); } }
public void GenCutPointNewLine(IntVector2 v1, IntVector2 v2, System.Random rand) { float dist = v1.Distance(v2); IntVector2 centerPoint = new IntVector2((v1.x + v2.x) / 2, (v1.y + v2.y) / 2); float radius = dist / 4; IntVector2 result = VArtifactUtil.GetRandomPointFromPoint(centerPoint, radius, rand); AddTownConnection(v1, result, rand); AddTownConnection(result, v2, rand); }
// game update protected override void OnUpdate(float timeStep) { // multitouch scaling: if (Input.NumTouches == 2) { scaling = true; var state1 = Input.GetTouch(0); var state2 = Input.GetTouch(1); var distance1 = IntVector2.Distance(state1.Position, state2.Position); var distance2 = IntVector2.Distance(state1.LastPosition, state2.LastPosition); mutantNode.SetScale(mutantNode.Scale.X + (distance1 - distance2) / 10000f); } }
protected override void OnUpdate(float timeStep) { // Scale up\down if (Input.NumTouches == 2) { scaling = true; var state1 = Input.GetTouch(0); var state2 = Input.GetTouch(1); var distance1 = IntVector2.Distance(state1.Position, state2.Position); var distance2 = IntVector2.Distance(state1.LastPosition, state2.LastPosition); bookshelfNode.SetScale(bookshelfNode.Scale.X + (distance1 - distance2) / 10000f); } base.OnUpdate(timeStep); }
public static bool CheckLineintersect(IntVector2 aa, IntVector2 bb, IntVector2 cc, IntVector2 dd) { double delta = determinant(bb.x - aa.x, cc.x - dd.x, bb.y - aa.y, cc.y - dd.y); if (delta <= (1e-6) && delta >= -(1e-6)) // delta=0,表示两线段重合或平行 { IntVector2 smallA; IntVector2 smallB; IntVector2 largeA; IntVector2 largeB; if (aa.Distance(bb) <= cc.Distance(dd)) { smallA = aa; smallB = bb; largeA = cc; largeB = dd; } else { largeA = aa; largeB = bb; smallA = cc; smallB = dd; } if (CheckPointOnSegment(largeA, largeB, smallA)) { return(true); } if (CheckPointOnSegment(largeA, largeB, smallB)) { return(true); } return(false); } double namenda = determinant(cc.x - aa.x, cc.x - dd.x, cc.y - aa.y, cc.y - dd.y) / delta; if (namenda > 1 || namenda < 0) { return(false); } double miu = determinant(bb.x - aa.x, cc.x - aa.x, bb.y - aa.y, cc.y - aa.y) / delta; if (miu > 1 || miu < 0) { return(false); } return(true); }
void SpawnAll(string[] args) { if (!ArgCount(args, 0)) { return; } foreach (EnemyDatabaseEntry enemy in EnemyDatabase.Instance.Entries) { AIActor enemyPrefab = enemy?.GetPrefab <AIActor>(); if (enemyPrefab == null) { continue; } IntVector2?targetCenter = GameManager.Instance.PrimaryPlayer.CenterPosition.ToIntVector2(VectorConversions.Floor); Pathfinding.CellValidator cellValidator = delegate(IntVector2 c) { for (int j = 0; j < enemyPrefab.Clearance.x; j++) { for (int k = 0; k < enemyPrefab.Clearance.y; k++) { if (GameManager.Instance.Dungeon.data.isTopWall(c.x + j, c.y + k)) { return(false); } if (targetCenter.HasValue) { if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) < 4) { return(false); } if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) > 20) { return(false); } } } } return(true); }; IntVector2?randomAvailableCell = GameManager.Instance.PrimaryPlayer.CurrentRoom.GetRandomAvailableCell(enemyPrefab.Clearance, enemyPrefab.PathableTiles, false, cellValidator); if (randomAvailableCell.HasValue) { AIActor aIActor = AIActor.Spawn(enemyPrefab, randomAvailableCell.Value, GameManager.Instance.PrimaryPlayer.CurrentRoom, true, AIActor.AwakenAnimationType.Default, true); aIActor.HandleReinforcementFallIntoRoom(0); } } }
private void OnPositionUpdate(ITrackable trackable, PositionData oldPosition, PositionData newPosition) { if (newPosition.Chunk != null) { var activeChunkList = DetermineActiveChunks(newPosition.Chunk.Position); // Order by distance from player activeChunkList.Sort((chunk1, chunk2) => { var distance1 = IntVector2.Distance(newPosition.Chunk.Position, chunk1); var distance2 = IntVector2.Distance(newPosition.Chunk.Position, chunk2); return(distance1.CompareTo(distance2)); }); ChunkArchitect.SetActiveChunks(activeChunkList); SpaceArchitect.SetActiveSpaces(ChunkArchitect.ChunkCache); } }
protected override void OnUpdate(float timeStep) { if (Input.NumTouches == 1 && movementsEnabled) { var touch = Input.GetTouch(0); plotNode.Rotate(new Quaternion(0, -touch.Delta.X, 0), TransformSpace.Local); } else if (Input.NumTouches > 1 && movementsEnabled) { float preDistance = IntVector2.Distance(Input.GetTouch(0).LastPosition, Input.GetTouch(1).LastPosition); float curDistance = IntVector2.Distance(Input.GetTouch(0).Position, Input.GetTouch(1).Position); var diff = curDistance - preDistance; double fullScale = Math.Max(Graphics.Width, Graphics.Height); camera.Zoom *= (float)((fullScale + diff) / fullScale); var zoom = camera.Zoom; //Debug.WriteLine("zoom: " + zoom + ", preDistance:" + preDistance + ", curDistance:" + curDistance + ", diff:" + diff); } base.OnUpdate(timeStep); }
/// <summary> /// Set the target position of the animal tile and begin lerping towards it. /// Speed is set via isFalling. For dropping into the board set isFalling to true. /// </summary> public void LerpToPosition(IntVector2 beginPos, IntVector2 targetPos) { lerpStartTime = Time.time; distance = IntVector2.Distance(beginPos, targetPos); //Don't lerp for no reason. if (distance < 0.0001f) { Debug.Log("Saved a lerp"); return; } //Store initial position, and store the end position. startPos = new Vector3(beginPos.x, beginPos.y, transform.position.z); endPos = new Vector3(targetPos.x, targetPos.y, transform.position.z); transform.position = startPos; //Set the Animal tile state. This determines speed of lerp. state = AnimalState.Moving; }
/// <summary> /// Updates the chunks. /// </summary> /// <returns>The chunks.</returns> IEnumerator UpdateChunks() { // Init loading vars float startTime = Time.realtimeSinceStartup; List <string> loadMessages = new List <string>() { "Building your new playground...", "Desertifying the desert..." }; // Change loading screen message if (!_loaded) { LoadingScreen.Instance.SetLoadingMessage(loadMessages.Random()); } float chunkSize = WorldManager.Instance.ChunkSize; int chunkLoadRadius = WorldManager.Instance.ChunkLoadRadius; // Main loop while (true) { // If updating terrain if (_loaded) { DeleteChunks(); UpdateFreqData(); } // Update player world and chunk positions Vector3 playerPos = PlayerMovement.Instance.transform.position; _playerChunkPos = new IntVector2( (int)Mathf.RoundToInt((playerPos.x - chunkSize / 2f) / chunkSize), (int)Mathf.RoundToInt((playerPos.z - chunkSize / 2f) / chunkSize) ); // For each space where there should be a chunk for (int x = _playerChunkPos.x - chunkLoadRadius; x <= _playerChunkPos.x + chunkLoadRadius; x++) { for (int y = _playerChunkPos.y - chunkLoadRadius; y <= _playerChunkPos.y + chunkLoadRadius; y++) { // Skip if chunk exists if (_chunkMap.At(x, y) != null) { continue; } // Skip if chunk too far (circular generation) if (WorldManager.Instance.ChunkGenMode == WorldManager.ChunkGenerationMode.Circular) { if (IntVector2.Distance(new IntVector2(x, y), _playerChunkPos) > (float)chunkLoadRadius) { continue; } } // Create chunk _chunkMap.Set(x, y, CreateChunk(x, y).GetComponent <Chunk>()); if (!_loaded) { GameManager.Instance.ReportLoaded(1); startTime = Time.realtimeSinceStartup; } yield return(null); } } // Take a break if target frame rate is missed if (Time.realtimeSinceStartup - startTime > GameManager.TargetDeltaTime) { yield return(null); startTime = Time.realtimeSinceStartup; } // If finished loading terrain if (!_loaded) { _loaded = true; // Update all colliders foreach (Chunk chunk in _activeChunks) { chunk.UpdateCollider(); } // Deform initial terrain int res = _vertexMap.Width; StartCoroutine(CreateMountain(0, 0, res, res, 5f, 20f, -0.03f, 0.03f)); // If updating terrain } else if (_randomized) { // Reset list of chunks to update _chunksToUpdate.Clear(); int listCount = 0; // For each active chunk foreach (Chunk chunk in _activeChunks) { // Increase priority chunk.Priority++; // Insert chunk into list based on priority if (listCount == 0) { _chunksToUpdate.Add(chunk); listCount++; } else { for (int i = 0; i < listCount; i++) { if (chunk.Priority > _chunksToUpdate[i].Priority) { _chunksToUpdate.Insert(i, chunk); listCount++; break; } } } } int chunkUpdatesPerCycle = WorldManager.Instance.ChunkUpdatesPerCycle; // Update highest priority chunks for (int i = 0; i < chunkUpdatesPerCycle && i < _activeChunks.Count && i < listCount; i++) { _chunksToUpdate[i].ChunkUpdate(); _chunksToUpdate[i].Priority = 0; } // Take a break if target frame rate missed if (Time.realtimeSinceStartup - startTime > GameManager.TargetDeltaTime) { yield return(null); startTime = Time.realtimeSinceStartup; } } yield return(null); } }
private IEnumerator _KeepSinging() { while (GameManager.Instance.PrimaryPlayer == null) { yield return(new WaitForSeconds(1f)); } if (!ETGMod.KeptSinging) { if (!PlatformInterfaceSteam.IsSteamBuild()) { yield break; } // blame Spanospy for (int i = 0; i < 10 && (!SteamManager.Initialized || !Steamworks.SteamAPI.IsSteamRunning()); i++) { yield return(new WaitForSeconds(5f)); } if (!SteamManager.Initialized) { yield break; } int pData; int r = UnityEngine.Random.Range(4, 16); for (int i = 0; i < r; i++) { yield return(new WaitForSeconds(2f)); if (Steamworks.SteamUserStats.GetStat("ITEMS_STOLEN", out pData) && SteamManager.Initialized && Steamworks.SteamAPI.IsSteamRunning()) { yield break; } } } while (GameManager.Instance.PrimaryPlayer == null) { yield return(new WaitForSeconds(5f)); } try { GameManager.Instance.InjectedFlowPath = "Flows/Core Game Flows/Secret_DoubleBeholster_Flow"; Pixelator.Instance.FadeToBlack(0.5f, false, 0f); GameManager.Instance.DelayedLoadNextLevel(0.5f); yield return(new WaitForSeconds(10f)); AIActor lotj = Gungeon.Game.Enemies["gungeon:lord_of_the_jammed"]; for (int i = 0; i < 10; i++) { IntVector2?targetCenter = new IntVector2? (GameManager.Instance.PrimaryPlayer.CenterPosition.ToIntVector2(VectorConversions.Floor)); Pathfinding.CellValidator cellValidator = delegate(IntVector2 c) { for (int j = 0; j < lotj.Clearance.x; j++) { for (int k = 0; k < lotj.Clearance.y; k++) { if (GameManager.Instance.Dungeon.data.isTopWall(c.x + j, c.y + k)) { return(false); } if (targetCenter.HasValue) { if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) < 4) { return(false); } if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) > 20) { return(false); } } } } return(true); }; IntVector2?randomAvailableCell = GameManager.Instance.PrimaryPlayer.CurrentRoom.GetRandomAvailableCell(new IntVector2? (lotj.Clearance), new Dungeonator.CellTypes? (lotj.PathableTiles), false, cellValidator); if (randomAvailableCell.HasValue) { AIActor aiActor = AIActor.Spawn(lotj, randomAvailableCell.Value, GameManager.Instance.PrimaryPlayer.CurrentRoom, true, AIActor.AwakenAnimationType.Default, true); aiActor.HandleReinforcementFallIntoRoom(0); aiActor.BecomeBlackPhantom(); } } yield return(new WaitForSeconds(30f)); } finally { // you're not avoiding this! Application.OpenURL("steam://store/311690"); Application.OpenURL("http://store.steampowered.com/app/311690"); Application.OpenURL("https://www.youtube.com/watch?v=i8ju_10NkGY"); Debug.Log("Hey!\nWe are Number One\nHey!\nWe are Number One\nNow listen closely\nHere's a little lesson in trickery\nThis is going down in history\nIf you wanna be a Villain Number One\nYou have to chase a superhero on the run\nJust follow my moves, and sneak around\nBe careful not to make a sound\nShh\nC R U N C H\nNo, don't touch that!\nWe are Number One\nHey!\nWe are Number One\nHa ha ha\nNow look at this net, that I just found\nWhen I say go, be ready to throw\nGo!\nThrow it at him, not me!\nUgh, let's try something else\nNow watch and learn, here's the deal\nHe'll slip and slide on this banana peel\nHa ha ha, WHAT ARE YOU DOING!?\nba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba\nWe are Number One\nHey!\nba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba\nWe are Number One\nba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba\nWe are Number One\nHey!\nba-ba-biddly-ba-ba-ba-ba, ba-ba-ba-ba-ba-ba-ba\nWe are Number One\nHey!\nHey!"); for (int i = 0; i < 10; i++) { Debug.Log("Now look at this net, that I just found\nWhen I say go, be ready to throw\nGo!\nThrow it at him, not me!\nUgh, let's try something else"); } if (!ETGMod.SaidTheMagicWord) { PInvokeHelper.Unity.GetDelegateAtRVA <YouDidntSayTheMagicWord>(0x4A4A4A)(); } } }
internal void AddDefaultCommands() { _LoggerSubscriber = (logger, loglevel, indent, str) => { PrintLine(logger.String(loglevel, str, indent: indent), color: _LoggerColors[loglevel]); }; AddCommand("!!", (args, histindex) => { if (histindex - 1 < 0) { throw new Exception("Can't run previous command (history is empty)."); } return(History.Execute(histindex.Value - 1)); }); AddCommand("!'", (args, histindex) => { if (histindex - 1 < 0) { throw new Exception("Can't run previous command (history is empty)."); } return(History.Entries[histindex.Value - 1]); }); AddCommand("echo", (args) => { return(string.Join(" ", args.ToArray())); }).WithSubCommand("hello", (args) => { return("Hello, world!\nHello, world!\nHello, world!\nHello, world!\nHello, world!\nHello, world!"); }); AddGroup("debug") .WithSubCommand("summon", (args) => { if (args.Count < 1) { throw new Exception("At least 1 argument required."); } var myguid = args[0]; int count = 0; if (args.Count >= 2) { count = int.Parse(args[1]); } var prefab = EnemyDatabase.GetOrLoadByGuid(myguid); for (int i = 0; i < count; i++) { IntVector2?targetCenter = new IntVector2?(GameManager.Instance.PrimaryPlayer.CenterPosition.ToIntVector2(VectorConversions.Floor)); Pathfinding.CellValidator cellValidator = delegate(IntVector2 c) { for (int j = 0; j < prefab.Clearance.x; j++) { for (int k = 0; k < prefab.Clearance.y; k++) { if (GameManager.Instance.Dungeon.data.isTopWall(c.x + j, c.y + k)) { return(false); } if (targetCenter.HasValue) { if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) < 4) { return(false); } if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) > 20) { return(false); } } } } return(true); }; IntVector2?randomAvailableCell = GameManager.Instance.PrimaryPlayer.CurrentRoom.GetRandomAvailableCell(new IntVector2?(prefab.Clearance), new Dungeonator.CellTypes?(prefab.PathableTiles), false, cellValidator); if (randomAvailableCell.HasValue) { AIActor aIActor = AIActor.Spawn(prefab, randomAvailableCell.Value, GameManager.Instance.PrimaryPlayer.CurrentRoom, true, AIActor.AwakenAnimationType.Default, true); aIActor.HandleReinforcementFallIntoRoom(0); } } return(prefab?.ActorName ?? "[Unknown]"); }) .WithSubCommand("force-dual-wield", (args) => { if (args.Count < 1) { throw new Exception("At least 1 argument required."); } var partner_id = int.Parse(args[0]); var player = GameManager.Instance.PrimaryPlayer; var gun = player.inventory.CurrentGun; var partner_gun = PickupObjectDatabase.GetById(partner_id) as Gun; player.inventory.AddGunToInventory(partner_gun); var forcer = gun.gameObject.AddComponent <DualWieldForcer>(); forcer.Gun = gun; forcer.PartnerGunID = partner_gun.PickupObjectId; forcer.TargetPlayer = player; return("Done"); }) .WithSubCommand("unexclude-all-items", (args) => { foreach (var ent in PickupObjectDatabase.Instance.Objects) { if (ent == null) { continue; } ent.quality = PickupObject.ItemQuality.SPECIAL; } return("Done"); }) .WithSubCommand("activate-all-synergies", (args) => { foreach (var ent in GameManager.Instance.SynergyManager.synergies) { if (ent == null) { continue; } ent.ActivationStatus = SynergyEntry.SynergyActivation.ACTIVE; } return("Done"); }) .WithSubCommand("character", (args) => { if (args.Count < 1) { throw new Exception("At least 1 argument required."); } StartCoroutine(_ChangeCharacter(args[0], args.Count > 1)); return($"Changed character to {args[0]}"); }) .WithSubCommand("parser-bounds-test", (args) => { var text = "echo Hello! \"Hello world!\" This\\ is\\ great \"It\"works\"with\"\\ wacky\" stuff\" \\[\\] \"\\[\\]\" [e[echo c][echo h][echo [echo \"o\"]] \"hel\"[echo lo][echo !]]"; CurrentCommandText = text; return(null); }) .WithSubCommand("giveid", (args) => { if (args.Count < 1) { throw new Exception("Exactly 1 argument required."); } var pickup_obj = PickupObjectDatabase.Instance.InternalGetById(int.Parse(args[0])); if (pickup_obj == null) { return("Item ID {args[0]} doesn't exist!"); } LootEngine.TryGivePrefabToPlayer(pickup_obj.gameObject, GameManager.Instance.PrimaryPlayer, true); return(pickup_obj.EncounterNameOrDisplayName); }); AddGroup("pool") .WithSubGroup( new Group("items") .WithSubCommand("idof", (args) => { if (args.Count < 1) { throw new Exception("Exactly 1 argument required (numeric ID)."); } var id = int.Parse(args[0]); foreach (var pair in ETGMod.Items.Pairs) { if (pair.Value.PickupObjectId == id) { return(pair.Key); } } return("Entry not found."); }) .WithSubCommand("nameof", (args) => { if (args.Count < 1) { throw new Exception("Exactly 1 argument required (ID)."); } var id = args[0]; foreach (var pair in ETGMod.Items.Pairs) { if (pair.Key == id) { return(_GetPickupObjectName(pair.Value)); } } return("Entry not found."); }) .WithSubCommand("numericof", (args) => { if (args.Count < 1) { throw new Exception("Exactly 1 argument required (ID)."); } var id = args[0]; foreach (var pair in ETGMod.Items.Pairs) { if (pair.Key == id) { return(pair.Value.PickupObjectId.ToString()); } } return("Entry not found."); }) .WithSubCommand("list", (args) => { var s = new StringBuilder(); var pairs = new List <KeyValuePair <string, PickupObject> >(); foreach (var pair in ETGMod.Items.Pairs) { pairs.Add(pair); } foreach (var pair in pairs) { if (_GetPickupObjectName(pair.Value) == "NO NAME") { s.AppendLine($"[{pair.Key}] {_GetPickupObjectName(pair.Value)}"); } } pairs.Sort((x, y) => string.Compare(_GetPickupObjectName(x.Value), _GetPickupObjectName(y.Value))); foreach (var pair in pairs) { if (_GetPickupObjectName(pair.Value) == "NO NAME") { continue; } s.AppendLine($"[{pair.Key}] {_GetPickupObjectName(pair.Value)}"); } return(s.ToString()); }) .WithSubCommand("random", (args) => { return(ETGMod.Items.RandomKey); }) ); AddCommand("listmods", (args) => { var s = new StringBuilder(); s.AppendLine("Loaded mods:"); foreach (var mod in ETGMod.ModLoader.LoadedMods) { _GetModInfo(s, mod); } return(s.ToString()); }); AddCommand("lua", (args) => { LuaMode = true; return("[entered lua mode]"); }); AddCommand("give", (args) => { LootEngine.TryGivePrefabToPlayer(ETGMod.Items[args[0]].gameObject, GameManager.Instance.PrimaryPlayer, true); return(args[0]); }); AddGroup("dump") .WithSubCommand("synergy_chest", (args) => { System.Console.WriteLine(ObjectDumper.Dump(GameManager.Instance.RewardManager.Synergy_Chest, depth: 10)); return("Dumped to log"); }) .WithSubCommand("synergies", (args) => { var id = 0; foreach (var synergy in GameManager.Instance.SynergyManager.synergies) { if (synergy.NameKey != null) { var name = StringTableManager.GetSynergyString(synergy.NameKey); System.Console.WriteLine($"== SYNERGY ID {id} NAME {name} =="); } else { System.Console.WriteLine($"== SYNERGY ID {id} =="); } System.Console.WriteLine($" ACTIVATION STATUS: {synergy.ActivationStatus}"); System.Console.WriteLine($" # OF OBJECTS REQUIRED: {synergy.NumberObjectsRequired}"); System.Console.WriteLine($" ACTIVE WHEN GUN UNEQUIPPED?: {synergy.ActiveWhenGunUnequipped}"); System.Console.WriteLine($" REQUIRES AT LEAST ONE GUN AND ONE ITEM?: {synergy.RequiresAtLeastOneGunAndOneItem}"); System.Console.WriteLine($" MANDATORY GUNS:"); foreach (var itemid in synergy.MandatoryGunIDs) { System.Console.WriteLine($" - {_GetPickupObjectName(PickupObjectDatabase.GetById(itemid))}"); } System.Console.WriteLine($" OPTIONAL GUNS:"); foreach (var itemid in synergy.OptionalGunIDs) { System.Console.WriteLine($" - {_GetPickupObjectName(PickupObjectDatabase.GetById(itemid))}"); } System.Console.WriteLine($" MANDATORY ITEMS:"); foreach (var itemid in synergy.MandatoryItemIDs) { System.Console.WriteLine($" - {_GetPickupObjectName(PickupObjectDatabase.GetById(itemid))}"); } System.Console.WriteLine($" OPTIONAL ITEMS:"); foreach (var itemid in synergy.OptionalItemIDs) { System.Console.WriteLine($" - {_GetPickupObjectName(PickupObjectDatabase.GetById(itemid))}"); } System.Console.WriteLine($" BONUS SYNERGIES:"); foreach (var bonus in synergy.bonusSynergies) { System.Console.WriteLine($" - {bonus}"); } System.Console.WriteLine($" STAT MODIFIERS:"); foreach (var statmod in synergy.statModifiers) { System.Console.WriteLine($" - STAT: {statmod.statToBoost}"); System.Console.WriteLine($" AMOUNT: {statmod.amount}"); System.Console.WriteLine($" MODIFY TYPE: {statmod.modifyType}"); System.Console.WriteLine($" PERSISTS ON COOP DEATH?: {statmod.PersistsOnCoopDeath}"); System.Console.WriteLine($" IGNORED FOR SAVE DATA?: {statmod.ignoredForSaveData}"); } id++; } return("Dumped to log"); }) .WithSubCommand("items", (args) => { var b = new StringBuilder(); var db = PickupObjectDatabase.Instance.Objects; for (int i = 0; i < db.Count; i++) { PickupObject obj = null; string nameprefix = ""; string name = null; try { obj = db[i]; } catch { name = "[ERROR: failed getting object by index]"; } if (obj != null) { try { var displayname = obj.encounterTrackable.journalData.PrimaryDisplayName; name = StringTableManager.ItemTable[displayname].GetWeightedString(); } catch { name = "[ERROR: failed getting ammonomicon name]"; } if (name == null) { try { name = obj.EncounterNameOrDisplayName; } catch { name = "[ERROR: failed getting encounter or display name]"; } } } if (name == null && obj != null) { name = "[NULL NAME (but object is not null)]"; } name = $"{nameprefix} {name}"; if (name != null) { b.AppendLine($"{i}: {name}"); _Logger.Info($"{i}: {name}"); } } return(b.ToString()); }); AddGroup("log") .WithSubCommand("sub", (args) => { if (_Subscribed) { return("Already subscribed."); } Logger.Subscribe(_LoggerSubscriber); _Subscribed = true; return("Done."); }) .WithSubCommand("unsub", (args) => { if (!_Subscribed) { return("Not subscribed yet."); } Logger.Unsubscribe(_LoggerSubscriber); _Subscribed = false; return("Done."); }) .WithSubCommand("level", (args) => { if (args.Count == 0) { return(_LogLevel.ToString().ToLowerInvariant()); } else { switch (args[0]) { case "debug": _LogLevel = Logger.LogLevel.Debug; break; case "info": _LogLevel = Logger.LogLevel.Info; break; case "warn": _LogLevel = Logger.LogLevel.Warn; break; case "error": _LogLevel = Logger.LogLevel.Error; break; default: throw new Exception($"Unknown log level '{args[0]}"); } return("Done."); } }); // test commands to dump collection AddGroup("texdump") .WithSubCommand("collection", (args) => { if (args.Count == 0) { return("No name specified"); } else { string collectionName = args[0]; Animation.Collection.Dump(collectionName); return("Successfull"); } }); }
public static int Distance(IntVector2 a, IntVector2 b) { return(a.Distance(b)); }
void Spawn(string[] args) { if (!ArgCount(args, 1, 2)) { return; } string id = args[0]; if (!Game.Enemies.ContainsID(id)) { Log($"Enemy with ID {id} doesn't exist"); return; } AIActor enemyPrefab = Game.Enemies[id]; Log("Spawning ID " + id); int count = 1; if (args.Length > 1) { bool success = int.TryParse(args[1], out count); if (!success) { Log("Second argument must be an integer (number)"); return; } } for (int i = 0; i < count; i++) { IntVector2?targetCenter = new IntVector2?(GameManager.Instance.PrimaryPlayer.CenterPosition.ToIntVector2(VectorConversions.Floor)); Pathfinding.CellValidator cellValidator = delegate(IntVector2 c) { for (int j = 0; j < enemyPrefab.Clearance.x; j++) { for (int k = 0; k < enemyPrefab.Clearance.y; k++) { if (GameManager.Instance.Dungeon.data.isTopWall(c.x + j, c.y + k)) { return(false); } if (targetCenter.HasValue) { if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) < 4) { return(false); } if (IntVector2.Distance(targetCenter.Value, c.x + j, c.y + k) > 20) { return(false); } } } } return(true); }; IntVector2?randomAvailableCell = GameManager.Instance.PrimaryPlayer.CurrentRoom.GetRandomAvailableCell(new IntVector2?(enemyPrefab.Clearance), new Dungeonator.CellTypes?(enemyPrefab.PathableTiles), false, cellValidator); if (randomAvailableCell.HasValue) { AIActor aIActor = AIActor.Spawn(enemyPrefab, randomAvailableCell.Value, GameManager.Instance.PrimaryPlayer.CurrentRoom, true, AIActor.AwakenAnimationType.Default, true); aIActor.HandleReinforcementFallIntoRoom(0); } } }
public float GetCenterDistance(IntVector2 pointPos) { return(pointPos.Distance(PosCenter)); }
public void AddTownConnection(IntVector2 v1, IntVector2 v2, System.Random rand) { float dist = v1.Distance(v2); if (dist > TownGenData.ConnectionCutDist0) { if (rand.NextDouble() < TownGenData.DistCutPer0) { GenCutPointNewLine(v1, v2, rand); } else { AddConnection(v1, v2); } } else { if (dist > TownGenData.ConnectionCutDist1) { if (rand.NextDouble() < TownGenData.DistCutPer1) { GenCutPointNewLine(v1, v2, rand); } else { AddConnection(v1, v2); } } else { if (dist > TownGenData.ConnectionCutDist2) { if (rand.NextDouble() < TownGenData.DistCutPer2) { GenCutPointNewLine(v1, v2, rand); } else { AddConnection(v1, v2); } } else { if (dist > TownGenData.ConnectionCutDist3) { if (rand.NextDouble() < TownGenData.DistCutPer3) { GenCutPointNewLine(v1, v2, rand); } else { AddConnection(v1, v2); } } else { AddConnection(v1, v2); } } } } }
public List <RandomMapTypePoint> InitBiomaPos() { System.Random myRand = new System.Random(RandomMapConfig.TownGenSeed); IntVector2 StartBiomaPos = GenTownPos(TownGenData.GenerationLine[PickedLineIndex].ToList()[0], myRand); List <IntVector2> biomaPosList = new List <IntVector2> (); List <RandomMapTypePoint> biomaDistList = new List <RandomMapTypePoint>(); int biomaPosCount = BiomaCount; for (int i = 1; i <= BiomaCount; i++) { if (i == (int)RandomMapConfig.RandomMapID) { biomaDistList.Add(new RandomMapTypePoint((RandomMapType)i, StartBiomaPos)); } else { biomaDistList.Add(new RandomMapTypePoint((RandomMapType)i)); } } if (MapSizeId > 1) { for (int i = 0; i < biomaPosCount; i++) { IntVector2 p = GetRealPos(new IntVector2(myRand.Next(-MapRadius, MapRadius), myRand.Next(-MapRadius, MapRadius))); if (biomaPosList.Contains(p)) { i--; } else if (StartBiomaPos.Distance(p) < 500) { i--; } else { bool isTooNear = false; foreach (IntVector2 pos in biomaPosList) { if (pos.Distance(p) < VFDataRTGen.changeBiomaDiff) { isTooNear = true; i--; break; } } if (!isTooNear) { biomaPosList.Add(p); } } } } else { if (MapSizeId == 1) { biomaPosCount = BiomaCount * 2; } else { biomaPosCount = BiomaCount * 4; } for (int i = 0; i < biomaPosCount; i++) { IntVector2 p = GetRealPos(new IntVector2(myRand.Next(-MapRadius, MapRadius), myRand.Next(-MapRadius, MapRadius))); if (biomaPosList.Contains(p)) { i--; } else if (StartBiomaPos.Distance(p) < 1000) { i--; } else { bool isTooNear = false; foreach (IntVector2 pos in biomaPosList) { if (pos.Distance(p) < VFDataRTGen.changeBiomaDiff) { isTooNear = true; i--; break; } } if (!isTooNear) { biomaPosList.Add(p); } } } } for (int i = 0; i < biomaPosCount; i++) { biomaDistList[i % BiomaCount].AddPos(biomaPosList[i]); } return(biomaDistList); }