Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

  • Days Won


Nypyren last won the day on July 28

Nypyren had the most liked content!

Community Reputation

12233 Excellent


About Nypyren

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Basically the reason to make this specific optimization is that if you do both a ContainsKey and also an indexer (dictionary[key]) operation, the code has to find the entry (or insertion point) in the dictionary twice. Although the entry lookup is amortized constant time (one GetHashCode call and usually one Equals call), why do it twice if you only need to do it once? If you find yourself in a chunk of code that only needs to call ContainsKey and nothing else, keep using ContainsKey. One neat thing you can use to judge complexity of built-in .Net code is to look at the reference source: https://referencesource.microsoft.com/#mscorlib/system/collections/generic/dictionary.cs While it might not always be exactly what ships in .Net, it should be close enough that you can base optimization decisions on it.
  2. I can't figure out how to quote just one small section of your code block, so... The section where you use messageDictionary.ContainsKey, Add, then [ ] operators can be condensed into a slightly more efficient form: Queue<string> queue; if (!messageDictionary.TryGetValue(so.epFrom, out queue) { messageDictionary.Add(so.epFrom, queue = new Queue<string>()); } queue.Enqueue(so.message); This is a pretty common pattern in C#. If you're using newer versions of C#, you can also say "out var queue" instead of defining the variable above TryGetValue.
  3. Delegate instances can be thought of as immutable lists of (object, method) pairs. It doesn't matter where the delegate instance lives; its behavior is only determined by what it contains and how it's invoked. The BeginReceive method controls which thread(s) the operation uses and what happens when it wants to invoke the callback. In .Net, there's a class called "SynchronizationContext" which is most frequently used to determine which thread asynchronous callbacks are run on. https://docs.microsoft.com/en-us/dotnet/api/system.threading.synchronizationcontext It's still up to the asynchronous code to decide whether to use the context or not. I don't remember off the top of my head if BeginReceive uses the synchronization context or not. The main thing that the SynchronizationContext allows is calling a function on a different thread. It does this by acting as a message queue. One thread adds delegates to a queue, and the other thread periodically reads from the queue and invokes the delegates. However, if the queue-reading thread is busy (or waiting for something) and isn't allowed to check on the queue, it can lead to deadlocks or lower throughput than what you want.
  4. You can quickly optimize the "new AsyncCallback(_Receive)" allocation by storing the AsyncCallback instance once in a member variable. These don't generate much garbage but they're trivial to deal with. You can use this optimization for any delegate as long as its captured variables (if it has any) don't change each time you use it.
  5. Nypyren

    Supporting mods in Unity game?

    For code: As long as you aren't using IL2CPP, you can dynamically load new C# DLLs (as long as you trust modders to not do malicious things in these DLLs). You can also use any other scripting language that works with C#, possibly even if you're using IL2CPP, as long as that language doesn't use any runtime code generation. For assets: You can load AssetBundles as long as they are compatible (any MonoBehaviours they use have to come from the assemblies your game shipped with) - this is how we do DLC where I work. You also have limited support to load "raw" assets and files (text files, typical File I/O, png files, etc). You can also programmatically construct several types of assets (images, meshes) at runtime, so you could write your own 3D model loading code if you wanted to spend the time doing that.
  6. I've never been able to edit-and-continue without suspending execution. It doesn't need to be a breakpoint; you just need to have the program suspended in the debugger. I wonder if you had a plugin that would suspend execution automatically when you started editing a file.
  7. The calling code has a fixed call to a placeholder to its PE's import address table. DLLs contain an export address table. The loader rewrites the placeholder in the caller's IAT with the real address after loading the DLL and figuring out what the absolute address of the actual function is. The lookup can be done either using function name OR ordinal (i.e. index). See the Import Address Table and Export Address Table sections of https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format If you want to do it the easy way at runtime, use LoadLibrary and GetProcAddress instead to avoid headaches. Other platforms use different formats (Mach-O, ELF, etc) and I'm not as familiar with low level details of those.
  8. Windows lets you pin folders to the 'File Explorer' if it's on your taskbar - this is what I do at work to keep everything quickly reachable. Another thing I use is the Address Bar on the taskbar, in combination with Favorites. You can favorite folders and the address bar will let you quickly search for any favorite you've got.
  9. But what benefit are political discussions, in the context of casual internet forums not dedicated to political discussion? Do they improve the participant's critical or rational thinking? Are practical and clever solutions to problems invented? Do people leave the discussion happier than when they joined it? No. The political discussions themselves are what are leading to increased toxicity in political culture.
  10. https://en.wikipedia.org/wiki/I_know_it_when_I_see_it
  11. Can we at least ban the "politics for the sake of politics" threads? If a thread is discussing politics-in-relation-to-development, then it might have useful content. Plain politics threads are worthless and should be closed immediately.
  12. Potential option: Cut the feature that the bug affects and release the feature later when you've fixed the bug. If you're close to a deadline with a large project, a freelancer may take too long to get familiar with your project to help. It may actually cause even more delays.
  13. Nypyren

    Find angle of radius at distance

    asin(x) is undefined when x is > 1, which would happen when distance-to-center is less than the radius. If you're inside the sphere, giving the maximum bonus (90 degrees) seems fine to me.
  14. Nypyren

    Find angle of radius at distance

    Zakwadya's first equation is correct. You form a right triangle: Point 1 = origin, Point 2 = center of circle, Point 3 = one of the tangent points on the circle. A tangent point is where a line from the origin touches the circle perpendicular to the center (and therefore is the right angle of the triangle). sin(angle) = opposite / hypotenuse, so angle = asin(o / h). The length of the hypotenuse is the distance from Point 1 to Point 2, and the length of the opposite is the radius of the circle.
  15. Put every ball on the same layer (I was assuming you have a single prefab for the ball anyway). Make that layer NOT collide with ITSELF. The screenshot example on the Unity page is for making layers that don't collide with others. But if you read further: "Change this to suit your needs: if, for example, you want Layer 1 to collide with Layer 2 and 3, but not with Layer 1, find the row for Layer 1, then check the boxes for the Layer 2 and Layer 3 colums, and leave the Layer 1 column checkbox blank."
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!