├── .gitattributes
├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── TemBot
├── App.config
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Reflection.cs
├── ShinyFinder.cs
├── Steam.cs
├── TemBot.csproj
├── Temtems.cs
├── Temtems.json
└── packages.config
├── TemCleaner
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── TemCleaner.csproj
└── packages.config
├── TemSharp.Loader
├── App.config
├── App.xaml
├── App.xaml.cs
├── Core
│ ├── Compiler.cs
│ └── Injector.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── TemSharp.Loader.csproj
└── packages.config
├── TemSharp.sln
└── TemSharp
├── Common
├── Deobfuscator.cs
├── Menu.cs
├── Reflection.cs
└── SceneDebugger.cs
├── Init.cs
├── Mods
├── MonsterInfo.cs
├── Notice.cs
├── RemoveName.cs
└── Zoom.cs
├── Properties
└── AssemblyInfo.cs
└── TemSharp.csproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # JustCode is a .NET coding add-in
131 | .JustCode
132 |
133 | # TeamCity is a build add-in
134 | _TeamCity*
135 |
136 | # DotCover is a Code Coverage Tool
137 | *.dotCover
138 |
139 | # AxoCover is a Code Coverage Tool
140 | .axoCover/*
141 | !.axoCover/settings.json
142 |
143 | # Visual Studio code coverage results
144 | *.coverage
145 | *.coveragexml
146 |
147 | # NCrunch
148 | _NCrunch_*
149 | .*crunch*.local.xml
150 | nCrunchTemp_*
151 |
152 | # MightyMoose
153 | *.mm.*
154 | AutoTest.Net/
155 |
156 | # Web workbench (sass)
157 | .sass-cache/
158 |
159 | # Installshield output folder
160 | [Ee]xpress/
161 |
162 | # DocProject is a documentation generator add-in
163 | DocProject/buildhelp/
164 | DocProject/Help/*.HxT
165 | DocProject/Help/*.HxC
166 | DocProject/Help/*.hhc
167 | DocProject/Help/*.hhk
168 | DocProject/Help/*.hhp
169 | DocProject/Help/Html2
170 | DocProject/Help/html
171 |
172 | # Click-Once directory
173 | publish/
174 |
175 | # Publish Web Output
176 | *.[Pp]ublish.xml
177 | *.azurePubxml
178 | # Note: Comment the next line if you want to checkin your web deploy settings,
179 | # but database connection strings (with potential passwords) will be unencrypted
180 | *.pubxml
181 | *.publishproj
182 |
183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
184 | # checkin your Azure Web App publish settings, but sensitive information contained
185 | # in these scripts will be unencrypted
186 | PublishScripts/
187 |
188 | # NuGet Packages
189 | *.nupkg
190 | # NuGet Symbol Packages
191 | *.snupkg
192 | # The packages folder can be ignored because of Package Restore
193 | **/[Pp]ackages/*
194 | # except build/, which is used as an MSBuild target.
195 | !**/[Pp]ackages/build/
196 | # Uncomment if necessary however generally it will be regenerated when needed
197 | #!**/[Pp]ackages/repositories.config
198 | # NuGet v3's project.json files produces more ignorable files
199 | *.nuget.props
200 | *.nuget.targets
201 |
202 | # Microsoft Azure Build Output
203 | csx/
204 | *.build.csdef
205 |
206 | # Microsoft Azure Emulator
207 | ecf/
208 | rcf/
209 |
210 | # Windows Store app package directories and files
211 | AppPackages/
212 | BundleArtifacts/
213 | Package.StoreAssociation.xml
214 | _pkginfo.txt
215 | *.appx
216 | *.appxbundle
217 | *.appxupload
218 |
219 | # Visual Studio cache files
220 | # files ending in .cache can be ignored
221 | *.[Cc]ache
222 | # but keep track of directories ending in .cache
223 | !?*.[Cc]ache/
224 |
225 | # Others
226 | ClientBin/
227 | ~$*
228 | *~
229 | *.dbmdl
230 | *.dbproj.schemaview
231 | *.jfm
232 | *.pfx
233 | *.publishsettings
234 | orleans.codegen.cs
235 |
236 | # Including strong name files can present a security risk
237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
238 | #*.snk
239 |
240 | # Since there are multiple workflows, uncomment next line to ignore bower_components
241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
242 | #bower_components/
243 |
244 | # RIA/Silverlight projects
245 | Generated_Code/
246 |
247 | # Backup & report files from converting an old project file
248 | # to a newer Visual Studio version. Backup files are not needed,
249 | # because we have git ;-)
250 | _UpgradeReport_Files/
251 | Backup*/
252 | UpgradeLog*.XML
253 | UpgradeLog*.htm
254 | ServiceFabricBackup/
255 | *.rptproj.bak
256 |
257 | # SQL Server files
258 | *.mdf
259 | *.ldf
260 | *.ndf
261 |
262 | # Business Intelligence projects
263 | *.rdl.data
264 | *.bim.layout
265 | *.bim_*.settings
266 | *.rptproj.rsuser
267 | *- [Bb]ackup.rdl
268 | *- [Bb]ackup ([0-9]).rdl
269 | *- [Bb]ackup ([0-9][0-9]).rdl
270 |
271 | # Microsoft Fakes
272 | FakesAssemblies/
273 |
274 | # GhostDoc plugin setting file
275 | *.GhostDoc.xml
276 |
277 | # Node.js Tools for Visual Studio
278 | .ntvs_analysis.dat
279 | node_modules/
280 |
281 | # Visual Studio 6 build log
282 | *.plg
283 |
284 | # Visual Studio 6 workspace options file
285 | *.opt
286 |
287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
288 | *.vbw
289 |
290 | # Visual Studio LightSwitch build output
291 | **/*.HTMLClient/GeneratedArtifacts
292 | **/*.DesktopClient/GeneratedArtifacts
293 | **/*.DesktopClient/ModelManifest.xml
294 | **/*.Server/GeneratedArtifacts
295 | **/*.Server/ModelManifest.xml
296 | _Pvt_Extensions
297 |
298 | # Paket dependency manager
299 | .paket/paket.exe
300 | paket-files/
301 |
302 | # FAKE - F# Make
303 | .fake/
304 |
305 | # CodeRush personal settings
306 | .cr/personal
307 |
308 | # Python Tools for Visual Studio (PTVS)
309 | __pycache__/
310 | *.pyc
311 |
312 | # Cake - Uncomment if you are using it
313 | # tools/**
314 | # !tools/packages.config
315 |
316 | # Tabs Studio
317 | *.tss
318 |
319 | # Telerik's JustMock configuration file
320 | *.jmconfig
321 |
322 | # BizTalk build output
323 | *.btp.cs
324 | *.btm.cs
325 | *.odx.cs
326 | *.xsd.cs
327 |
328 | # OpenCover UI analysis results
329 | OpenCover/
330 |
331 | # Azure Stream Analytics local run output
332 | ASALocalRun/
333 |
334 | # MSBuild Binary and Structured Log
335 | *.binlog
336 |
337 | # NVidia Nsight GPU debugger configuration file
338 | *.nvuser
339 |
340 | # MFractors (Xamarin productivity tool) working folder
341 | .mfractor/
342 |
343 | # Local History for Visual Studio
344 | .localhistory/
345 |
346 | # BeatPulse healthcheck temp database
347 | healthchecksdb
348 |
349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
350 | MigrationBackup/
351 |
352 | # Ionide (cross platform F# VS Code tools) working folder
353 | .ionide/
354 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "SharpMonoInjector"]
2 | path = SharpMonoInjector
3 | url = https://github.com/warbler/SharpMonoInjector
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 shalzuth
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Don't run this as is
2 | You will get banned. There is new anti-cheat. My private closed-source platform (https://www.temsharp.com) bypasses this.
3 |
4 | ## How to Run
5 | - Download https://github.com/shalzuth/TemSharp/releases/download/beta/TemSharp.Loader.exe
6 | - Launch Game
7 | - Launch Exe, this will download https://github.com/shalzuth/TemSharp/tree/master/TemSharp and inject it
8 | - In game, when you have cursor (escape, tab, main menu, etc), you can enable/disable mods
9 |
10 | ## Available Mods
11 | - Disable Fights
12 | - Heal
13 | - Monster Info
14 | - Open Bank
15 | - Open Shop
16 | - Shiny Hunter
17 | - Speed
18 | - Teleporter
19 | - Zoom
20 |
21 | ## Disable Fights
22 | Only works in grass. Working on Trainer fight bypassing.
23 |
24 | ## Heal
25 | Heals your little guys up to full.
26 |
27 | ## Monster Info
28 | Shows SV info in battle.
29 |
30 | ## Open Bank
31 | Swap your Temtems on the fly.
32 |
33 | ## Open Shop
34 | Forget pokeballs? Buy them on the fly.
35 |
36 | ## Shiny Hunter
37 | Start mod in grass.
38 | Mod will:
39 | * Start fight
40 | * Fight or Flee
41 | * Repeat until a Shiny Pokeman is found, or minimum SV values are found
42 | Has option to disable graphics during battle.
43 |
44 | ## Speed
45 | Speeds up the game. Could be modified to make it go slower if there are requests.
46 |
47 | ## Teleporter
48 | Don't use in buildings/caverns
49 | Right Click on map to teleport to location
50 | Right Click on ground to teleport to mouse
51 |
52 | Using the numpad, 2, 4, 6, 8 will teleport you a couple blocks away.
53 |
54 | ## Zoom
55 | Pulls Mr Cameraman back a bit. And cleans up the blur effect.
56 |
57 | ## Remove Name
58 | Removes your name from appearing on the HUD.
59 |
60 | ## Extra
61 | I also left a clientless project in here. Goodluck getting it to work :)
62 |
63 | ## Donate coffee and/or beer
64 | I probably won't mix them.
65 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RZCNSSMSHTCE6)
66 |
67 | ## Legal stuff
68 |
69 | MIT License
70 |
71 | *Temsharp and Shalzuth aren't endorsed by CremaGames S.L., Crema and doesn’t reflect the views or opinions of CremaGames S.L., Crema or anyone officially involved in producing or managing CremaGames S.L., Crema. Game content and materials are trademarks and copyrights of CremaGames S.L., Crema*
72 |
--------------------------------------------------------------------------------
/TemBot/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/TemBot/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Sfs2X;
8 | using Sfs2X.Core;
9 | using Sfs2X.Entities.Data;
10 | using Sfs2X.Util;
11 | using Sfs2X.Protocol.Serialization;
12 |
13 | namespace TemBot
14 | {
15 | class Program
16 | {
17 | static void Main(string[] args)
18 | {
19 | typeof(Temtem.Network.NetworkLogic).SetField("dqnppqrrgeo", new SmartFox());
20 | var q = typeof(Temtem.Network.NetworkLogic).GetField();
21 | var monsters = typeof(Temtem.Battle.BattleClient).GetField();
22 | while (true)
23 | {
24 | var client = new ShinyFinder();
25 | while (client.SFClient.IsConnecting || client.SFClient.IsConnected || (client.fleeThread != null && client.fleeThread.IsAlive)) System.Threading.Thread.Sleep(1000);
26 | System.Threading.Thread.Sleep(1000);
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/TemBot/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("TemBot")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TemBot")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("ed617d8d-10d6-4504-8213-c024acbefad4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TemBot/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TemBot.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TemBot.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Byte[].
65 | ///
66 | internal static byte[] Temtems {
67 | get {
68 | object obj = ResourceManager.GetObject("Temtems", resourceCulture);
69 | return ((byte[])(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/TemBot/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Temtems.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
123 |
124 |
--------------------------------------------------------------------------------
/TemBot/Reflection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 |
6 | namespace TemBot
7 | {
8 | public static class Reflection
9 | {
10 | public static BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic |
11 | BindingFlags.Static | BindingFlags.FlattenHierarchy;
12 | public static Dictionary fields = new Dictionary();
13 | public static FieldInfo GetFieldFast(this Type type, String fieldName, String fieldType, String baseType)
14 | {
15 | var key = type.FullName + ":" + fieldName + "(" + fieldType + ")" + " " + baseType;
16 | if (fields.ContainsKey(key)) return fields[key];
17 | //UnityEngine.Debug.Log(key);
18 | var field = type.GetField(fieldName, flags);
19 | //UnityEngine.Debug.Log(field);
20 | if (field == null || !field.FieldType.Name.Contains(fieldType) || !field.DeclaringType.Name.Contains(baseType))
21 | field = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static).FirstOrDefault(f =>
22 | (String.IsNullOrEmpty(fieldName) || f.Name == fieldName)
23 | && f.FieldType.ToString().Contains(fieldType)
24 | && f.DeclaringType.ToString().Contains(baseType));
25 | if (field == null || !field.FieldType.Name.Contains(fieldType) || !field.DeclaringType.Name.Contains(baseType))
26 | field = type.GetFields(flags).FirstOrDefault(f =>
27 | (String.IsNullOrEmpty(fieldName) || f.Name == fieldName)
28 | && f.FieldType.ToString().Contains(fieldType)
29 | && f.DeclaringType.ToString().Contains(baseType));
30 | if (field == null) field = type.GetField(fieldName, flags);
31 | if (field != null) fields[key] = field;
32 | return field;
33 | }
34 | public static Dictionary properties = new Dictionary();
35 | public static PropertyInfo GetPropertyFast(this Type type, String propertyName, String propretyType, String baseType)
36 | {
37 | var key = type.FullName + "." + propertyName + "(" + propretyType + ")" + " " + baseType;
38 | if (properties.ContainsKey(key)) return properties[key];
39 | var property = type.GetProperty(propertyName, flags);
40 | if (!property.PropertyType.Name.Contains(propretyType) || !property.DeclaringType.Name.Contains(baseType))
41 | property = type.GetProperties(flags).FirstOrDefault(p => p.Name == propertyName
42 | && p.PropertyType.ToString().Contains(propretyType)
43 | && p.DeclaringType.ToString().Contains(baseType));
44 | if (property != null) properties[key] = property;
45 | return property;
46 | }
47 | public static Object GetField(this Object obj, String fieldName)
48 | {
49 | return obj.GetField(fieldName, "", "");
50 | }
51 | public static Object GetField(this Object obj, String fieldName, String fieldType, String baseType)
52 | {
53 | if (obj == null) return null;
54 | var objType = obj is Type ? (Type)obj : obj.GetType();
55 | var field = objType.GetFieldFast(fieldName, fieldType, baseType);
56 | if (field != null) return obj is Type ? field.GetValue(null) : field.GetValue(obj);
57 | var property = objType.GetPropertyFast(fieldName, fieldType, baseType);
58 | if (property != null) return obj is Type ? property.GetValue(null, null) : property.GetValue(obj, null);
59 | return null;
60 | }
61 | public static T GetField(this Type obj)
62 | {
63 | return (T)obj.GetField("", typeof(T).Name, obj.Name);
64 | }
65 | public static T GetField(this Object obj, String fieldName)
66 | {
67 | return (T)obj.GetField(fieldName, "", "");
68 | }
69 | public static Dictionary staticFields = new Dictionary();
70 | public static T GetField(this Object obj, String fieldName, String fieldType, String baseType)
71 | {
72 | if (String.IsNullOrEmpty(fieldType)) fieldType = typeof(T).Name;
73 | if (String.IsNullOrEmpty(baseType)) baseType = obj is Type ? ((Type)obj).Name : obj.GetType().Name;
74 | return (T)GetField(obj, fieldName, fieldType, baseType);
75 | }
76 | public static void SetField(this Object obj, String fieldName, String fieldType, String baseType, T val)
77 | {
78 | if (obj == null) return;
79 | var objType = obj.GetType();
80 | if (obj is Type)
81 | objType = (Type)obj;
82 | var field = objType.GetFieldFast(fieldName, fieldType, baseType);
83 | if (field != null)
84 | {
85 | field.SetValue(obj, val);
86 | return;
87 | }
88 | var property = objType.GetPropertyFast(fieldName, fieldType, baseType);
89 | if (property != null) property.SetValue(obj, val, null);
90 | }
91 | public static void SetField(this Object obj, String fieldName, T val)
92 | {
93 | obj.SetField(fieldName, val, "", "");
94 | }
95 | public static void SetField(this Object obj, String fieldName, T val, String fieldType, String baseType)
96 | {
97 | if (String.IsNullOrEmpty(fieldType))
98 | fieldType = typeof(T).Name;
99 | if (String.IsNullOrEmpty(baseType))
100 | baseType = obj is Type ? ((Type)obj).Name : obj.GetType().Name;
101 | SetField(obj, fieldName, fieldType, baseType, val);
102 | }
103 | public static List