├── .editorconfig
├── .gitattributes
├── .github
├── Falloff.JPG
├── ISSUE_TEMPLATE
│ ├── bug-report.md
│ ├── feature_request.md
│ └── wiki-issue.md
├── Images
├── depth.JPG
├── diamond.jpg
├── lead_indicators.png
├── radial30.jpg
├── radial90.jpg
└── round.jpg
├── .gitignore
├── Audio
└── ARC
│ └── WEP
│ ├── ArcWepShipGatlingShot3d01.wav
│ ├── ArcWepShipGatlingShot3d02.wav
│ ├── ArcWepShipGatlingShot3d03.wav
│ ├── ArcWepShipGatlingShot3d04.wav
│ ├── ArcWepShipGatlingShot3d05.wav
│ ├── ArcWepShipGatlingShot3d06.wav
│ └── ArcWepShipGatlingShot3d07.wav
├── CONTRIBUTING.md
├── CoreSystems.csproj
├── CoreSystems.sln
├── Data
├── Audio.sbc
├── BlockCategories.sbc
├── BlockVariantGroups.sbc
├── CubeBlocks_Weapons.sbc
├── Energy_Ammo.sbc
├── Energy_Magazine.sbc
├── EntityComponents.sbc
├── Particles.sbc
├── Scripts
│ └── CoreSystems
│ │ ├── Ai
│ │ ├── AiComp
│ │ │ ├── AiCompFields.cs
│ │ │ └── AiCompRun.cs
│ │ ├── AiConstruct.cs
│ │ ├── AiConstructData.cs
│ │ ├── AiData.cs
│ │ ├── AiDatabase.cs
│ │ ├── AiEvents.cs
│ │ ├── AiFields.cs
│ │ ├── AiSupport.cs
│ │ ├── AiTargeting.cs
│ │ └── AiTypes.cs
│ │ ├── Api
│ │ ├── ApiBackend.cs
│ │ ├── ApiServer.cs
│ │ ├── CoreSystemsApiBase.cs
│ │ ├── CoreSystemsApiBlocks.cs
│ │ ├── CoreSystemsApiDefs.cs
│ │ ├── CoreSystemsApiPhantoms.cs
│ │ └── CoreSystemsPbApi.cs
│ │ ├── AudioVisual
│ │ ├── AvShot.cs
│ │ └── RunAv.cs
│ │ ├── Comms
│ │ ├── SignalProcessing.cs
│ │ ├── Space.cs
│ │ └── Spectrum.cs
│ │ ├── Coreparts
│ │ ├── Definitions
│ │ │ ├── AmmoTypes.cs
│ │ │ ├── Artillery.cs
│ │ │ ├── Assault Cannons.cs
│ │ │ ├── Autocannons.cs
│ │ │ ├── Gatlings.cs
│ │ │ ├── InteriorTurret.cs
│ │ │ ├── MasterConfig.cs
│ │ │ ├── Missiles.cs
│ │ │ ├── RailgunAnimations.cs
│ │ │ ├── Railguns.cs
│ │ │ └── SearchLight.cs
│ │ └── PartCompile.cs
│ │ ├── Definitions
│ │ ├── CoreDefinitions.cs
│ │ ├── CoreStructure.cs
│ │ ├── CoreSystems.cs
│ │ ├── PartAnimation.cs
│ │ └── SerializedConfigs
│ │ │ ├── AiValues.cs
│ │ │ ├── AmmoConstants.cs
│ │ │ ├── ConstructValues.cs
│ │ │ ├── Control
│ │ │ └── ProtoControl.cs
│ │ │ ├── CoreSettings.cs
│ │ │ ├── Misc.cs
│ │ │ ├── PacketTypes.cs
│ │ │ ├── Support
│ │ │ └── ProtoSupport.cs
│ │ │ ├── Upgrade
│ │ │ └── ProtoUpgrade.cs
│ │ │ └── Weapon
│ │ │ └── ProtoWeapon.cs
│ │ ├── EntityComp
│ │ ├── Controls
│ │ │ ├── Control
│ │ │ │ ├── ControlActions.cs
│ │ │ │ └── ControlUi.cs
│ │ │ ├── CreateCustomActions.cs
│ │ │ ├── Support
│ │ │ │ ├── SupportActions.cs
│ │ │ │ └── SupportUi.cs
│ │ │ ├── TerminalHelpers.cs
│ │ │ ├── Upgrade
│ │ │ │ ├── UpgradeActions.cs
│ │ │ │ └── UpgradeUi.cs
│ │ │ └── Weapon
│ │ │ │ ├── WeaponActions.cs
│ │ │ │ └── WeaponUi.cs
│ │ ├── EntityData.cs
│ │ ├── EntityEvents.cs
│ │ ├── EntityFields.cs
│ │ ├── EntityInit.cs
│ │ ├── EntityRun.cs
│ │ ├── EntityState.cs
│ │ ├── EntitySupport.cs
│ │ ├── ModelSupport
│ │ │ ├── Dummies.cs
│ │ │ ├── PartInfo.cs
│ │ │ └── RecursiveSubparts.cs
│ │ ├── Parts
│ │ │ ├── Control
│ │ │ │ ├── ControlComp.cs
│ │ │ │ ├── ControlData.cs
│ │ │ │ ├── ControlFields.cs
│ │ │ │ └── ControlTracking.cs
│ │ │ ├── PartFields.cs
│ │ │ ├── PartState.cs
│ │ │ ├── Support
│ │ │ │ ├── SupportAv.cs
│ │ │ │ ├── SupportCharge.cs
│ │ │ │ ├── SupportComp.cs
│ │ │ │ ├── SupportData.cs
│ │ │ │ ├── SupportFields.cs
│ │ │ │ ├── SupportManager.cs
│ │ │ │ ├── SupportMisc.cs
│ │ │ │ └── SupportTypes.cs
│ │ │ ├── Upgrade
│ │ │ │ ├── UpgradeComp.cs
│ │ │ │ ├── UpgradeData.cs
│ │ │ │ ├── UpgradeFields.cs
│ │ │ │ └── UpgradeTypes.cs
│ │ │ └── Weapon
│ │ │ │ ├── WeaponAv.cs
│ │ │ │ ├── WeaponComp.cs
│ │ │ │ ├── WeaponController.cs
│ │ │ │ ├── WeaponData.cs
│ │ │ │ ├── WeaponFields.cs
│ │ │ │ ├── WeaponHand.cs
│ │ │ │ ├── WeaponReload.cs
│ │ │ │ ├── WeaponShoot.cs
│ │ │ │ ├── WeaponState.cs
│ │ │ │ ├── WeaponTracking.cs
│ │ │ │ └── WeaponTypes.cs
│ │ └── PlatformInit.cs
│ │ ├── Projectiles
│ │ ├── Dtree.cs
│ │ ├── Projectile.cs
│ │ ├── ProjectileGen.cs
│ │ ├── ProjectileHits.cs
│ │ ├── ProjectileTypes.cs
│ │ └── Projectiles.cs
│ │ ├── Session
│ │ ├── SessionAnimationMgr.cs
│ │ ├── SessionCharging.cs
│ │ ├── SessionCleanUp.cs
│ │ ├── SessionCompMgr.cs
│ │ ├── SessionControls.cs
│ │ ├── SessionDamageMgr.cs
│ │ ├── SessionEvents.cs
│ │ ├── SessionEwar.cs
│ │ ├── SessionFields.cs
│ │ ├── SessionFutureEvents.cs
│ │ ├── SessionInit.cs
│ │ ├── SessionInventory.cs
│ │ ├── SessionJobs.cs
│ │ ├── SessionLocalPlayer.cs
│ │ ├── SessionModHandlers.cs
│ │ ├── SessionNetwork.cs
│ │ ├── SessionNetworkCMethods.cs
│ │ ├── SessionNetworkSMethods.cs
│ │ ├── SessionNetworkSupport.cs
│ │ ├── SessionRun.cs
│ │ ├── SessionSupport.cs
│ │ ├── SessionTypes.cs
│ │ └── SessionUpdate.cs
│ │ ├── Support
│ │ ├── Api
│ │ │ ├── NerdShieldAPI.cs
│ │ │ ├── ShieldApi.cs
│ │ │ └── WaterModAPI.cs
│ │ ├── Draw
│ │ │ ├── DebugDraw.cs
│ │ │ └── DrawExts.cs
│ │ ├── GridIntersect.cs
│ │ ├── Localization.cs
│ │ ├── Log.cs
│ │ ├── MathFuncs.cs
│ │ ├── MiscTypes.cs
│ │ ├── StaticUtils.cs
│ │ ├── Utils.cs
│ │ ├── VersionControl.cs
│ │ └── VoxelIntersect.cs
│ │ └── Ui
│ │ ├── Hud
│ │ ├── HudDraw.cs
│ │ ├── HudFields.cs
│ │ ├── HudSupport.cs
│ │ ├── HudText.cs
│ │ └── HudTextMaps.cs
│ │ ├── Targeting
│ │ ├── SupportClasses.cs
│ │ ├── TargetUiDraw.cs
│ │ ├── TargetUiFields.cs
│ │ └── TargetUiSelect.cs
│ │ └── UiInput.cs
├── TransparentMaterials.sbc
└── Weapons.sbc
├── License
├── Models
├── Cubes
│ └── Small
│ │ ├── AutocannonTurret_Barrel.mwm
│ │ ├── AutocannonTurret_Barrel_LOD1.mwm
│ │ ├── AutocannonTurret_Barrel_LOD2.mwm
│ │ ├── AutocannonTurret_Barrel_LOD3.mwm
│ │ ├── AutocannonTurret_Base.mwm
│ │ ├── AutocannonTurret_Base1.mwm
│ │ ├── AutocannonTurret_Base1_LOD1.mwm
│ │ ├── AutocannonTurret_Base1_LOD2.mwm
│ │ ├── AutocannonTurret_Base1_LOD3.mwm
│ │ ├── AutocannonTurret_Base_LOD1.mwm
│ │ ├── AutocannonTurret_Base_LOD2.mwm
│ │ └── AutocannonTurret_Base_LOD3.mwm
├── Empty.mwm
├── Environment
│ └── JumpNullField.mwm
└── Weapons
│ └── Projectile_Missile.mwm
├── README.md
├── RechargeAtlas.psd
├── RelaodingIcon.psd
├── Textures
├── Display_add.dds
├── Display_cm.dds
├── Display_ng.dds
└── GUI
│ ├── EmoteLeadIcons.dds
│ ├── EnglishFontMono.dds
│ ├── EnglishFontShadow.dds
│ ├── HUD
│ ├── BlockTargetAtlas.dds
│ ├── WC_HUD_DroneAlert.dds
│ ├── WC_HUD_Minimal.dds
│ ├── WC_HUD_Minimal_Active.dds
│ ├── WC_HUD_NoShield.dds
│ ├── WC_HUD_NoShieldTarget.dds
│ ├── WC_HUD_Shield.dds
│ └── WC_HUD_ShieldTarget.dds
│ ├── HeatAtlas_bar.dds
│ ├── Icons
│ ├── Actions
│ │ └── Cycle_Ammo.dds
│ ├── RechargeAtlas.dds
│ ├── ReloadingIcon.dds
│ ├── TelionAMACMAmmo.dds
│ └── TurretFocusReticle.dds
│ ├── LeadingLine.dds
│ ├── Reloading.dds
│ ├── SelectedReticle.dds
│ ├── ShapeLeadIcons.dds
│ ├── TargetLeadReticle.dds
│ ├── TargetLeadReticle2.dds
│ ├── TargetReticle.dds
│ ├── WC_turret_overlay.dds
│ ├── WeaponStatWindow.dds
│ ├── lockon_01.dds
│ ├── lockon_02.dds
│ ├── lockon_03.dds
│ ├── lockon_04.dds
│ ├── lockon_05.dds
│ ├── lockon_06.dds
│ ├── lockon_07.dds
│ ├── lockon_08.dds
│ ├── lockon_09.dds
│ ├── lockon_10.dds
│ ├── lockon_11.dds
│ ├── lockon_12.dds
│ ├── lockon_13.dds
│ ├── lockon_14.dds
│ ├── lockon_15.dds
│ ├── lockon_16.dds
│ ├── lockon_17.dds
│ ├── lockon_18.dds
│ ├── lockon_19.dds
│ ├── lockon_20.dds
│ └── lockon_gif.gif
├── metadata.mod
├── modinfo.sbmi
└── packages.config
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # ProhibitedMemberRuleM: Prohibited Type Or Member(Mod script)
4 | dotnet_diagnostic.ProhibitedMemberRuleM.severity = warning
5 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/Falloff.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/.github/Falloff.JPG
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug Report
3 | about: Leave a bug report, tell us whats wrong! Please read the issue posting guidelines
4 | before posting, it's in the wiki!
5 | title: ''
6 | labels: Bug Report
7 | assignees: ''
8 |
9 | ---
10 |
11 | ## Is this a multiplayer or singleplayer bug?
12 |
13 |
14 |
15 | ## Describe the bug:
16 |
17 |
18 |
19 | ## Steps To Reproduce:
20 |
21 |
22 |
23 | ## Expected behavior:
24 |
25 |
26 |
27 | ### User Error Report (if Weapon-Specific) and log files
28 | *WeaponCore lets you generate an error report for a specific weapon, while ingame, hold Ctrl+R and aim the red line at the Weapon that is erroring, and an error report will be generated in WeaponCores log cache: `Users\UserName\AppData\Roaming\SpaceEngineers\Storage\1918681825.sbm_WeaponCore`
29 |
30 | Zip up that folder and link it here:
31 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "(Suggestion / Enhancement) "
5 | labels: Enhancement Request
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe:**
11 |
12 |
13 | **Describe the solution or feature you'd like:**
14 |
15 |
16 | **Additional context:**
17 |
18 | Add any other context or screenshots about the feature request here.
19 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/wiki-issue.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Wiki Issue
3 | about: Find an issue with the wiki? Please describe it here!
4 | title: ''
5 | labels: Wiki Issue
6 | assignees: ''
7 |
8 | ---
9 |
10 | ## Please link to the page with an error:
11 |
12 |
13 |
14 | ## Where is the issue, and what should be changed?
15 |
--------------------------------------------------------------------------------
/.github/Images:
--------------------------------------------------------------------------------
1 | Placeholder
2 |
--------------------------------------------------------------------------------
/.github/depth.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/.github/depth.JPG
--------------------------------------------------------------------------------
/.github/diamond.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/.github/diamond.jpg
--------------------------------------------------------------------------------
/.github/lead_indicators.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/.github/lead_indicators.png
--------------------------------------------------------------------------------
/.github/radial30.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/.github/radial30.jpg
--------------------------------------------------------------------------------
/.github/radial90.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/.github/radial90.jpg
--------------------------------------------------------------------------------
/.github/round.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/.github/round.jpg
--------------------------------------------------------------------------------
/.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 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015/2017 cache/options directory
29 | .vs/
30 | # Uncomment if you have tasks that create the project's static files in wwwroot
31 | #wwwroot/
32 |
33 | # Visual Studio 2017 auto generated files
34 | Generated\ Files/
35 |
36 | # MSTest test Results
37 | [Tt]est[Rr]esult*/
38 | [Bb]uild[Ll]og.*
39 |
40 | # NUNIT
41 | *.VisualState.xml
42 | TestResult.xml
43 |
44 | # Build Results of an ATL Project
45 | [Dd]ebugPS/
46 | [Rr]eleasePS/
47 | dlldata.c
48 |
49 | # Benchmark Results
50 | BenchmarkDotNet.Artifacts/
51 |
52 | # .NET Core
53 | project.lock.json
54 | project.fragment.lock.json
55 | artifacts/
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_h.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *_wpftmp.csproj
81 | *.log
82 | *.vspscc
83 | *.vssscc
84 | .builds
85 | *.pidb
86 | *.svclog
87 | *.scc
88 |
89 | # Chutzpah Test files
90 | _Chutzpah*
91 |
92 | # Visual C++ cache files
93 | ipch/
94 | *.aps
95 | *.ncb
96 | *.opendb
97 | *.opensdf
98 | *.sdf
99 | *.cachefile
100 | *.VC.db
101 | *.VC.VC.opendb
102 |
103 | # Visual Studio profiler
104 | *.psess
105 | *.vsp
106 | *.vspx
107 | *.sap
108 |
109 | # Visual Studio Trace Files
110 | *.e2e
111 |
112 | # TFS 2012 Local Workspace
113 | $tf/
114 |
115 | # Guidance Automation Toolkit
116 | *.gpState
117 |
118 | # ReSharper is a .NET coding add-in
119 | _ReSharper*/
120 | *.[Rr]e[Ss]harper
121 | *.DotSettings.user
122 |
123 | # JustCode is a .NET coding add-in
124 | .JustCode
125 |
126 | # TeamCity is a build add-in
127 | _TeamCity*
128 |
129 | # DotCover is a Code Coverage Tool
130 | *.dotCover
131 |
132 | # AxoCover is a Code Coverage Tool
133 | .axoCover/*
134 | !.axoCover/settings.json
135 |
136 | # Visual Studio code coverage results
137 | *.coverage
138 | *.coveragexml
139 |
140 | # NCrunch
141 | _NCrunch_*
142 | .*crunch*.local.xml
143 | nCrunchTemp_*
144 |
145 | # MightyMoose
146 | *.mm.*
147 | AutoTest.Net/
148 |
149 | # Web workbench (sass)
150 | .sass-cache/
151 |
152 | # Installshield output folder
153 | [Ee]xpress/
154 |
155 | # DocProject is a documentation generator add-in
156 | DocProject/buildhelp/
157 | DocProject/Help/*.HxT
158 | DocProject/Help/*.HxC
159 | DocProject/Help/*.hhc
160 | DocProject/Help/*.hhk
161 | DocProject/Help/*.hhp
162 | DocProject/Help/Html2
163 | DocProject/Help/html
164 |
165 | # Click-Once directory
166 | publish/
167 |
168 | # Publish Web Output
169 | *.[Pp]ublish.xml
170 | *.azurePubxml
171 | # Note: Comment the next line if you want to checkin your web deploy settings,
172 | # but database connection strings (with potential passwords) will be unencrypted
173 | *.pubxml
174 | *.publishproj
175 |
176 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
177 | # checkin your Azure Web App publish settings, but sensitive information contained
178 | # in these scripts will be unencrypted
179 | PublishScripts/
180 |
181 | # NuGet Packages
182 | *.nupkg
183 | # The packages folder can be ignored because of Package Restore
184 | **/[Pp]ackages/*
185 | # except build/, which is used as an MSBuild target.
186 | !**/[Pp]ackages/build/
187 | # Uncomment if necessary however generally it will be regenerated when needed
188 | #!**/[Pp]ackages/repositories.config
189 | # NuGet v3's project.json files produces more ignorable files
190 | *.nuget.props
191 | *.nuget.targets
192 |
193 | # Microsoft Azure Build Output
194 | csx/
195 | *.build.csdef
196 |
197 | # Microsoft Azure Emulator
198 | ecf/
199 | rcf/
200 |
201 | # Windows Store app package directories and files
202 | AppPackages/
203 | BundleArtifacts/
204 | Package.StoreAssociation.xml
205 | _pkginfo.txt
206 | *.appx
207 |
208 | # Visual Studio cache files
209 | # files ending in .cache can be ignored
210 | *.[Cc]ache
211 | # but keep track of directories ending in .cache
212 | !*.[Cc]ache/
213 |
214 | # Others
215 | ClientBin/
216 | ~$*
217 | *~
218 | *.dbmdl
219 | *.dbproj.schemaview
220 | *.jfm
221 | *.pfx
222 | *.publishsettings
223 | orleans.codegen.cs
224 |
225 | # Including strong name files can present a security risk
226 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
227 | #*.snk
228 |
229 | # Since there are multiple workflows, uncomment next line to ignore bower_components
230 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
231 | #bower_components/
232 |
233 | # RIA/Silverlight projects
234 | Generated_Code/
235 |
236 | # Backup & report files from converting an old project file
237 | # to a newer Visual Studio version. Backup files are not needed,
238 | # because we have git ;-)
239 | _UpgradeReport_Files/
240 | Backup*/
241 | UpgradeLog*.XML
242 | UpgradeLog*.htm
243 | ServiceFabricBackup/
244 | *.rptproj.bak
245 |
246 | # SQL Server files
247 | *.mdf
248 | *.ldf
249 | *.ndf
250 |
251 | # Business Intelligence projects
252 | *.rdl.data
253 | *.bim.layout
254 | *.bim_*.settings
255 | *.rptproj.rsuser
256 |
257 | # Microsoft Fakes
258 | FakesAssemblies/
259 |
260 | # GhostDoc plugin setting file
261 | *.GhostDoc.xml
262 |
263 | # Node.js Tools for Visual Studio
264 | .ntvs_analysis.dat
265 | node_modules/
266 |
267 | # Visual Studio 6 build log
268 | *.plg
269 |
270 | # Visual Studio 6 workspace options file
271 | *.opt
272 |
273 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
274 | *.vbw
275 |
276 | # Visual Studio LightSwitch build output
277 | **/*.HTMLClient/GeneratedArtifacts
278 | **/*.DesktopClient/GeneratedArtifacts
279 | **/*.DesktopClient/ModelManifest.xml
280 | **/*.Server/GeneratedArtifacts
281 | **/*.Server/ModelManifest.xml
282 | _Pvt_Extensions
283 |
284 | # Paket dependency manager
285 | .paket/paket.exe
286 | paket-files/
287 |
288 | # FAKE - F# Make
289 | .fake/
290 |
291 | # JetBrains Rider
292 | .idea/
293 | *.sln.iml
294 |
295 | # CodeRush personal settings
296 | .cr/personal
297 |
298 | # Python Tools for Visual Studio (PTVS)
299 | __pycache__/
300 | *.pyc
301 |
302 | # Cake - Uncomment if you are using it
303 | # tools/**
304 | # !tools/packages.config
305 |
306 | # Tabs Studio
307 | *.tss
308 |
309 | # Telerik's JustMock configuration file
310 | *.jmconfig
311 |
312 | # BizTalk build output
313 | *.btp.cs
314 | *.btm.cs
315 | *.odx.cs
316 | *.xsd.cs
317 |
318 | # OpenCover UI analysis results
319 | OpenCover/
320 |
321 | # Azure Stream Analytics local run output
322 | ASALocalRun/
323 |
324 | # MSBuild Binary and Structured Log
325 | *.binlog
326 |
327 | # NVidia Nsight GPU debugger configuration file
328 | *.nvuser
329 |
330 | # MFractors (Xamarin productivity tool) working folder
331 | .mfractor/
332 |
333 | # Local History for Visual Studio
334 | .localhistory/
335 | Models/Cubes/AmmoOrb.blockdef.xml
336 | Models/Cubes/AmmoOrb.fbx
337 | Models/Cubes/AmmoOrb.xml
338 |
339 | /Data/Textures/GUI
340 | /Data/Textures
341 | /Data/Models
342 | /WeaponCore.csproj.bak
343 | Textures/GUI/WC_NewHUD_Icons.psd
344 |
--------------------------------------------------------------------------------
/Audio/ARC/WEP/ArcWepShipGatlingShot3d01.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/Audio/ARC/WEP/ArcWepShipGatlingShot3d01.wav
--------------------------------------------------------------------------------
/Audio/ARC/WEP/ArcWepShipGatlingShot3d02.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/Audio/ARC/WEP/ArcWepShipGatlingShot3d02.wav
--------------------------------------------------------------------------------
/Audio/ARC/WEP/ArcWepShipGatlingShot3d03.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/Audio/ARC/WEP/ArcWepShipGatlingShot3d03.wav
--------------------------------------------------------------------------------
/Audio/ARC/WEP/ArcWepShipGatlingShot3d04.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/Audio/ARC/WEP/ArcWepShipGatlingShot3d04.wav
--------------------------------------------------------------------------------
/Audio/ARC/WEP/ArcWepShipGatlingShot3d05.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/Audio/ARC/WEP/ArcWepShipGatlingShot3d05.wav
--------------------------------------------------------------------------------
/Audio/ARC/WEP/ArcWepShipGatlingShot3d06.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/Audio/ARC/WEP/ArcWepShipGatlingShot3d06.wav
--------------------------------------------------------------------------------
/Audio/ARC/WEP/ArcWepShipGatlingShot3d07.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ash-LikeSnow/WeaponCore/db3c20e41a1b401910a69ddd7658eb63606743df/Audio/ARC/WEP/ArcWepShipGatlingShot3d07.wav
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # To be populated
2 |
--------------------------------------------------------------------------------
/CoreSystems.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.13.35806.99 d17.13
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreSystems", "CoreSystems.csproj", "{A02FF223-D75F-45ED-84F4-63ED89AFCCE9}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x64 = Debug|x64
12 | Release|Any CPU = Release|Any CPU
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {A02FF223-D75F-45ED-84F4-63ED89AFCCE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {A02FF223-D75F-45ED-84F4-63ED89AFCCE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {A02FF223-D75F-45ED-84F4-63ED89AFCCE9}.Debug|x64.ActiveCfg = Debug|x64
19 | {A02FF223-D75F-45ED-84F4-63ED89AFCCE9}.Debug|x64.Build.0 = Debug|x64
20 | {A02FF223-D75F-45ED-84F4-63ED89AFCCE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {A02FF223-D75F-45ED-84F4-63ED89AFCCE9}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {A02FF223-D75F-45ED-84F4-63ED89AFCCE9}.Release|x64.ActiveCfg = Release|x64
23 | {A02FF223-D75F-45ED-84F4-63ED89AFCCE9}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {8C5070A9-283B-46F6-9A41-A1F1F5EB022C}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/Data/Audio.sbc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | MyObjectBuilder_AudioDefinition
7 | ArcWepShipGatlingShot
8 |
9 | SHOT
10 | 200
11 | 0
12 | HeavyFight
13 | 3
14 |
15 |
16 |
17 | 0.7
18 |
19 |
20 | Audio\ARC\WEP\ArcWepShipGatlingShot3d01.wav
21 |
22 |
23 | Audio\ARC\WEP\ArcWepShipGatlingShot3d02.wav
24 |
25 |
26 | Audio\ARC\WEP\ArcWepShipGatlingShot3d03.wav
27 |
28 |
29 | Audio\ARC\WEP\ArcWepShipGatlingShot3d04.wav
30 |
31 |
32 | Audio\ARC\WEP\ArcWepShipGatlingShot3d05.wav
33 |
34 |
35 | Audio\ARC\WEP\ArcWepShipGatlingShot3d06.wav
36 |
37 |
38 | Audio\ARC\WEP\ArcWepShipGatlingShot3d07.wav
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Data/BlockCategories.sbc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | GuiBlockCategoryDefinition
8 |
9 |
10 | DisplayName_Category_LargeBlocks
11 | Section1_Position1_LargeBlocks
12 | true
13 |
14 | ConveyorSorter/LargeRailgun
15 |
16 |
17 |
18 |
19 |
20 | GuiBlockCategoryDefinition
21 |
22 |
23 | DisplayName_Category_SmallBlocks
24 | Section1_Position1_SmallBlocks
25 | true
26 |
27 | LargeMissileTurret/AutoCannonTurret
28 | ConveyorSorter/SmallRailgun
29 |
30 |
31 |
32 |
33 |
34 | GuiBlockCategoryDefinition
35 | Nonarmor
36 |
37 | DisplayName_Category_Nonarmor
38 | Section1_Position2_Nonarmor
39 | true
40 |
41 | LargeMissileTurret/AutoCannonTurret
42 | ConveyorSorter/LargeRailgun
43 | ConveyorSorter/SmallRailgun
44 |
45 |
46 |
47 |
48 | GuiBlockCategoryDefinition
49 | Weapons
50 |
51 | DisplayName_Category_Weapons
52 | Section1_Position3_Weapons
53 | true
54 |
55 | LargeMissileTurret/AutoCannonTurret
56 | ConveyorSorter/LargeRailgun
57 | ConveyorSorter/SmallRailgun
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Data/BlockVariantGroups.sbc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Textures\GUI\Icons\Cubes\missile_launcher.dds
8 | DisplayName_BlockGroup_ShipWeaponStaticGroup
9 | Description_BlockGroup_ShipWeaponStaticGroup
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | Textures\GUI\Icons\Cubes\gatling_turret.dds
30 | DisplayName_BlockGroup_TurretGroup
31 | Description_BlockGroup_TurretGroup
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Data/Energy_Ammo.sbc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | AmmoDefinition
7 | Blank
8 |
9 |
10 | 0
11 | 0
12 | 0
13 | 0
14 |
15 |
16 | 0
17 | 0
18 | 0
19 |
20 | 0
21 | 0
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Data/Energy_Magazine.sbc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | AmmoMagazine
7 | Energy
8 |
9 | Energy
10 | Textures\GUI\Icons\component\BatteryComponent.dds
11 |
12 | 0.25
13 | 0.2
14 | 0.2
15 |
16 | 1
17 | 1
18 | Models\Components\PowerCellComponent.mwm
19 | 1
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Data/EntityComponents.sbc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ModStorageComponent
6 | WeaponCore
7 |
8 |
9 | 75BBB4F5-4FB9-4230-BEEF-BB79C9811501
10 | 75BBB4F5-4FB9-4230-BEEF-BB79C9811502
11 | 75BBB4F5-4FB9-4230-BEEF-BB79C9811503
12 | 75BBB4F5-4FB9-4230-BEEF-BB79C9811504
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Ai/AiComp/AiCompFields.cs:
--------------------------------------------------------------------------------
1 | namespace CoreSystems.Support
2 | {
3 | public partial class AiComponent
4 | {
5 | internal readonly Ai Ai;
6 | public AiComponent(Ai ai)
7 | {
8 | Ai = ai;
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Ai/AiComp/AiCompRun.cs:
--------------------------------------------------------------------------------
1 | using VRage.Game.Components;
2 |
3 | namespace CoreSystems.Support
4 | {
5 | public partial class AiComponent : MyEntityComponentBase
6 | {
7 | public override void OnAddedToContainer()
8 | {
9 | base.OnAddedToContainer();
10 | }
11 |
12 | public override void OnAddedToScene()
13 | {
14 | base.OnAddedToScene();
15 | }
16 |
17 | public override void OnBeforeRemovedFromContainer()
18 | {
19 | base.OnBeforeRemovedFromContainer();
20 | }
21 |
22 |
23 | internal void OnAddedToSceneTasks()
24 | {
25 | }
26 |
27 | public override void OnRemovedFromScene()
28 | {
29 | base.OnRemovedFromScene();
30 | }
31 |
32 | public override bool IsSerialized()
33 | {
34 | if (Session.I.IsServer)
35 | {
36 | Ai.Data.Save();
37 | Ai.Construct.Data.Save();
38 | }
39 | return false;
40 | }
41 |
42 | public override string ComponentTypeDebugString => "CoreSystems";
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Ai/AiConstructData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using CoreSystems.Support;
3 | using Sandbox.Game.EntityComponents;
4 | using Sandbox.ModAPI;
5 |
6 | namespace CoreSystems
7 | {
8 | public class ConstructData
9 | {
10 | internal Ai Ai;
11 | public ConstructDataValues Repo;
12 |
13 |
14 | internal void Init(Ai ai)
15 | {
16 | Ai = ai;
17 |
18 | StorageInit();
19 | Load();
20 |
21 | if (Session.I.IsServer)
22 | {
23 | Repo.FocusData = new FocusData();
24 | }
25 | }
26 |
27 | public void Clean()
28 | {
29 | Repo.FocusData = null;
30 | Repo = null;
31 | Ai = null;
32 | }
33 |
34 | public void StorageInit()
35 | {
36 | if (Ai.TopEntity.Storage == null)
37 | Ai.TopEntity.Storage = new MyModStorageComponent { [Session.I.ConstructDataGuid] = "" };
38 | else if (!Ai.TopEntity.Storage.ContainsKey(Session.I.ConstructDataGuid))
39 | Ai.TopEntity.Storage[Session.I.ConstructDataGuid] = "";
40 | }
41 |
42 | public void Save()
43 | {
44 | if (Ai.TopEntity.Storage == null) return;
45 | var binary = MyAPIGateway.Utilities.SerializeToBinary(Repo);
46 | Ai.TopEntity.Storage[Session.I.ConstructDataGuid] = Convert.ToBase64String(binary);
47 | }
48 |
49 | public void Load()
50 | {
51 | if (Ai.TopEntity.Storage == null) return;
52 |
53 | ConstructDataValues load = null;
54 | string rawData;
55 | bool validData = false;
56 |
57 | if (Ai.TopEntity.Storage.TryGetValue(Session.I.ConstructDataGuid, out rawData))
58 | {
59 | try
60 | {
61 | var base64 = Convert.FromBase64String(rawData);
62 | load = MyAPIGateway.Utilities.SerializeFromBinary(base64);
63 | validData = load != null;
64 | }
65 | catch (Exception e)
66 | {
67 | //Log.Line("Invalid PartState Loaded, Re-init");
68 | }
69 | }
70 | else Log.Line("Storage didn't contain ConstructDataGuid");
71 |
72 | Repo = validData ? load : new ConstructDataValues();
73 |
74 | if (Repo.FocusData == null)
75 | Repo.FocusData = new FocusData();
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Ai/AiData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using CoreSystems.Support;
3 | using Sandbox.Game.EntityComponents;
4 | using Sandbox.ModAPI;
5 |
6 | namespace CoreSystems
7 | {
8 | public class AiData
9 | {
10 | public Ai Ai;
11 | public AiDataValues Repo;
12 |
13 |
14 | public void Init(Ai ai)
15 | {
16 | Ai = ai;
17 |
18 | StorageInit();
19 | Load();
20 | }
21 |
22 | public void Clean()
23 | {
24 | Ai = null;
25 | Repo = null;
26 | }
27 |
28 | public void StorageInit()
29 | {
30 | if (Ai.TopEntity.Storage == null)
31 | Ai.TopEntity.Storage = new MyModStorageComponent { [Session.I.AiDataGuid] = "" };
32 | else if (!Ai.TopEntity.Storage.ContainsKey(Session.I.AiDataGuid))
33 | Ai.TopEntity.Storage[Session.I.AiDataGuid] = "";
34 | }
35 |
36 | public void Save()
37 | {
38 | if (Ai.TopEntity.Storage == null) return;
39 | Ai.LastAiDataSave = Session.I.Tick;
40 | var binary = MyAPIGateway.Utilities.SerializeToBinary(Repo);
41 | Ai.TopEntity.Storage[Session.I.AiDataGuid] = Convert.ToBase64String(binary);
42 | }
43 |
44 | public void Load()
45 | {
46 | if (Ai.TopEntity.Storage == null) return;
47 |
48 | AiDataValues load = null;
49 | string rawData;
50 | bool validData = false;
51 |
52 | if (Ai.TopEntity.Storage.TryGetValue(Session.I.AiDataGuid, out rawData))
53 | {
54 | try
55 | {
56 | var base64 = Convert.FromBase64String(rawData);
57 | load = MyAPIGateway.Utilities.SerializeFromBinary(base64);
58 | validData = load != null;
59 | }
60 | catch (Exception e)
61 | {
62 | //Log.Line("Invalid PartState Loaded, Re-init");
63 | }
64 | }
65 |
66 | if (validData)
67 | Repo = load;
68 | else
69 | Repo = new AiDataValues();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Api/ApiServer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using CoreSystems.Support;
4 | using Sandbox.ModAPI;
5 |
6 | namespace CoreSystems.Api
7 | {
8 | public class ApiServer
9 | {
10 | private const long Channel = 67549756549;
11 |
12 | ///
13 | /// Is the API ready to be serve
14 | ///
15 | public bool IsReady { get; private set; }
16 |
17 | private void HandleMessage(object o)
18 | {
19 | if ((o as string) == "ApiEndpointRequest")
20 | MyAPIGateway.Utilities.SendModMessage(Channel, Session.I.Api.ModApiMethods);
21 | }
22 |
23 | private bool _isRegistered;
24 |
25 | ///
26 | /// Prepares the client to receive API endpoints and requests an update.
27 | ///
28 | public void Load()
29 | {
30 | if (!_isRegistered)
31 | {
32 | _isRegistered = true;
33 | MyAPIGateway.Utilities.RegisterMessageHandler(Channel, HandleMessage);
34 | }
35 | IsReady = true;
36 | try
37 | {
38 | MyAPIGateway.Utilities.SendModMessage(Channel, Session.I.Api.ModApiMethods);
39 |
40 | }
41 | catch (Exception ex) { Log.Line($"Exception in Api Load: {ex}", null, true); }
42 | }
43 |
44 |
45 | ///
46 | /// Unloads all API endpoints and detaches events.
47 | ///
48 | public void Unload()
49 | {
50 | if (_isRegistered)
51 | {
52 | _isRegistered = false;
53 | MyAPIGateway.Utilities.UnregisterMessageHandler(Channel, HandleMessage);
54 | }
55 | IsReady = false;
56 | MyAPIGateway.Utilities.SendModMessage(Channel, new Dictionary());
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Api/CoreSystemsApiBlocks.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Sandbox.ModAPI;
4 |
5 | namespace CoreSystems.Api
6 | {
7 | ///
8 | /// https://github.com/sstixrud/CoreSystems/blob/master/BaseData/Scripts/CoreSystems/Api/CoreSystemsApiBlocks.cs
9 | ///
10 | public partial class WcApi
11 | {
12 | private Func, bool> _getBlockWeaponMap;
13 |
14 | public bool GetBlockWeaponMap(IMyTerminalBlock weaponBlock, IDictionary collection) =>
15 | _getBlockWeaponMap?.Invoke(weaponBlock, collection) ?? false;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Api/CoreSystemsApiPhantoms.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using VRage;
3 | using VRageMath;
4 | using VRage.Game.Entity;
5 |
6 | namespace CoreSystems.Api
7 | {
8 | ///
9 | /// https://github.com/sstixrud/CoreSystems/blob/master/BaseData/Scripts/CoreSystems/Api/CoreSystemsApiPhantoms.cs
10 | ///
11 | public partial class WcApi
12 | {
13 | public enum TriggerActions
14 | {
15 | TriggerOff,
16 | TriggerOn,
17 | TriggerOnce,
18 | }
19 |
20 | private Func> _getTargetAssessment;
21 | //private Action>> _getPhantomInfo;
22 | private Action _setTriggerState;
23 | private Action _addMagazines;
24 | private Action _setAmmo;
25 | private Func _closePhantom;
26 | private Func _spawnPhantom;
27 | private Func _setPhantomFocusTarget;
28 |
29 | ///
30 | /// Get information about a particular target relative to this phantom
31 | ///
32 | ///
33 | ///
34 | ///
35 | ///
36 | ///
37 | internal void GetTargetAssessment(MyEntity phantom, MyEntity target, int weapon = 0, bool mustBeInrange = false, bool checkTargetOrb = false) => _getTargetAssessment?.Invoke(phantom, target, weapon, mustBeInrange, checkTargetOrb);
38 |
39 | ///
40 | ///
41 | ///
42 | ///
43 | ///
44 | //internal void GetPhantomInfo(string phantomSubtypeId, ICollection> collection) => _getPhantomInfo?.Invoke(phantomSubtypeId, collection);
45 |
46 | ///
47 | /// Change the phantoms current fire state
48 | ///
49 | ///
50 | ///
51 | internal void SetTriggerState(MyEntity phantom, TriggerActions trigger) => _setTriggerState?.Invoke(phantom, (int)trigger);
52 |
53 | ///
54 | /// Add additional magazines
55 | ///
56 | ///
57 | ///
58 | ///
59 | internal void AddMagazines(MyEntity phantom, int weapon, long quanity) => _addMagazines?.Invoke(phantom, weapon, quanity);
60 | ///
61 | /// Set/switch ammo
62 | ///
63 | ///
64 | ///
65 | ///
66 | internal void SetAmmo(MyEntity phantom, int weapon, string ammoName) => _setAmmo?.Invoke(phantom, weapon, ammoName);
67 | ///
68 | /// Close phantoms, required for phantoms that do not auto close
69 | ///
70 | ///
71 | ///
72 | internal bool ClosePhantom(MyEntity phantom) => _closePhantom?.Invoke(phantom) ?? false;
73 |
74 | ///
75 | /// string: weapon subtypeId
76 | /// uint: max age, defaults to never die, you must issue close request! Max duration is 14400 ticks (4 minutes)
77 | /// bool: close when phantom runs out of ammo
78 | /// long: Number of ammo reloads phantom has per default, prior to you adding more, defaults to long.MaxValue
79 | /// string: name of the ammo you want the phantom to start with, if different than default
80 | /// TriggerActions: TriggerOff, TriggerOn, TriggerOnce
81 | /// float?: scales the model if defined in the WeaponDefinition for this subtypeId
82 | /// MyEntity: Parent's this phantom to another world entity.
83 | /// StringerBuilder: Assign a name to this phantom
84 | /// bool: Add this phantom to the world PrunningStructure
85 | /// bool: Enable shadows for the model.
86 | ///
87 | ///
88 | ///
89 | ///
90 | ///
91 | ///
92 | ///
93 | ///
94 | ///
95 | ///
96 | ///
97 | ///
98 | ///
99 |
100 | ///
101 | internal MyEntity SpawnPhantom(string phantomType, uint maxAge = 0, bool closeWhenOutOfAmmo = false, long defaultReloads = long.MaxValue, string ammoOverideName = null, TriggerActions trigger = TriggerActions.TriggerOff, float? modelScale = null, MyEntity parnet = null, bool addToPrunning = false, bool shadows = false, long identityId = 0, bool sync = false)
102 | => _spawnPhantom?.Invoke(phantomType, maxAge, closeWhenOutOfAmmo, defaultReloads, ammoOverideName, (int)trigger, modelScale, parnet, addToPrunning, shadows, identityId, sync) ?? null;
103 |
104 | ///
105 | /// Set/switch ammo
106 | /// focusId is a value between 0 and 1, can have two active focus targets.
107 | ///
108 | ///
109 | ///
110 | ///
111 | internal bool SetPhantomFocusTarget(MyEntity phantom, MyEntity target, int focusId) => _setPhantomFocusTarget?.Invoke(phantom, target, focusId) ?? false;
112 | }
113 | }
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Comms/Space.cs:
--------------------------------------------------------------------------------
1 | using VRageMath;
2 | using WeaponCore.Data.Scripts.CoreSystems.Comms;
3 |
4 | namespace WeaponCore.Data.Scripts.CoreSystems.Support
5 | {
6 | internal class SpaceTrees
7 | {
8 | internal MyDynamicAABBTreeD DividedSpace = new MyDynamicAABBTreeD(Vector3D.One * 10.0, 10.0);
9 | internal void RegisterSignal(RadioStation station, ref BoundingSphereD volume)
10 | {
11 | if (station.PruningProxyId != -1)
12 | return;
13 | BoundingBoxD result;
14 | BoundingBoxD.CreateFromSphere(ref volume, out result);
15 | station.PruningProxyId = DividedSpace.AddProxy(ref result, station, 0U);
16 | }
17 |
18 | internal void UnregisterSignal(RadioStation station)
19 | {
20 | if (station.PruningProxyId == -1)
21 | return;
22 | DividedSpace.RemoveProxy(station.PruningProxyId);
23 | station.PruningProxyId = -1;
24 | }
25 |
26 | internal void OnSignalMoved(RadioStation station, ref Vector3 velocity, ref BoundingSphereD volume)
27 | {
28 | if (station.PruningProxyId == -1)
29 | return;
30 | BoundingBoxD result;
31 | BoundingBoxD.CreateFromSphere(ref volume, out result);
32 | DividedSpace.MoveProxy(station.PruningProxyId, ref result, velocity);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Comms/Spectrum.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using VRage.Utils;
4 | using WeaponCore.Data.Scripts.CoreSystems.Support;
5 |
6 | namespace WeaponCore.Data.Scripts.CoreSystems.Comms
7 | {
8 | internal class Spectrum
9 | {
10 | internal Dictionary Channels = new Dictionary(MyStringHash.Comparer);
11 | internal Stack RadiosPool = new Stack(32);
12 | internal Stack RadioPool = new Stack(32);
13 | internal Stack RadioStationPool = new Stack(32);
14 | }
15 |
16 | internal class Frequency
17 | {
18 | public enum LicensedFor
19 | {
20 | BroadCasters,
21 | Relayers,
22 | Both,
23 | }
24 | internal readonly Dictionary> Nodes = new Dictionary>();
25 | internal readonly SpaceTrees Tree = new SpaceTrees();
26 | internal readonly LicensedFor Rights;
27 | internal readonly MyStringHash HashId;
28 | internal readonly LicensedFor[] Licenses;
29 | internal readonly string Id;
30 | internal bool Dirty;
31 |
32 | public Frequency(LicensedFor rights, MyStringHash hashId)
33 | {
34 | Rights = rights;
35 | HashId = hashId;
36 | Id = hashId.String;
37 | Licenses = new LicensedFor[Enum.GetNames(typeof(LicensedFor)).Length];
38 |
39 | for (int i = 0; i < Licenses.Length; i++)
40 | {
41 | var license = (LicensedFor) i;
42 | Licenses[i] = license;
43 | Nodes[license] = new List();
44 | }
45 | }
46 |
47 | public bool TryAddOrUpdateSource(RadioStation station)
48 | {
49 | switch (Rights)
50 | {
51 | case LicensedFor.Both:
52 | break;
53 | case LicensedFor.BroadCasters:
54 | break;
55 | case LicensedFor.Relayers:
56 | break;
57 | }
58 |
59 | return false;
60 | }
61 |
62 | public bool TryRemoveSource(RadioStation station)
63 | {
64 | switch (Rights)
65 | {
66 | case LicensedFor.Both:
67 | break;
68 | case LicensedFor.BroadCasters:
69 | break;
70 | case LicensedFor.Relayers:
71 | break;
72 | }
73 |
74 | return false;
75 | }
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Coreparts/Definitions/InteriorTurret.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Support;
2 | using static CoreSystems.Support.WeaponDefinition;
3 | using static CoreSystems.Support.WeaponDefinition.ModelAssignmentsDef;
4 | using static CoreSystems.Support.WeaponDefinition.HardPointDef;
5 | using static CoreSystems.Support.WeaponDefinition.HardPointDef.Prediction;
6 | using static CoreSystems.Support.WeaponDefinition.TargetingDef.BlockTypes;
7 | using static CoreSystems.Support.WeaponDefinition.TargetingDef.Threat;
8 | using static CoreSystems.Support.WeaponDefinition.HardPointDef.HardwareDef.HardwareType;
9 |
10 | namespace Scripts {
11 | partial class Parts {
12 | // Don't edit above this line
13 | WeaponDefinition LargeInteriorTurret => new WeaponDefinition
14 | {
15 | Assignments = new ModelAssignmentsDef
16 | {
17 | MountPoints = new[] {
18 | new MountPointDef {
19 | SubtypeId = "LargeInteriorTurret", // Block Subtypeid. Your Cubeblocks contain this information
20 | SpinPartId = "None", // For weapons with a spinning barrel such as Gatling Guns. Subpart_Boomsticks must be written as Boomsticks.
21 | MuzzlePartId = "InteriorTurretBase2", // The subpart where your muzzle empties are located. This is often the elevation subpart. Subpart_Boomsticks must be written as Boomsticks.
22 | AzimuthPartId = "InteriorTurretBase1", // Your Rotating Subpart, the bit that moves sideways.
23 | ElevationPartId = "InteriorTurretBase2",// Your Elevating Subpart, that bit that moves up.
24 | DurabilityMod = 0.5f, // GeneralDamageMultiplier, 0.25f = 25% damage taken.
25 | IconName = "" // Overlay for block inventory slots, like reactors, refineries, etc.
26 | },
27 |
28 | },
29 | Muzzles = new[] {
30 | "muzzle_projectile", // Where your Projectiles spawn. Use numbers not Letters. IE Muzzle_01 not Muzzle_A
31 | },
32 | Scope = "muzzle_projectile", // Where line of sight checks are performed from. Must be clear of block collision.
33 | },
34 | Targeting = new TargetingDef
35 | {
36 | Threats = new[] {
37 | Grids, Characters, Projectiles, Meteors, // Types of threat to engage: Grids, Projectiles, Characters, Meteors, Neutrals
38 | },
39 | SubSystems = new[] {
40 | Thrust, Utility, Offense, Power, Production, Any, // Subsystem targeting priority: Offense, Utility, Power, Production, Thrust, Jumping, Steering, Any
41 | },
42 | ClosestFirst = true, // Tries to pick closest targets first (blocks on grids, projectiles, etc...).
43 | TopTargets = 4, // Maximum number of targets to randomize between; 0 = unlimited.
44 | TopBlocks = 4, // Maximum number of blocks to randomize between; 0 = unlimited.
45 | StopTrackingSpeed = 500, // Do not track threats traveling faster than this speed; 0 = unlimited.
46 | },
47 | HardPoint = new HardPointDef
48 | {
49 | PartName = "Interior Turret", // Name of the weapon in terminal, should be unique for each weapon definition that shares a SubtypeId (i.e. multiweapons).
50 | DeviateShotAngle = 0.1f, // Projectile inaccuracy in degrees.
51 | AimingTolerance = 1f, // How many degrees off target a turret can fire at. 0 - 180 firing angle.
52 | AimLeadingPrediction = Accurate, // Level of turret aim prediction; Off, Basic, Accurate, Advanced
53 | DelayCeaseFire = 10, // Measured in game ticks (6 = 100ms, 60 = 1 second, etc..). Length of time the weapon continues firing after trigger is released.
54 | Ai = new AiDef
55 | {
56 | TrackTargets = true, // Whether this weapon tracks its own targets, or (for multiweapons) relies on the weapon with PrimaryTracking enabled for target designation. Turrets Need this set to True.
57 | TurretAttached = true, // Whether this weapon is a turret and should have the UI and API options for such. Turrets Need this set to True.
58 | TurretController = true, // Whether this weapon can physically control the turret's movement. Turrets Need this set to True.
59 | PrimaryTracking = true, // For multiweapons: whether this weapon should designate targets for other weapons on the platform without their own tracking.
60 | },
61 | HardWare = new HardwareDef
62 | {
63 | RotateRate = 0.04f, // Max traversal speed of azimuth subpart in radians per tick (0.1 is approximately 360 degrees per second).
64 | ElevateRate = 0.04f, // Max traversal speed of elevation subpart in radians per tick.
65 | MinAzimuth = -180,
66 | MaxAzimuth = 180,
67 | MinElevation = -76,
68 | MaxElevation = 90,
69 | InventorySize = 0.08f, // Inventory capacity in kL.
70 | IdlePower = 0.01f, // Constant base power draw in MW.
71 | Type = BlockWeapon, // What type of weapon this is; BlockWeapon, HandWeapon, Phantom
72 | },
73 | Loading = new LoadingDef
74 | {
75 | RateOfFire = 600, // Set this to 3600 for beam weapons. This is how fast your Gun fires.
76 | BarrelsPerShot = 1, // How many muzzles will fire a projectile per fire event.
77 | TrajectilesPerBarrel = 1, // Number of projectiles per muzzle per fire event.
78 | ReloadTime = 180, // Measured in game ticks (6 = 100ms, 60 = 1 seconds, etc..).
79 | MagsToLoad = 1, // Number of physical magazines to consume on reload.
80 | },
81 | Audio = new HardPointAudioDef
82 | {
83 | FiringSound = "WepTurretInteriorFire", // Audio for firing.
84 | FiringSoundPerShot = true, // Whether to replay the sound for each shot, or just loop over the entire track while firing.
85 | HardPointRotationSound = "WepTurretGatlingRotate", // Audio played when turret is moving.
86 | FireSoundEndDelay = 10, // How long the firing audio should keep playing after firing stops. Measured in game ticks(6 = 100ms, 60 = 1 seconds, etc..).
87 | FireSoundNoBurst = true, // Don't stop firing sound from looping when delaying after burst.
88 | },
89 | Graphics = new HardPointParticleDef
90 | {
91 | Effect1 = new ParticleDef
92 | {
93 | Name = "Muzzle_Flash", // SubtypeId of muzzle particle effect.
94 | Extras = new ParticleOptionDef
95 | {
96 | Loop = true, // Set this to the same as in the particle sbc!
97 | Restart = true, // Whether to end a looping effect instantly when firing stops.
98 | Scale = 3f, // Scale of effect.
99 | },
100 | },
101 | },
102 | },
103 | Ammos = new[] {
104 | InteriorAmmo,
105 | InteriorAmmoOld // Must list all primary, shrapnel, and pattern ammos.
106 | },
107 | };
108 |
109 | // Don't edit below this line.
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Coreparts/Definitions/MasterConfig.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Scripts
3 | {
4 | partial class Parts
5 | {
6 | internal Parts()
7 | {
8 | PartDefinitions(LargeGatlingTurret,
9 | SmallGatlingGun,
10 | SmallGatlingTurret,
11 | LargeMissileLauncher,
12 | LargeMissileTurret,
13 | SmallMissileLauncher,
14 | SmallRocketLauncherReload,
15 | SmallMissileTurret,
16 | LargeInteriorTurret,
17 | SmallBlockAutocannon,
18 | AutoCannonTurret,
19 | LargeBlockAssaultCannonTurret,
20 | SmallBlockAssaultCannon,
21 | SmallBlockAssaultCannonTurret,
22 | LargeBlockArtillery,
23 | LargeBlockArtilleryTurret,
24 | LargeBlockRailgun,
25 | SmallBlockRailgun,
26 | LargeSearchlight,
27 | SmallSearchlight,
28 | LargeGatlingTurretReskin,
29 | SmallGatlingTurretReskin
30 | );
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Coreparts/Definitions/RailgunAnimations.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using static CoreSystems.Support.WeaponDefinition;
3 | using static CoreSystems.Support.WeaponDefinition.AnimationDef;
4 | using static CoreSystems.Support.WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers;
5 | namespace Scripts
6 | { // Don't edit above this line
7 | partial class Parts
8 | {
9 | private AnimationDef LargeRailgunAnimation => new AnimationDef
10 | {
11 |
12 | EventParticles = new Dictionary
13 | {
14 | [PreFire] = new[]{ //This particle fires in the Prefire state, during the 2 second windup.
15 | //Valid options include Firing, Reloading, Overheated, Tracking, On, Off, BurstReload, OutOfAmmo, PreFire.
16 | new EventParticle
17 | {
18 | EmptyNames = Names("barrel_001"), //If you want an effect on your own dummy
19 | MuzzleNames = Names("barrel_001"), //If you want an effect on the muzzle
20 | StartDelay = 0, //ticks 60 = 1 second, delay until particle starts.
21 | LoopDelay = 0, //ticks 60 = 1 second
22 | ForceStop = false,
23 | Particle = new ParticleDef
24 | {
25 | Name = "Muzzle_Flash_RailgunLargeVaRe", //Particle subtypeID
26 | Color = Color(red: 25, green: 25, blue: 25, alpha: 1), //This is redundant as recolouring is no longer supported.
27 | Extras = new ParticleOptionDef //do your particle colours in your particle file instead.
28 | {
29 | Loop = true, //Should match your particle definition.
30 | Restart = false,
31 | MaxDistance = 1000, //meters
32 | MaxDuration = 0, //ticks 60 = 1 second
33 | Scale = 1, //How chunky the particle is.
34 | }
35 | }
36 | },
37 | },
38 | },
39 |
40 | };
41 |
42 | private AnimationDef SmallRailgunAnimation => new AnimationDef
43 | {
44 |
45 | EventParticles = new Dictionary
46 | {
47 | [PreFire] = new[]{ //This particle fires in the Prefire state, during the 2 second windup.
48 | //Valid options include Firing, Reloading, Overheated, Tracking, On, Off, BurstReload, OutOfAmmo, PreFire.
49 | new EventParticle
50 | {
51 | EmptyNames = Names("barrel_001"), //If you want an effect on your own dummy
52 | MuzzleNames = Names("barrel_001"), //If you want an effect on the muzzle
53 | StartDelay = 0, //ticks 60 = 1 second, delay until particle starts.
54 | LoopDelay = 0, //ticks 60 = 1 second
55 | ForceStop = false,
56 | Particle = new ParticleDef
57 | {
58 | Name = "Muzzle_Flash_RailgunSmallVaRe", //Particle subtypeID
59 | Color = Color(red: 25, green: 25, blue: 25, alpha: 1), //This is redundant as recolouring is no longer supported.
60 | Extras = new ParticleOptionDef //do your particle colours in your particle file instead.
61 | {
62 | Loop = true, //Should match your particle definition.
63 | Restart = false,
64 | MaxDistance = 1000, //meters
65 | MaxDuration = 0, //ticks 60 = 1 second
66 | Scale = 1, //How chunky the particle is.
67 | }
68 | }
69 | },
70 | },
71 | },
72 |
73 | };
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Coreparts/PartCompile.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using CoreSystems.Support;
3 | using VRageMath;
4 |
5 | namespace Scripts
6 | {
7 | partial class Parts
8 | {
9 | internal ContainerDefinition Container = new ContainerDefinition();
10 | internal void PartDefinitions(params WeaponDefinition[] defs)
11 | {
12 | Container.WeaponDefs = defs;
13 | }
14 |
15 | internal void ArmorDefinitions(params ArmorDefinition[] defs)
16 | {
17 | Container.ArmorDefs = defs;
18 | }
19 |
20 | internal void SupportDefinitions(params SupportDefinition[] defs)
21 | {
22 | Container.SupportDefs = defs;
23 | }
24 |
25 | internal void UpgradeDefinitions(params UpgradeDefinition[] defs)
26 | {
27 | Container.UpgradeDefs = defs;
28 | }
29 |
30 | internal static void GetBaseDefinitions(out ContainerDefinition baseDefs)
31 | {
32 | baseDefs = new Parts().Container;
33 | }
34 |
35 | internal static void SetModPath(ContainerDefinition baseDefs, string modContext)
36 | {
37 | if (baseDefs.WeaponDefs != null)
38 | for (int i = 0; i < baseDefs.WeaponDefs.Length; i++)
39 | baseDefs.WeaponDefs[i].ModPath = modContext;
40 |
41 | if (baseDefs.SupportDefs != null)
42 | for (int i = 0; i < baseDefs.SupportDefs.Length; i++)
43 | baseDefs.SupportDefs[i].ModPath = modContext;
44 |
45 | if (baseDefs.UpgradeDefs != null)
46 | for (int i = 0; i < baseDefs.UpgradeDefs.Length; i++)
47 | baseDefs.UpgradeDefs[i].ModPath = modContext;
48 | }
49 |
50 | internal WeaponDefinition.AmmoDef.Randomize Random(float start, float end)
51 | {
52 | return new WeaponDefinition.AmmoDef.Randomize { Start = start, End = end };
53 | }
54 |
55 | internal Vector4 Color(float red, float green, float blue, float alpha)
56 | {
57 | return new Vector4(red, green, blue, alpha);
58 | }
59 |
60 | internal Vector3D Vector(double x, double y, double z)
61 | {
62 | return new Vector3D(x, y, z);
63 | }
64 |
65 | internal WeaponDefinition.AnimationDef.RelMove.XYZ Transformation(double X, double Y, double Z)
66 | {
67 | return new WeaponDefinition.AnimationDef.RelMove.XYZ { x = X, y = Y, z = Z };
68 | }
69 |
70 | internal Dictionary Delays(uint FiringDelay = 0, uint ReloadingDelay = 0, uint OverheatedDelay = 0, uint TrackingDelay = 0, uint LockedDelay = 0, uint OnDelay = 0, uint OffDelay = 0, uint BurstReloadDelay = 0, uint OutOfAmmoDelay = 0, uint PreFireDelay = 0, uint StopFiringDelay = 0, uint StopTrackingDelay = 0, uint InitDelay = 0, uint HomingDelay = 0, uint TargetAlignedDelay = 0, uint WhileOnDelay = 0, uint TargetRanged100Delay = 0, uint TargetRanged75Delay = 0, uint TargetRanged50Delay = 0, uint TargetRanged25Delay = 0)
71 | {
72 | return new Dictionary
73 | {
74 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.Firing] = FiringDelay,
75 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.Reloading] = ReloadingDelay,
76 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.Overheated] = OverheatedDelay,
77 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.Tracking] = TrackingDelay,
78 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.TurnOn] = OnDelay,
79 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.TurnOff] = OffDelay,
80 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.BurstReload] = BurstReloadDelay,
81 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.NoMagsToLoad] = OutOfAmmoDelay,
82 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.PreFire] = PreFireDelay,
83 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.EmptyOnGameLoad] = 0,
84 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.StopFiring] = StopFiringDelay,
85 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.StopTracking] = StopTrackingDelay,
86 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.LockDelay] = LockedDelay,
87 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.Init] = InitDelay,
88 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.Homing] = HomingDelay,
89 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.TargetAligned] = TargetAlignedDelay,
90 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.WhileOn] = WhileOnDelay,
91 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.TargetRanged100] = TargetRanged100Delay,
92 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.TargetRanged75] = TargetRanged75Delay,
93 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.TargetRanged50] = TargetRanged50Delay,
94 | [WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers.TargetRanged25] = TargetRanged25Delay,
95 | };
96 | }
97 |
98 | internal WeaponDefinition.AnimationDef.PartEmissive Emissive(string EmissiveName, bool CycleEmissiveParts, bool LeavePreviousOn, Vector4[] Colors, float IntensityFrom, float IntensityTo, string[] EmissivePartNames)
99 | {
100 | return new WeaponDefinition.AnimationDef.PartEmissive
101 | {
102 | EmissiveName = EmissiveName,
103 | Colors = Colors,
104 | CycleEmissivesParts = CycleEmissiveParts,
105 | LeavePreviousOn = LeavePreviousOn,
106 | EmissivePartNames = EmissivePartNames,
107 | IntensityRange = new[]{ IntensityFrom, IntensityTo }
108 | };
109 | }
110 |
111 | internal WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers[] Events(params WeaponDefinition.AnimationDef.PartAnimationSetDef.EventTriggers[] events)
112 | {
113 | return events;
114 | }
115 |
116 | internal string[] Names(params string[] names)
117 | {
118 | return names;
119 | }
120 |
121 | internal string[] AmmoRounds(params string[] names)
122 | {
123 | return names;
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/AiValues.cs:
--------------------------------------------------------------------------------
1 | using ProtoBuf;
2 |
3 | namespace CoreSystems
4 | {
5 | [ProtoContract]
6 | public class AiDataValues
7 | {
8 | //[ProtoMember(1)] public uint Revision;
9 | //[ProtoMember(2)] public int Version = Session.VersionControl;
10 | [ProtoMember(3)] public long ActiveTerminal;
11 |
12 | public bool Sync(AiDataValues sync)
13 | {
14 | ActiveTerminal = sync.ActiveTerminal;
15 |
16 | return true;
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/ConstructValues.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Support;
2 | using ProtoBuf;
3 | using static CoreSystems.Support.Ai;
4 | namespace CoreSystems
5 | {
6 | [ProtoContract]
7 | public class ConstructDataValues
8 | {
9 | [ProtoMember(2)] public FocusData FocusData;
10 |
11 | public bool Sync(Constructs construct, ConstructDataValues sync, bool localCall = false)
12 | {
13 | FocusData.Sync(construct.RootAi, sync.FocusData, localCall);
14 | return true;
15 | }
16 | }
17 |
18 | [ProtoContract]
19 | public class FocusData
20 | {
21 | public enum LockModes
22 | {
23 | None,
24 | Locked,
25 | }
26 |
27 | [ProtoMember(1)] public uint Revision;
28 | [ProtoMember(2)] public long Target;
29 | [ProtoMember(4)] public bool HasFocus;
30 | [ProtoMember(5)] public float DistToNearestFocusSqr;
31 | [ProtoMember(6)] public LockModes Locked;
32 |
33 |
34 | public bool Sync(Ai ai, FocusData sync, bool localCall = false)
35 | {
36 | if (Session.I.IsServer || sync.Revision > Revision)
37 | {
38 | Revision = sync.Revision;
39 | HasFocus = sync.HasFocus;
40 | DistToNearestFocusSqr = sync.DistToNearestFocusSqr;
41 |
42 | Target = sync.Target;
43 | Locked = sync.Locked;
44 |
45 | if (ai == ai.Construct.RootAi && localCall)
46 | ai.Construct.UpdateLeafFoci();
47 |
48 | return true;
49 | }
50 | return false;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/Control/ProtoControl.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Platform;
2 | using CoreSystems.Support;
3 | using ProtoBuf;
4 | using System.ComponentModel;
5 | using static CoreSystems.Support.CoreComponent;
6 |
7 | namespace CoreSystems
8 | {
9 |
10 | [ProtoContract]
11 | public class ProtoControlRepo : ProtoRepo
12 | {
13 | [ProtoMember(1)] public ProtoControlComp Values;
14 |
15 | public void ResetToFreshLoadState(ControlSys.ControlComponent comp)
16 | {
17 | Values.State.TrackingReticle = false;
18 | var ws = Values.State.Control;
19 | ws.Heat = 0;
20 | ws.Overheated = false;
21 | Values.Other.Rotor1 = comp.Controller.AzimuthRotor?.EntityId ?? 0;
22 | Values.Other.Rotor2 = comp.Controller.ElevationRotor?.EntityId ?? 0;
23 | ResetCompBaseRevisions();
24 | }
25 |
26 | public void ResetCompBaseRevisions()
27 | {
28 | Values.Revision = 0;
29 | Values.State.Revision = 0;
30 | var p = Values.State.Control;
31 | }
32 | }
33 |
34 |
35 | [ProtoContract]
36 | public class ProtoControlComp
37 | {
38 | [ProtoMember(1)] public uint Revision;
39 | [ProtoMember(2)] public ProtoWeaponSettings Set;
40 | [ProtoMember(3)] public ProtoControlState State;
41 | [ProtoMember(4)] public ProtoControlOtherSettings Other;
42 |
43 | public bool Sync(ControlSys.ControlComponent comp, ProtoControlComp sync)
44 | {
45 | if (sync.Revision > Revision)
46 | {
47 |
48 | Revision = sync.Revision;
49 | Set.Sync(comp, sync.Set);
50 | State.Sync(comp, sync.State, ProtoControlState.Caller.CompData);
51 | Other.Sync(comp, sync.Other);
52 | return true;
53 | }
54 | return false;
55 | }
56 |
57 | public void UpdateCompPacketInfo(ControlSys.ControlComponent comp, bool clean = false)
58 | {
59 | ++Revision;
60 | ++State.Revision;
61 | Session.PacketInfo info;
62 | if (clean && Session.I.PrunedPacketsToClient.TryGetValue(comp.Data.Repo.Values.State, out info))
63 | {
64 | Session.I.PrunedPacketsToClient.Remove(comp.Data.Repo.Values.State);
65 | Session.I.PacketControlStatePool.Return((ControlStatePacket)info.Packet);
66 | }
67 | }
68 | }
69 |
70 |
71 | [ProtoContract]
72 | public class ProtoControlState
73 | {
74 | public enum Caller
75 | {
76 | Direct,
77 | CompData,
78 | }
79 |
80 | public enum ControlMode
81 | {
82 | None,
83 | Ui,
84 | Toolbar,
85 | Camera
86 | }
87 |
88 | [ProtoMember(1)] public uint Revision;
89 | [ProtoMember(2)] public ProtoControlPartState Control;
90 | [ProtoMember(3)] public bool TrackingReticle; //don't save
91 | [ProtoMember(4), DefaultValue(-1)] public long PlayerId = -1;
92 | [ProtoMember(5), DefaultValue(ControlMode.None)] public ControlMode Mode = ControlMode.None;
93 | [ProtoMember(6)] public Trigger Terminal;
94 |
95 | public bool Sync(CoreComponent comp, ProtoControlState sync, Caller caller)
96 | {
97 | if (sync.Revision > Revision || caller == Caller.CompData)
98 | {
99 | Revision = sync.Revision;
100 | TrackingReticle = sync.TrackingReticle;
101 | PlayerId = sync.PlayerId;
102 | Mode = sync.Mode;
103 | Terminal = sync.Terminal;
104 | comp.Platform.Control.PartState.Sync(sync.Control);
105 |
106 | return true;
107 | }
108 | return false;
109 | }
110 |
111 | public void TerminalActionSetter(ControlSys.ControlComponent comp, Trigger action, bool syncWeapons = false, bool updateWeapons = true)
112 | {
113 | Terminal = action;
114 |
115 | if (updateWeapons)
116 | {
117 | Control.Action = action;
118 | }
119 |
120 | if (syncWeapons)
121 | Session.I.SendState(comp);
122 | }
123 | }
124 |
125 | [ProtoContract]
126 | public class ProtoControlPartState
127 | {
128 | [ProtoMember(1)] public float Heat; // don't save
129 | [ProtoMember(2)] public bool Overheated; //don't save
130 | [ProtoMember(3), DefaultValue(Trigger.Off)] public Trigger Action = Trigger.Off; // save
131 |
132 | public void Sync(ProtoControlPartState sync)
133 | {
134 | Heat = sync.Heat;
135 | Overheated = sync.Overheated;
136 | Action = sync.Action;
137 | }
138 |
139 | public void WeaponMode(ControlSys.ControlComponent comp, Trigger action, bool resetTerminalAction = true, bool syncCompState = true)
140 | {
141 | if (resetTerminalAction)
142 | comp.Data.Repo.Values.State.Terminal = Trigger.Off;
143 |
144 | Action = action;
145 | if (Session.I.MpActive && Session.I.IsServer && syncCompState)
146 | Session.I.SendState(comp);
147 | }
148 |
149 | }
150 |
151 | [ProtoContract]
152 | public class ProtoControlOtherSettings
153 | {
154 | [ProtoMember(1)] public float GravityOffset;
155 | [ProtoMember(2)] public long Rotor1;
156 | [ProtoMember(3)] public long Rotor2;
157 |
158 |
159 | public void Sync(CoreComponent comp, ProtoControlOtherSettings sync)
160 | {
161 | GravityOffset = sync.GravityOffset;
162 | Rotor1 = sync.Rotor1;
163 | Rotor2 = sync.Rotor2;
164 | }
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Definitions/SerializedConfigs/Misc.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using CoreSystems.Platform;
3 | using CoreSystems.Support;
4 | using ProtoBuf;
5 |
6 | namespace CoreSystems
7 | {
8 | [ProtoInclude(1999, typeof(ProtoWeaponRepo))]
9 | [ProtoInclude(1998, typeof(ProtoUpgradeRepo))]
10 | [ProtoInclude(1997, typeof(ProtoSupportRepo))]
11 | [ProtoInclude(1996, typeof(ProtoControlRepo))]
12 | [ProtoContract]
13 | public class ProtoRepo
14 | {
15 | [ProtoMember(1)] public int Version = Session.VersionControl;
16 | }
17 |
18 | #region packet BaseData
19 | [ProtoContract]
20 | internal class DataReport
21 | {
22 | [ProtoMember(1)] internal Dictionary Session = new Dictionary();
23 | [ProtoMember(2)] internal Dictionary Ai = new Dictionary();
24 | [ProtoMember(3)] internal Dictionary Comp = new Dictionary();
25 | [ProtoMember(4)] internal Dictionary Platform = new Dictionary();
26 | [ProtoMember(5)] internal Dictionary Weapon = new Dictionary();
27 | }
28 |
29 | [ProtoContract]
30 | internal class InputStateData
31 | {
32 | [ProtoMember(1)] internal bool MouseButtonLeft;
33 | [ProtoMember(2)] internal bool MouseButtonMenu;
34 | [ProtoMember(3)] internal bool MouseButtonRight;
35 | [ProtoMember(4)] internal bool InMenu;
36 |
37 | internal InputStateData() { }
38 |
39 | internal InputStateData(InputStateData createFrom)
40 | {
41 | Sync(createFrom);
42 | }
43 |
44 | internal void Sync(InputStateData syncFrom)
45 | {
46 | MouseButtonLeft = syncFrom.MouseButtonLeft;
47 | MouseButtonMenu = syncFrom.MouseButtonMenu;
48 | MouseButtonRight = syncFrom.MouseButtonRight;
49 | InMenu = syncFrom.InMenu;
50 | }
51 | }
52 |
53 | [ProtoContract]
54 | internal class PlayerMouseData
55 | {
56 | [ProtoMember(1)] internal long PlayerId;
57 | [ProtoMember(2)] internal InputStateData MouseStateData;
58 | }
59 |
60 |
61 | [ProtoContract]
62 | public class WeaponRandomGenerator
63 | {
64 | [ProtoMember(4)] public int CurrentSeed;
65 | public XorShiftRandomStruct TurretRandom;
66 | public XorShiftRandomStruct AcquireRandom;
67 |
68 | public enum RandomType
69 | {
70 | Deviation,
71 | ReAcquire,
72 | Acquire,
73 | }
74 |
75 | public void Init(Weapon w)
76 | {
77 | if (Session.I.IsServer)
78 | CurrentSeed = int.MaxValue - w.UniquePartId;
79 | else
80 | Session.I.WeaponLookUp[w.PartState.Id] = w;
81 |
82 | TurretRandom = new XorShiftRandomStruct((ulong)CurrentSeed);
83 | AcquireRandom = new XorShiftRandomStruct((ulong)CurrentSeed);
84 | AcquireRandom.NextBoolean();
85 | }
86 |
87 | public void Sync(WeaponRandomGenerator syncFrom)
88 | {
89 | CurrentSeed = syncFrom.CurrentSeed;
90 | TurretRandom = new XorShiftRandomStruct((ulong)CurrentSeed);
91 | }
92 |
93 | internal void ReInitRandom()
94 | {
95 | CurrentSeed = TurretRandom.Range(1, int.MaxValue);
96 | TurretRandom = new XorShiftRandomStruct((ulong)CurrentSeed);
97 | AcquireRandom = new XorShiftRandomStruct((ulong)CurrentSeed);
98 | }
99 | }
100 |
101 | [ProtoContract]
102 | public class EwarValues
103 | {
104 | [ProtoMember(1)] public long FiringBlockId;
105 | [ProtoMember(2)] public long EwaredBlockId;
106 | [ProtoMember(3)] public int SystemId;
107 | [ProtoMember(4)] public int AmmoId;
108 | [ProtoMember(5)] public uint EndTick;
109 | }
110 | #endregion
111 | }
112 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Controls/Support/SupportActions.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Platform;
2 | using CoreSystems.Support;
3 | using Sandbox.ModAPI;
4 |
5 | namespace CoreSystems.Control
6 | {
7 | public static partial class CustomActions
8 | {
9 | #region Call Actions
10 | internal static void SupportActionToggleShow(IMyTerminalBlock blk)
11 | {
12 | var comp = blk?.Components?.Get() as SupportSys.SupportComponent;
13 | if (comp == null || comp.Platform.State != CorePlatform.PlatformState.Ready)
14 | return;
15 |
16 | var newBool = !comp.Data.Repo.Values.Set.Overrides.ArmorShowArea;
17 | var newValue = newBool ? 1 : 0;
18 |
19 | SupportSys.SupportComponent.RequestSetValue(comp, "ArmorShowArea", newValue, Session.I.PlayerId);
20 | }
21 |
22 | #endregion
23 |
24 | #region Writters
25 | #endregion
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Controls/Support/SupportUi.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Platform;
2 | using CoreSystems.Support;
3 | using Sandbox.ModAPI;
4 |
5 | namespace CoreSystems
6 | {
7 | internal static partial class BlockUi
8 | {
9 | internal static bool GetShowArea(IMyTerminalBlock block)
10 | {
11 | var comp = block?.Components?.Get() as SupportSys.SupportComponent;
12 | if (comp == null || comp.Platform.State != CorePlatform.PlatformState.Ready) return false;
13 | return comp.Data.Repo.Values.Set.Overrides.ArmorShowArea;
14 |
15 | }
16 |
17 | internal static void RequestSetShowArea(IMyTerminalBlock block, bool newValue)
18 | {
19 | var comp = block?.Components?.Get() as SupportSys.SupportComponent;
20 | if (comp == null || comp.Platform.State != CorePlatform.PlatformState.Ready) return;
21 |
22 | var value = newValue ? 1 : 0;
23 | SupportSys.SupportComponent.RequestSetValue(comp, "ArmorShowArea", value, Session.I.PlayerId);
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Controls/Upgrade/UpgradeActions.cs:
--------------------------------------------------------------------------------
1 | namespace CoreSystems.Control
2 | {
3 | public static partial class CustomActions
4 | {
5 | #region Call Actions
6 |
7 | #endregion
8 |
9 | #region Writters
10 | #endregion
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Controls/Upgrade/UpgradeUi.cs:
--------------------------------------------------------------------------------
1 | namespace CoreSystems
2 | {
3 | internal static partial class BlockUi
4 | {
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/EntityData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using CoreSystems.Platform;
3 | using CoreSystems.Support;
4 | using Sandbox.Game.EntityComponents;
5 | using Sandbox.ModAPI;
6 |
7 | namespace CoreSystems
8 | {
9 | public class CompData
10 | {
11 | public CoreComponent BaseComp;
12 | public ProtoRepo ProtoRepoBase;
13 |
14 | public void Init (CoreComponent comp)
15 | {
16 | BaseComp = comp;
17 | }
18 |
19 | public void StorageInit()
20 | {
21 | if (BaseComp.CoreEntity.Storage == null)
22 | {
23 | BaseComp.CoreEntity.Storage = new MyModStorageComponent { [Session.I.CompDataGuid] = "" };
24 | }
25 | }
26 |
27 | public void Save()
28 | {
29 | if (BaseComp.CoreEntity.Storage == null) return;
30 | if (ProtoRepoBase != null)
31 | {
32 | switch (BaseComp.Type)
33 | {
34 | case CoreComponent.CompType.Weapon:
35 | BaseComp.CoreEntity.Storage[Session.I.CompDataGuid] = Convert.ToBase64String(MyAPIGateway.Utilities.SerializeToBinary((ProtoWeaponRepo)ProtoRepoBase));
36 | break;
37 | case CoreComponent.CompType.Upgrade:
38 | BaseComp.CoreEntity.Storage[Session.I.CompDataGuid] = Convert.ToBase64String(MyAPIGateway.Utilities.SerializeToBinary((ProtoUpgradeRepo)ProtoRepoBase));
39 | break;
40 | case CoreComponent.CompType.Support:
41 | BaseComp.CoreEntity.Storage[Session.I.CompDataGuid] = Convert.ToBase64String(MyAPIGateway.Utilities.SerializeToBinary((ProtoSupportRepo)ProtoRepoBase));
42 | break;
43 | case CoreComponent.CompType.Control:
44 | BaseComp.CoreEntity.Storage[Session.I.CompDataGuid] = Convert.ToBase64String(MyAPIGateway.Utilities.SerializeToBinary((ProtoControlRepo)ProtoRepoBase));
45 | break;
46 | }
47 | }
48 | }
49 |
50 | public enum DataState
51 | {
52 | Load,
53 | Reset,
54 | }
55 |
56 | public void DataManager (DataState change)
57 | {
58 | switch (BaseComp.Type)
59 | {
60 | case CoreComponent.CompType.Upgrade:
61 | ((Upgrade.UpgradeComponent)BaseComp).Data.Change(change);
62 | break;
63 | case CoreComponent.CompType.Support:
64 | ((SupportSys.SupportComponent)BaseComp).Data.Change(change);
65 | break;
66 | case CoreComponent.CompType.Weapon:
67 | ((Weapon.WeaponComponent)BaseComp).Data.Change(change);
68 | break;
69 | case CoreComponent.CompType.Control:
70 | ((ControlSys.ControlComponent)BaseComp).Data.Change(change);
71 | break;
72 | }
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/EntityInit.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Platform;
2 | using Sandbox.Game;
3 | using Sandbox.ModAPI;
4 | using System.Collections.Generic;
5 | using VRage.Game;
6 | using static CoreSystems.CompData;
7 | namespace CoreSystems.Support
8 | {
9 | public partial class CoreComponent
10 | {
11 | private void PowerInit()
12 | {
13 | Cube.ResourceSink.SetRequiredInputFuncByType(GId, () => Cube.IsWorking ? SinkPower : 0);
14 | Cube.ResourceSink.SetMaxRequiredInputByType(GId, 0);
15 |
16 | Cube.ResourceSink.Update();
17 | }
18 |
19 | private void StorageSetup()
20 | {
21 | if (CoreEntity.Storage == null)
22 | BaseData.StorageInit();
23 |
24 | BaseData.DataManager(DataState.Load);
25 |
26 | if (Session.I.IsServer)
27 | BaseData.DataManager(DataState.Reset);
28 | }
29 |
30 | private void InventoryInit()
31 | {
32 | using (InventoryEntity.Pin())
33 | {
34 | if (InventoryInited || !InventoryEntity.HasInventory || InventoryEntity.MarkedForClose || (Platform.State != CorePlatform.PlatformState.Inited && Platform.State != CorePlatform.PlatformState.Incomplete) || CoreInventory == null)
35 | {
36 | Platform.PlatformCrash(this, false, true, $"InventoryInit failed: IsInitted:{InventoryInited} - NoInventory:{!InventoryEntity.HasInventory} - Marked:{InventoryEntity.MarkedForClose} - PlatformNotReady:{Platform.State != CorePlatform.PlatformState.Ready}({Platform.State}) - nullInventory:{CoreInventory == null}");
37 | return;
38 | }
39 |
40 | if (TypeSpecific == CompTypeSpecific.Rifle)
41 | {
42 | InventoryInited = true;
43 | return;
44 | }
45 | var constraintList = new List();
46 | var constraintNames = new List();
47 | if (Type == CompType.Weapon)
48 | {
49 | var collect = TypeSpecific != CompTypeSpecific.Phantom ? Platform.Weapons : Platform.Phantoms;
50 | for (int i = 0; i < collect.Count; i++)
51 | {
52 | var w = collect[i];
53 |
54 | if (w == null)
55 | {
56 | Log.Line("InventoryInit weapon null");
57 | continue;
58 | }
59 | for (int j = 0; j < w.System.AmmoTypes.Length; j++)
60 | {
61 | var ammo = w.System.AmmoTypes[j];
62 | if (ammo.AmmoDef.Const.MagazineDef != null)
63 | {
64 | constraintList.Add(ammo.AmmoDef.Const.MagazineDef.Id);
65 | if (ammo.AmmoDef.HardPointUsable && !constraintNames.Contains(ammo.AmmoDef.Const.MagazineDef.DisplayNameText))
66 | constraintNames.Add(ammo.AmmoDef.Const.MagazineDef.DisplayNameText);
67 | }
68 | }
69 | }
70 | }
71 |
72 | var constraintName = "Ammo:";
73 | constraintNames.Sort();
74 | foreach (var name in constraintNames)
75 | constraintName += "\n - " + name;
76 |
77 | if (InventoryEntity is IMyConveyorSorter || CoreInventory.Constraint == null)
78 | CoreInventory.Constraint = new MyInventoryConstraint(constraintName);
79 |
80 | CoreInventory.Constraint.m_useDefaultIcon = false;
81 | CoreInventory.Refresh();
82 | CoreInventory.Constraint.Clear();
83 |
84 | if (!string.IsNullOrEmpty(CustomIcon)) {
85 | var iconPath = Platform.Structure.ModPath + "\\Textures\\GUI\\Icons\\" + CustomIcon;
86 | CoreInventory.Constraint.Icon = iconPath;
87 | CoreInventory.Constraint.UpdateIcon();
88 | }
89 |
90 | foreach (var constraint in constraintList)
91 | CoreInventory.Constraint.Add(constraint);
92 |
93 | CoreInventory.Refresh();
94 |
95 | InventoryInited = true;
96 | }
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/EntityState.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Platform;
2 | using Sandbox.Game.Entities;
3 | using VRage.Game.Entity;
4 | using static CoreSystems.Support.WeaponDefinition.AnimationDef.PartAnimationSetDef;
5 |
6 | namespace CoreSystems.Support
7 | {
8 | public partial class CoreComponent
9 | {
10 | internal void HealthCheck()
11 | {
12 | if (Platform.State != CorePlatform.PlatformState.Ready || TopEntity.MarkedForClose)
13 | return;
14 |
15 | switch (Status)
16 | {
17 | case Start.Starting:
18 | Startup();
19 | break;
20 | case Start.ReInit:
21 |
22 | if (Type == CompType.Weapon)
23 | Platform.ResetParts();
24 |
25 | Ai.Construct.RootAi.Construct.DirtyWeaponGroups = true;
26 | Status = NeedsWorldReset ? Start.ReInit : Start.Started;
27 | NeedsWorldReset = false;
28 | break;
29 | }
30 |
31 | if (Session.I.HandlesInput)
32 | Session.I.LeadGroupsDirty = true;
33 | }
34 |
35 | private void Startup()
36 | {
37 | IsWorking = !IsBlock || Cube.IsWorking;
38 |
39 | if (IsBlock && FunctionalBlock.Enabled) {
40 | FunctionalBlock.Enabled = false;
41 | FunctionalBlock.Enabled = true;
42 | LastOnOffState = true;
43 | }
44 |
45 | Status = Start.ReInit;
46 | }
47 |
48 | internal void WakeupComp()
49 | {
50 | if (IsAsleep) {
51 | IsAsleep = false;
52 | Ai.AwakeComps += 1;
53 | Ai.SleepingComps -= 1;
54 | }
55 | }
56 |
57 |
58 | internal void SubpartClosed(MyEntity ent)
59 | {
60 | if (ent == null)
61 | {
62 | Log.Line($"SubpartClosed had null entity");
63 | return;
64 | }
65 |
66 | using (CoreEntity.Pin())
67 | {
68 | ent.OnClose -= SubpartClosed;
69 | if (!CoreEntity.MarkedForClose && Platform.State == CorePlatform.PlatformState.Ready)
70 | {
71 | if (Type == CompType.Weapon)
72 | Platform.ResetParts();
73 | Status = Start.Started;
74 |
75 | foreach (var w in Platform.Weapons)
76 | {
77 | w.Azimuth = 0;
78 | w.Elevation = 0;
79 | w.Elevation = 0;
80 |
81 | if (w.ActiveAmmoDef.AmmoDef.Const.MustCharge)
82 | w.ExitCharger = true;
83 |
84 | if (!FunctionalBlock.Enabled)
85 | w.EventTriggerStateChanged(EventTriggers.TurnOff, true);
86 | else if (w.AnimationsSet.ContainsKey(EventTriggers.TurnOn))
87 | Session.I.FutureEvents.Schedule(w.TurnOnAV, null, 100);
88 |
89 | if (w.ProtoWeaponAmmo.CurrentAmmo == 0)
90 | {
91 | w.EventTriggerStateChanged(EventTriggers.EmptyOnGameLoad, true);
92 | }
93 | }
94 | }
95 | }
96 | }
97 |
98 | internal void ForceClose(object o)
99 | {
100 | var subtypeId = o as string;
101 | if (TypeSpecific != CompTypeSpecific.Phantom) Log.Line($"closing: {subtypeId} - critical:{CloseCondition}");
102 | CloseCondition = true;
103 | MyEntities.SendCloseRequest(CoreEntity);
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/EntitySupport.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using CoreSystems.Platform;
3 | using Sandbox.Game.Entities;
4 | using Sandbox.ModAPI.Weapons;
5 | using VRage.Game.Entity;
6 | using VRageMath;
7 | using static CoreSystems.Support.Ai;
8 |
9 | namespace CoreSystems.Support
10 | {
11 | public partial class CoreComponent
12 | {
13 | internal MyEntity GetTopEntity()
14 | {
15 | var cube = CoreEntity as MyCubeBlock;
16 |
17 | if (cube != null)
18 | return cube.CubeGrid;
19 |
20 | var gun = CoreEntity as IMyAutomaticRifleGun;
21 | return gun != null ? ((Weapon.WeaponComponent)this).Rifle.Owner : CoreEntity;
22 | }
23 |
24 | internal void TerminalRefresh(bool update = true)
25 | {
26 | if (Platform.State != CorePlatform.PlatformState.Ready || Status != Start.Started)
27 | return;
28 |
29 | if (Ai?.LastTerminal == CoreEntity) {
30 |
31 | TerminalBlock.RefreshCustomInfo();
32 |
33 | if (update && InControlPanel)
34 | {
35 | Cube.UpdateTerminal();
36 | }
37 | }
38 | }
39 |
40 | internal bool ValidDummies()
41 | {
42 | var weaponComp = this as Weapon.WeaponComponent;
43 | if (weaponComp == null) return true;
44 |
45 | foreach (var w in Platform.Weapons)
46 | {
47 | for (int i = 0; i < w.Dummies.Length; i++)
48 | {
49 | if (w.Dummies[i].NullEntity)
50 | {
51 | var forceResetRequest = w.Dummies[i].Entity;
52 | return false;
53 | }
54 | }
55 | }
56 |
57 | return true;
58 | }
59 |
60 | internal void RemoveFromReInit()
61 | {
62 | InReInit = false;
63 | Session.I.CompsDelayedReInit.Remove(this);
64 | }
65 |
66 | internal void RemoveComp()
67 | {
68 |
69 | if (InReInit) {
70 | RemoveFromReInit();
71 | return;
72 | }
73 |
74 | if (Registered)
75 | RegisterEvents(false);
76 |
77 | if (Ai != null) {
78 |
79 | try
80 | {
81 | if (Type == CompType.Weapon)
82 | {
83 | var wComp = ((Weapon.WeaponComponent) this);
84 | Ai.OptimalDps -= wComp.PeakDps;
85 | Ai.EffectiveDps -= wComp.EffectiveDps;
86 | Ai.PerfectDps -= wComp.PerfectDps;
87 |
88 |
89 | if (TypeSpecific == CompTypeSpecific.Rifle)
90 | {
91 | Session.I.OnPlayerControl(CoreEntity, null);
92 | wComp.AmmoStorage();
93 | }
94 |
95 | Constructs.WeaponGroupsMarkDirty(Ai.TopEntityMap?.GroupMap);
96 | wComp.MasterOverrides = null;
97 | wComp.BombFuze?.Close();
98 | wComp.BombFuze = null;
99 | }
100 |
101 | PartCounter wCount;
102 | if (Ai.PartCounting.TryGetValue(SubTypeId, out wCount))
103 | {
104 | wCount.Current--;
105 |
106 | if (IsBlock)
107 | Constructs.BuildAiListAndCounters(Ai);
108 |
109 | if (wCount.Current == 0)
110 | {
111 | Ai.PartCounting.Remove(SubTypeId);
112 | Session.I.PartCountPool.Return(wCount);
113 | }
114 | }
115 | else if (Session.I.LocalVersion) Log.Line($"didnt find counter for: {SubTypeId} - MarkedForClose:{Ai.MarkedForClose} - AiAge:{Session.I.Tick - Ai.AiSpawnTick} - CubeMarked:{CoreEntity.MarkedForClose} - GridMarked:{TopEntity.MarkedForClose}");
116 |
117 | if (Ai.Data.Repo.ActiveTerminal == CoreEntity.EntityId)
118 | Ai.Data.Repo.ActiveTerminal = 0;
119 |
120 | if (Ai.CompBase.Remove(CoreEntity))
121 | {
122 | if (Platform.State == CorePlatform.PlatformState.Ready)
123 | {
124 |
125 | var collection = TypeSpecific != CompTypeSpecific.Phantom ? Platform.Weapons : Platform.Phantoms;
126 |
127 | for (int i = 0; i < collection.Count; i++)
128 | {
129 | var w = collection[i];
130 | w.StopShooting();
131 | w.TurretActive = false;
132 | if (!Session.I.IsClient) w.Target.Reset(Session.I.Tick, Target.States.AiLost);
133 |
134 | if (w.InCharger)
135 | w.ExitCharger = true;
136 | if (w.CriticalReaction && w.Comp.Slim.IsDestroyed)
137 | w.CriticalOnDestruction();
138 | }
139 | }
140 | Ai.CompChange(false, this);
141 | }
142 |
143 | if (Ai.CompBase.Count == 0 && TypeSpecific != CompTypeSpecific.Rifle)
144 | {
145 | if (Ai.TopEntity != null)
146 | {
147 | Ai ai;
148 | Session.I.EntityAIs.TryRemove(Ai.TopEntity, out ai);
149 | }
150 | else
151 | Log.Line($"Ai.TopEntity was Null - marked:{Ai.MarkedForClose} - closed:{Ai.Closed}");
152 | }
153 |
154 | if (Session.I.TerminalMon.Comp == this)
155 | Session.I.TerminalMon.Clean(true);
156 |
157 | Ai = null;
158 | MasterAi = null;
159 | }
160 | catch (Exception ex) { Log.Line($"Exception in RemoveComp Inner: {ex} - Name:{Platform?.Comp?.SubtypeName} - AiNull:{Ai == null} - CoreEntNull:{CoreEntity == null} - PlatformNull: {Platform == null} - AiTopNull:{Ai?.TopEntity == null} - TopEntityNull:{TopEntity == null}", null, true); }
161 |
162 | }
163 | else if (Platform.State != CorePlatform.PlatformState.Delay && TypeSpecific != CompTypeSpecific.Rifle) Log.Line($"CompRemove: Ai already null - PartState:{Platform.State} - Status:{Status} - LastRemoveFromScene:{Session.I.Tick - LastRemoveFromScene}");
164 |
165 | LastRemoveFromScene = Session.I.Tick;
166 | }
167 |
168 |
169 | internal void ReCalculateMaxTargetingRange(double maxRange)
170 | {
171 | var expandedMaxTrajectory2 = maxRange + Ai.TopEntity.PositionComp.LocalVolume.Radius;
172 | if (expandedMaxTrajectory2 > Ai.MaxTargetingRange)
173 | {
174 |
175 | Ai.MaxTargetingRange = MathHelperD.Min(expandedMaxTrajectory2, Session.I.Settings.Enforcement.MaxHudFocusDistance);
176 | Ai.MaxTargetingRangeSqr = Ai.MaxTargetingRange * Ai.MaxTargetingRange;
177 | }
178 | }
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/ModelSupport/PartInfo.cs:
--------------------------------------------------------------------------------
1 | using VRage.Game.Entity;
2 | using VRageMath;
3 |
4 | namespace CoreSystems.Support
5 | {
6 | class PartInfo
7 | {
8 | internal PartInfo(MyEntity entity, bool isCoreEntity, bool parentIsCoreEntity, PartTypes type)
9 | {
10 | Entity = entity;
11 | IsCoreEntity = isCoreEntity;
12 | ParentIsCoreEntity = parentIsCoreEntity;
13 | ParentNull = entity.Parent == null;
14 | Parent = entity.Parent;
15 | Type = type;
16 | }
17 |
18 | public enum PartTypes
19 | {
20 | Muzzle,
21 | Az,
22 | El,
23 | Spin,
24 | }
25 |
26 | internal readonly PartTypes Type;
27 | internal readonly bool ParentNull;
28 | internal readonly bool IsCoreEntity;
29 | internal readonly bool ParentIsCoreEntity;
30 | internal MyEntity Entity;
31 | internal MyEntity Parent;
32 | internal Matrix ToTransformation;
33 | internal Matrix FromTransformation;
34 | internal Matrix FullRotationStep;
35 | internal Matrix RevFullRotationStep;
36 | internal Matrix OriginalPosition;
37 | internal Vector3 PartLocalLocation;
38 | internal Vector3 RotationAxis;
39 |
40 | internal void Reset(MyEntity entity)
41 | {
42 | Entity = entity;
43 | Parent = entity.Parent;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/ModelSupport/RecursiveSubparts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using Sandbox.Game.Entities;
5 | using VRage.Game.Entity;
6 | using VRage.Game.ModAPI;
7 | using VRage.ModAPI;
8 | using VRageMath;
9 |
10 | namespace CoreSystems.Support
11 | {
12 | // Courtesy Equinox
13 | ///
14 | /// Maintains a list of all recursive subparts of the given entity. Respects changes to the model.
15 | ///
16 | internal class RecursiveSubparts : IEnumerable
17 | {
18 | private readonly List _subparts = new List();
19 | private readonly Dictionary _tmp1 = new Dictionary();
20 | private readonly Dictionary _tmp2 = new Dictionary();
21 | internal readonly Dictionary NameToEntity = new Dictionary();
22 | internal readonly Dictionary EntityToName = new Dictionary();
23 | internal readonly Dictionary VanillaSubparts = new Dictionary();
24 | internal readonly Dictionary NeedsWorld = new Dictionary();
25 |
26 | internal const string MissileVanillaBase = "MissileTurretBase1";
27 | internal const string MissileVanillaBarrels = "MissileTurretBarrels";
28 | internal const string GatVanillaBase = "GatlingTurretBase1";
29 | internal const string GatVanillaBarrels = "GatlingTurretBase2";
30 | internal const string NoneStr = "None";
31 |
32 |
33 | private IMyModel _trackedModel;
34 | internal MyEntity Entity;
35 |
36 | internal void Clean(MyEntity myEntity)
37 | {
38 | _subparts.Clear();
39 | _tmp1.Clear();
40 | NameToEntity.Clear();
41 | EntityToName.Clear();
42 | VanillaSubparts.Clear();
43 | NeedsWorld.Clear();
44 | _trackedModel = null;
45 | Entity = myEntity;
46 | }
47 |
48 | internal void CheckSubparts()
49 | {
50 | if (_trackedModel == Entity?.Model)
51 | return;
52 | _trackedModel = Entity?.Model;
53 | _subparts.Clear();
54 | NameToEntity.Clear();
55 | EntityToName.Clear();
56 | VanillaSubparts.Clear();
57 | NeedsWorld.Clear();
58 | if (Entity != null)
59 | {
60 | var head = -1;
61 | _tmp1.Clear();
62 | while (head < _subparts.Count)
63 | {
64 | var query = head == -1 ? Entity : _subparts[head];
65 | head++;
66 | if (query.Model == null)
67 | continue;
68 | _tmp1.Clear();
69 | ((IMyEntity)query).Model.GetDummies(_tmp1);
70 | foreach (var kv in _tmp1)
71 | {
72 | if (kv.Key.StartsWith("subpart_", StringComparison.Ordinal))
73 | {
74 | var name = kv.Key.Substring("subpart_".Length);
75 | MyEntitySubpart res;
76 | if (query.TryGetSubpart(name, out res))
77 | {
78 | _subparts.Add(res);
79 | NameToEntity[name] = res;
80 | EntityToName[res] = name;
81 | var sorter = Entity as MyConveyorSorter;
82 | if (sorter == null && (name.Equals(MissileVanillaBase) || name.Equals(MissileVanillaBarrels) || name.Equals(GatVanillaBase) || name.Equals(GatVanillaBarrels)))
83 | VanillaSubparts[res] = name;
84 | }
85 | }
86 | else NameToEntity[kv.Key] = Entity;
87 | }
88 | }
89 | NameToEntity[NoneStr] = Entity;
90 | EntityToName[Entity] = NoneStr;
91 | }
92 |
93 | foreach (var ent in EntityToName)
94 | {
95 | if (!string.IsNullOrWhiteSpace(ent.Value) && !ent.Value.Equals(NoneStr) && VanillaSubparts.ContainsKey(ent.Key.Parent) && !VanillaSubparts.ContainsKey(ent.Key))
96 | NeedsWorld[ent.Key] = ent.Value;
97 | }
98 | }
99 |
100 | internal bool FindFirstDummyByName(string name1, string name2, out MyEntity entity, out string matched)
101 | {
102 | entity = null;
103 | matched = string.Empty;
104 | var checkSecond = !string.IsNullOrEmpty(name2);
105 | foreach (var parts in NameToEntity) {
106 |
107 | ((IMyEntity)parts.Value)?.Model?.GetDummies(_tmp2);
108 |
109 | foreach (var pair in _tmp2) {
110 |
111 | var firstCheck = pair.Key == name1;
112 | var secondCheck = checkSecond && pair.Key == name2;
113 | if (firstCheck || secondCheck) {
114 |
115 | matched = firstCheck ? name1 : name2;
116 |
117 | entity = parts.Value;
118 | break;
119 | }
120 | }
121 | _tmp2.Clear();
122 |
123 | if (entity != null)
124 | break;
125 | }
126 |
127 | return entity != null && !string.IsNullOrEmpty(matched);
128 | }
129 |
130 | IEnumerator IEnumerable.GetEnumerator()
131 | {
132 | return GetEnumerator();
133 | }
134 |
135 | internal List.Enumerator GetEnumerator()
136 | {
137 | CheckSubparts();
138 | return _subparts.GetEnumerator();
139 | }
140 |
141 | IEnumerator IEnumerable.GetEnumerator()
142 | {
143 | return GetEnumerator();
144 | }
145 |
146 | ///
147 | /// Sets the emissive value of a specific emissive material on entity, and all recursive subparts.
148 | ///
149 | /// The name of the emissive material (ie. "Emissive0")
150 | /// Level of emissivity (0 is off, 1 is full brightness)
151 | /// Color to emit
152 | internal void SetEmissiveParts(string emissiveName, Color emissivePartColor, float emissivity)
153 | {
154 | Entity.SetEmissiveParts(emissiveName, emissivePartColor, emissivity);
155 | SetEmissivePartsForSubparts(emissiveName, emissivePartColor, emissivity);
156 | }
157 |
158 | ///
159 | /// Sets the emissive value of a specific emissive material on all recursive subparts.
160 | ///
161 | /// The name of the emissive material (ie. "Emissive0")
162 | /// Level of emissivity (0 is off, 1 is full brightness).
163 | /// Color to emit
164 | internal void SetEmissivePartsForSubparts(string emissiveName, Color emissivePartColor, float emissivity)
165 | {
166 | foreach (var k in this)
167 | k.SetEmissiveParts(emissiveName, emissivePartColor, emissivity);
168 | }
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Control/ControlData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using CoreSystems.Support;
3 | using Sandbox.ModAPI;
4 | using VRageMath;
5 |
6 | namespace CoreSystems.Platform
7 | {
8 | public partial class ControlSys
9 | {
10 | internal class ControlCompData : CompData
11 | {
12 | internal readonly ControlComponent Comp;
13 | internal ProtoControlRepo Repo;
14 |
15 | internal ControlCompData(ControlComponent comp)
16 | {
17 | Init(comp);
18 | Comp = comp;
19 | }
20 |
21 | internal void Load()
22 | {
23 | if (Comp.CoreEntity.Storage == null) return;
24 |
25 | ProtoControlRepo load = null;
26 | string rawData;
27 | bool validData = false;
28 | if (Comp.CoreEntity.Storage.TryGetValue(Session.I.CompDataGuid, out rawData))
29 | {
30 | try
31 | {
32 | var base64 = Convert.FromBase64String(rawData);
33 | load = MyAPIGateway.Utilities.SerializeFromBinary(base64);
34 | validData = load?.Values.Other != null;
35 | }
36 | catch (Exception e)
37 | {
38 | Log.Line("Invalid PartState Loaded, Re-init");
39 | }
40 | }
41 |
42 | if (validData && load.Version == Session.VersionControl)
43 | {
44 | Repo = load;
45 | var p = Comp.Platform.Control;
46 | p.PartState = Repo.Values.State.Control;
47 | }
48 | else
49 | {
50 | Repo = new ProtoControlRepo
51 | {
52 | Values = new ProtoControlComp
53 | {
54 | State = new ProtoControlState { Control = new ProtoControlPartState() },
55 | Set = new ProtoWeaponSettings(),
56 | Other = new ProtoControlOtherSettings(),
57 | },
58 | };
59 |
60 | var state = Repo.Values.State.Control = new ProtoControlPartState();
61 | var p = Comp.Platform.Control;
62 |
63 | if (p != null)
64 | {
65 | p.PartState = state;
66 | }
67 |
68 | Repo.Values.Set.Range = -1;
69 | }
70 | ProtoRepoBase = Repo;
71 | }
72 |
73 | internal void Change(DataState state)
74 | {
75 | switch (state)
76 | {
77 | case DataState.Load:
78 | Load();
79 | break;
80 | case DataState.Reset:
81 | Repo.ResetToFreshLoadState(Comp);
82 | break;
83 | }
84 | }
85 | }
86 | internal bool ValidFakeTargetInfo(long playerId, out Ai.FakeTarget.FakeWorldTargetInfo fakeTargetInfo, bool preferPainted = true)
87 | {
88 | fakeTargetInfo = null;
89 | Ai.FakeTargets fakeTargets;
90 | if (Session.I.PlayerDummyTargets.TryGetValue(playerId, out fakeTargets))
91 | {
92 | var validManual = Comp.Data.Repo.Values.Set.Overrides.Control == ProtoWeaponOverrides.ControlModes.Manual && Comp.Data.Repo.Values.State.TrackingReticle && fakeTargets.ManualTarget.FakeInfo.WorldPosition != Vector3D.Zero;
93 | var validPainter = !Session.I.Settings.Enforcement.ProhibitHUDPainter && Comp.Data.Repo.Values.Set.Overrides.Control == ProtoWeaponOverrides.ControlModes.Painter && fakeTargets.PaintedTarget.LocalPosition != Vector3D.Zero;
94 | var fakeTarget = validPainter && preferPainted ? fakeTargets.PaintedTarget : validManual ? fakeTargets.ManualTarget : null;
95 | if (fakeTarget == null)
96 | return false;
97 |
98 | fakeTargetInfo = fakeTarget.LastInfoTick != Session.I.Tick ? fakeTarget.GetFakeTargetInfo(Comp.Ai) : fakeTarget.FakeInfo;
99 | }
100 |
101 | return fakeTargetInfo != null;
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Control/ControlFields.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Support;
2 | using Sandbox.ModAPI;
3 | using VRage.Utils;
4 | using VRageMath;
5 |
6 | namespace CoreSystems.Platform
7 | {
8 | public partial class ControlSys : Part
9 | {
10 | internal readonly ControlComponent Comp;
11 | internal readonly ControlSystem System;
12 | internal readonly MyStringHash PartHash;
13 |
14 | internal IMyMotorStator BaseMap;
15 | internal IMyMotorStator OtherMap;
16 | internal Ai TopAi;
17 | internal ProtoControlPartState PartState;
18 | internal bool IsAimed;
19 |
20 | internal ControlSys(ControlSystem system, ControlComponent comp, int partId)
21 | {
22 | System = system;
23 | Comp = comp;
24 | Init(comp, system, partId);
25 | PartHash = Comp.Structure.PartHashes[partId];
26 | }
27 |
28 |
29 | internal void CleanControl()
30 | {
31 | if (TopAi != null)
32 | {
33 | if (TopAi?.RootComp?.PrimaryWeapon != null)
34 | TopAi.RootComp.PrimaryWeapon.RotorTurretTracking = false;
35 |
36 | if (TopAi?.RootComp?.Ai?.ControlComp != null)
37 | TopAi.RootComp.Ai.ControlComp = null;
38 |
39 | if (TopAi?.RootComp != null)
40 | TopAi.RootComp = null;
41 |
42 | TopAi = null;
43 | }
44 | }
45 |
46 | internal bool RefreshRootComp()
47 | {
48 | for (int i = 0; i < TopAi.WeaponComps.Count; i++)
49 | {
50 | var comp = TopAi.WeaponComps[i];
51 | if (comp.Ai.ControlComp != null)
52 | {
53 | var distSqr = Vector3.DistanceSquared(comp.Cube.PositionComp.LocalAABB.Center, comp.TopEntity.PositionComp.LocalAABB.Center);
54 | if (distSqr < comp.Ai.ClosestFixedWeaponCompSqr)
55 | {
56 | comp.Ai.ClosestFixedWeaponCompSqr = distSqr;
57 | comp.Ai.RootComp = comp;
58 | comp.UpdateControlInfo();
59 | }
60 | }
61 | }
62 | return TopAi.RootComp?.CoreEntity != null && !TopAi.RootComp.CoreEntity.MarkedForClose;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Control/ControlTracking.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Projectiles;
2 | using CoreSystems.Support;
3 | using Sandbox.Game.Entities;
4 | using VRage.Game;
5 | using VRage.Game.Entity;
6 | using VRageMath;
7 | namespace CoreSystems.Platform
8 | {
9 | public partial class ControlSys : Part
10 | {
11 | internal static bool TrajectoryEstimation(ControlSys control, out Vector3D targetDirection)
12 | {
13 | var topAi = control.TopAi;
14 | var weapon = topAi.RootComp.PrimaryWeapon;
15 | var cValues = control.Comp.Data.Repo.Values;
16 | Vector3D targetCenter;
17 | Vector3D targetVel = Vector3D.Zero;
18 | Vector3D targetAcc = Vector3D.Zero;
19 | var eTarget = weapon.Target.TargetObject as MyEntity;
20 | Ai.FakeTarget.FakeWorldTargetInfo fakeTargetInfo = null;
21 | var pTarget = weapon.Target.TargetObject as Projectile;
22 | if (cValues.Set.Overrides.Control != ProtoWeaponOverrides.ControlModes.Auto && control.ValidFakeTargetInfo(cValues.State.PlayerId, out fakeTargetInfo))
23 | {
24 | targetCenter = fakeTargetInfo.WorldPosition;
25 | targetVel = fakeTargetInfo.LinearVelocity;
26 | targetAcc = fakeTargetInfo.Acceleration;
27 | }
28 | else if (eTarget != null)
29 | {
30 | targetCenter = eTarget.PositionComp.WorldAABB.Center;
31 | var topEnt = eTarget.GetTopMostParent();
32 | var grid = topEnt as MyCubeGrid;
33 |
34 | if (grid != null) {
35 |
36 | var gridSize = grid.GridSizeEnum;
37 | var invalidType = !cValues.Set.Overrides.Grids || !cValues.Set.Overrides.SmallGrid && gridSize == MyCubeSize.Small || !cValues.Set.Overrides.LargeGrid && gridSize == MyCubeSize.Large;
38 |
39 | if (invalidType) {
40 | targetDirection = Vector3D.Zero;
41 | return false;
42 | }
43 | }
44 |
45 | if (topEnt != null) {
46 | targetVel = topEnt.Physics?.LinearVelocity ?? Vector3D.Zero;
47 | targetAcc = topEnt.Physics?.LinearAcceleration ?? Vector3D.Zero;
48 | }
49 | }
50 | else if (pTarget != null)
51 | {
52 | targetCenter = pTarget.Position;
53 | targetVel = pTarget.Velocity;
54 | targetAcc = pTarget.TravelMagnitude;
55 | }
56 | else
57 | {
58 | targetDirection = Vector3D.Zero;
59 | topAi.RotorTargetPosition = Vector3D.MaxValue;
60 | return false;
61 | }
62 |
63 | var shooterPos = weapon.GetScope.Info.Position;
64 | var maxRangeSqr = fakeTargetInfo != null && topAi.Construct.RootAi != null ? topAi.Construct.RootAi.MaxTargetingRangeSqr : cValues.Set.Range * cValues.Set.Range;
65 |
66 | bool valid;
67 | if (weapon.ActiveAmmoDef.AmmoDef.Const.IsBeamWeapon)
68 | {
69 | valid = true;
70 | topAi.RotorTargetPosition = targetCenter;
71 | }
72 | else
73 | topAi.RotorTargetPosition = Weapon.TrajectoryEstimation(weapon, targetCenter, targetVel, targetAcc, shooterPos, out valid, false, cValues.Set.Overrides.AngularTracking);
74 | targetDirection = Vector3D.Normalize(topAi.RotorTargetPosition - shooterPos);
75 | return valid && Vector3D.DistanceSquared(topAi.RotorTargetPosition, shooterPos) < maxRangeSqr;
76 | }
77 |
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/PartFields.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Support;
2 |
3 | namespace CoreSystems.Platform
4 | {
5 | public partial class Part
6 | {
7 | internal CoreComponent BaseComp;
8 | internal CoreSystem CoreSystem;
9 | internal PartAcquire Acquire;
10 | internal float MaxCharge;
11 | internal float DesiredPower;
12 | internal float AssignedPower;
13 | internal float EstimatedCharge;
14 | internal uint PartCreatedTick;
15 | internal uint PartReadyTick;
16 | internal int ShortLoadId;
17 | internal int UniquePartId;
18 | internal int PartId;
19 | internal bool IsPrime;
20 | internal bool Loading;
21 | internal bool ExitCharger;
22 | internal bool NewPowerNeeds;
23 | internal bool InCharger;
24 | internal bool Charging;
25 | internal bool StayCharged;
26 |
27 | internal void Init(CoreComponent comp, CoreSystem system, int partId)
28 | {
29 | CoreSystem = system;
30 | StayCharged = system.StayCharged;
31 | BaseComp = comp;
32 | PartCreatedTick = Session.I.Tick;
33 | PartId = partId;
34 | IsPrime = partId == comp.Platform.Structure.PrimaryPart;
35 | Acquire = new PartAcquire(this);
36 | UniquePartId = Session.I.UniquePartId;
37 | ShortLoadId = Session.I.ShortLoadAssigner();
38 | }
39 |
40 |
41 | internal class PartAcquire
42 | {
43 | internal readonly Part Part;
44 | internal uint CreatedTick;
45 | internal int SlotId;
46 | internal bool IsSleeping;
47 | internal bool Monitoring;
48 |
49 | internal PartAcquire(Part part)
50 | {
51 | Part = part;
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/PartState.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Support;
2 | using VRageMath;
3 |
4 | namespace CoreSystems.Platform
5 | {
6 | public partial class Part
7 | {
8 | internal void DrawPower(float assignedPower, Ai ai)
9 | {
10 | AssignedPower = MathHelper.Clamp(assignedPower, 0, DesiredPower);
11 | if (ai.ModOverride)
12 | return;
13 |
14 | BaseComp.SinkPower += AssignedPower;
15 | ai.GridAssignedPower += AssignedPower;
16 | Charging = true;
17 |
18 | if (BaseComp.CoreEntity.MarkedForClose)
19 | return;
20 | if (BaseComp.IsBlock)
21 | BaseComp.Cube.ResourceSink.Update();
22 | }
23 |
24 | internal void AdjustPower(float assignedPower, Ai ai)
25 | {
26 | if (ai.ModOverride) {
27 | AssignedPower = MathHelper.Clamp(assignedPower, 0, DesiredPower);
28 | return;
29 | }
30 |
31 | BaseComp.SinkPower -= AssignedPower;
32 | ai.GridAssignedPower -= AssignedPower;
33 |
34 | AssignedPower = MathHelper.Clamp(assignedPower, 0, DesiredPower);
35 |
36 | BaseComp.SinkPower += AssignedPower;
37 | ai.GridAssignedPower += AssignedPower;
38 |
39 | NewPowerNeeds = false;
40 |
41 | if (BaseComp.CoreEntity.MarkedForClose)
42 | return;
43 |
44 | if (BaseComp.IsBlock)
45 | BaseComp.Cube.ResourceSink.Update();
46 | }
47 |
48 | internal void StopPowerDraw(bool hardStop, Ai ai)
49 | {
50 | if (!Charging) {
51 | return;
52 | }
53 |
54 | BaseComp.SinkPower -= AssignedPower;
55 | ai.GridAssignedPower -= AssignedPower;
56 | AssignedPower = 0;
57 |
58 | if (BaseComp.SinkPower < BaseComp.IdlePower) BaseComp.SinkPower = BaseComp.IdlePower;
59 | Charging = false;
60 |
61 | if (BaseComp.CoreEntity.MarkedForClose)
62 | return;
63 |
64 | if (BaseComp.IsBlock)
65 | BaseComp.Cube.ResourceSink.Update();
66 | }
67 |
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Support/SupportAv.cs:
--------------------------------------------------------------------------------
1 | using Sandbox.Game.Entities;
2 |
3 | namespace CoreSystems.Platform
4 | {
5 | public partial class SupportSys
6 | {
7 | internal void ToggleAreaEffectDisplay()
8 | {
9 | var grid = BaseComp.Cube.CubeGrid;
10 | if (!ShowAffectedBlocks) {
11 |
12 | ShowAffectedBlocks = true;
13 | foreach (var slim in SuppotedBlocks)
14 | {
15 | if (!slim.IsDestroyed)
16 | {
17 | MyCube myCube;
18 | Comp.Cube.CubeGrid.TryGetCube(slim.Position, out myCube);
19 | BlockColorBackup.Add(slim, new BlockBackup { MyCube = myCube, OriginalColor = slim.ColorMaskHSV, OriginalSkin = slim.SkinSubtypeId });
20 | }
21 | }
22 |
23 | Session.I.DisplayAffectedArmor.Add(this);
24 | }
25 | else {
26 |
27 | foreach (var pair in BlockColorBackup)
28 | {
29 | if (!pair.Key.IsDestroyed)
30 | grid.ChangeColorAndSkin(pair.Value.MyCube.CubeBlock, pair.Value.OriginalColor, pair.Value.OriginalSkin);
31 | }
32 |
33 | BlockColorBackup.Clear();
34 | Session.I.DisplayAffectedArmor.Remove(this);
35 | ShowAffectedBlocks = false;
36 | }
37 | }
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Support/SupportCharge.cs:
--------------------------------------------------------------------------------
1 | namespace CoreSystems.Platform
2 | {
3 | public partial class SupportSys
4 | {
5 | internal void Charge()
6 | {
7 | if (_charges > 0 && !Info.Idle)
8 | Info.Update(_charges);
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Support/SupportData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using CoreSystems.Support;
3 | using Sandbox.ModAPI;
4 |
5 | namespace CoreSystems.Platform
6 | {
7 | public partial class SupportSys
8 | {
9 | internal class SupportCompData : CompData
10 | {
11 | internal readonly SupportComponent Comp;
12 | internal ProtoSupportRepo Repo;
13 |
14 | internal SupportCompData(SupportComponent comp)
15 | {
16 | Init(comp);
17 | Comp = comp;
18 | }
19 |
20 | internal void Load()
21 | {
22 | if (Comp.CoreEntity.Storage == null) return;
23 |
24 | ProtoSupportRepo load = null;
25 | string rawData;
26 | bool validData = false;
27 | if (Comp.CoreEntity.Storage.TryGetValue(Session.I.CompDataGuid, out rawData))
28 | {
29 | try
30 | {
31 | var base64 = Convert.FromBase64String(rawData);
32 | load = MyAPIGateway.Utilities.SerializeFromBinary(base64);
33 | validData = load != null;
34 | }
35 | catch (Exception e)
36 | {
37 | //Log.Line("Invalid PartState Loaded, Re-init");
38 | }
39 | }
40 |
41 | if (validData && load.Version == Session.VersionControl)
42 | {
43 | Log.Line("loading something");
44 | Repo = load;
45 |
46 | for (int i = 0; i < Comp.Platform.Support.Count; i++)
47 | {
48 | var p = Comp.Platform.Support[i];
49 |
50 | p.PartState = Repo.Values.State.Support[i];
51 | }
52 | }
53 | else
54 | {
55 | Log.Line("creating something");
56 | Repo = new ProtoSupportRepo
57 | {
58 | Values = new ProtoSupportComp
59 | {
60 | State = new ProtoSupportState { Support = new ProtoSupportPartState[Comp.Platform.Support.Count] },
61 | Set = new ProtoSupportSettings(),
62 | },
63 | };
64 |
65 | for (int i = 0; i < Comp.Platform.Support.Count; i++)
66 | {
67 | var state = Repo.Values.State.Support[i] = new ProtoSupportPartState();
68 | var p = Comp.Platform.Support[i];
69 |
70 | if (p != null)
71 | {
72 | p.PartState = state;
73 | }
74 | }
75 |
76 | Repo.Values.Set.Range = -1;
77 | }
78 | ProtoRepoBase = Repo;
79 | }
80 |
81 | internal void Change(DataState state)
82 | {
83 | switch (state)
84 | {
85 | case DataState.Load:
86 | Load();
87 | break;
88 | case DataState.Reset:
89 | Repo.ResetToFreshLoadState();
90 | break;
91 | }
92 | }
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Support/SupportFields.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Concurrent;
2 | using System.Collections.Generic;
3 | using CoreSystems.Support;
4 | using VRage.Game.ModAPI;
5 | using VRage.Utils;
6 | using VRageMath;
7 | namespace CoreSystems.Platform
8 | {
9 | public partial class SupportSys : Part
10 | {
11 |
12 | internal readonly HashSet SuppotedBlocks = new HashSet();
13 | internal readonly Dictionary BlockColorBackup = new Dictionary();
14 | internal readonly SupportInfo Info = new SupportInfo();
15 | internal readonly SupportComponent Comp;
16 | internal readonly SupportSystem System;
17 | internal readonly MyStringHash PartHash;
18 |
19 | private readonly HashSet _updatedBlocks = new HashSet();
20 | private readonly HashSet _newBlocks = new HashSet();
21 | private readonly HashSet _lostBlocks = new HashSet();
22 | private readonly HashSet _agedBlocks = new HashSet();
23 | private readonly ConcurrentDictionary _activeSupports;
24 | private int _charges;
25 |
26 |
27 | internal uint LastBlockRefreshTick;
28 | internal bool ShowAffectedBlocks;
29 | internal bool Active;
30 | internal Vector3I Min;
31 | internal Vector3I Max;
32 | internal BoundingBox Box = BoundingBox.CreateInvalid();
33 | internal ProtoSupportPartState PartState;
34 |
35 | internal SupportSys(SupportSystem system, SupportComponent comp, int partId)
36 | {
37 | System = system;
38 | Comp = comp;
39 |
40 | Init(comp, system, partId);
41 | PartHash = Comp.Structure.PartHashes[partId];
42 |
43 | _activeSupports = GetSupportCollection();
44 |
45 | if (!BaseComp.Ai.BlockMonitoring)
46 | BaseComp.Ai.DelayedEventRegistration(true);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Support/SupportMisc.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Concurrent;
2 | using VRage.Game.ModAPI;
3 | using static CoreSystems.Support.SupportDefinition.SupportEffect.Protections;
4 |
5 | namespace CoreSystems.Platform
6 | {
7 | public partial class SupportSys
8 | {
9 | private ConcurrentDictionary GetSupportCollection()
10 | {
11 | switch (System.Values.Effect.Protection)
12 | {
13 | case EnergeticProt:
14 | case KineticProt:
15 | case GenericProt:
16 | return Session.I.ProtSupports;
17 | case Regenerate:
18 | return Session.I.RegenSupports;
19 | case Structural:
20 | return Session.I.StructalSupports;
21 | }
22 | return null;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Support/SupportTypes.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Support;
2 | using Sandbox.Game.Entities;
3 | using VRage.Utils;
4 | using VRageMath;
5 | namespace CoreSystems.Platform
6 | {
7 | internal struct BlockBackup
8 | {
9 | internal MyCube MyCube;
10 | internal Vector3 OriginalColor;
11 | internal MyStringHash OriginalSkin;
12 | }
13 |
14 | internal class SupportInfo
15 | {
16 | internal readonly int[] RunningTotal = new int[60];
17 | internal int LastStep = 59;
18 | internal int TimeStep;
19 | internal int UsedThisSecond;
20 | internal int UsedLastMinute;
21 | internal int IdleTime;
22 |
23 | internal int MaxPoints;
24 | internal int PointsPerCharge;
25 | internal bool Idle;
26 | internal int CurrentPoints;
27 |
28 | internal void Update(int charges)
29 | {
30 | CurrentPoints = MathHelper.Clamp(CurrentPoints + (charges * PointsPerCharge), 0, MaxPoints);
31 | UsedLastMinute += UsedThisSecond;
32 |
33 | if (UsedThisSecond > 0 || CurrentPoints < MaxPoints)
34 | {
35 | IdleTime = 0;
36 | Idle = false;
37 | }
38 | else if (++IdleTime > 59)
39 | {
40 | Idle = true;
41 | }
42 |
43 | if (TimeStep > LastStep)
44 | {
45 | LastStep = TimeStep;
46 | UsedLastMinute -= RunningTotal[LastStep];
47 | }
48 |
49 | if (TimeStep < 59)
50 | {
51 | RunningTotal[TimeStep++] = UsedThisSecond;
52 | }
53 | else
54 | {
55 | TimeStep = 0;
56 | RunningTotal[TimeStep] = UsedThisSecond;
57 | }
58 | Log.Line($"used: {UsedLastMinute} - {UsedThisSecond}");
59 | UsedThisSecond = 0;
60 | }
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Upgrade/UpgradeComp.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using CoreSystems.Support;
3 | using VRage.Game;
4 | using VRage.Game.Entity;
5 |
6 | namespace CoreSystems.Platform
7 | {
8 | public partial class Upgrade
9 | {
10 | public class UpgradeComponent : CoreComponent
11 | {
12 | internal readonly UpgradeCompData Data;
13 | internal readonly UpgradeStructure Structure;
14 | internal UpgradeComponent(MyEntity coreEntity, MyDefinitionId id)
15 | {
16 | //Bellow order is important
17 | Data = new UpgradeCompData(this);
18 | Init(coreEntity, true, Data, id);
19 | Structure = (UpgradeStructure)Platform.Structure;
20 | }
21 |
22 | internal void DetectStateChanges()
23 | {
24 | if (Platform.State != CorePlatform.PlatformState.Ready)
25 | return;
26 |
27 | if (Session.I.Tick - Ai.LastDetectEvent > 59)
28 | {
29 | Ai.LastDetectEvent = Session.I.Tick;
30 | Ai.SleepingComps = 0;
31 | Ai.AwakeComps = 0;
32 | Ai.DetectOtherSignals = false;
33 | }
34 |
35 | UpdatedState = true;
36 |
37 |
38 | DetectOtherSignals = false;
39 | if (DetectOtherSignals)
40 | Ai.DetectOtherSignals = true;
41 |
42 | var wasAsleep = IsAsleep;
43 | IsAsleep = false;
44 | IsDisabled = false;
45 |
46 | if (!Session.I.IsServer)
47 | return;
48 |
49 | var otherRangeSqr = Ai.DetectionInfo.OtherRangeSqr;
50 | var priorityRangeSqr = Ai.DetectionInfo.PriorityRangeSqr;
51 | var somethingInRange = DetectOtherSignals ? otherRangeSqr <= MaxDetectDistanceSqr && otherRangeSqr >= MinDetectDistanceSqr || priorityRangeSqr <= MaxDetectDistanceSqr && priorityRangeSqr >= MinDetectDistanceSqr : priorityRangeSqr <= MaxDetectDistanceSqr && priorityRangeSqr >= MinDetectDistanceSqr;
52 |
53 | if (Session.I.Settings.Enforcement.ServerSleepSupport && !somethingInRange && PartTracking == 0 && Ai.Construct.RootAi.Construct.ControllingPlayers.Count <= 0 && Session.I.TerminalMon.Comp != this && Data.Repo.Values.State.Terminal == Trigger.Off)
54 | {
55 |
56 | IsAsleep = true;
57 | Ai.SleepingComps++;
58 | }
59 | else if (wasAsleep)
60 | {
61 |
62 | Ai.AwakeComps++;
63 | }
64 | else
65 | Ai.AwakeComps++;
66 | }
67 |
68 |
69 | internal static void RequestSetValue(UpgradeComponent comp, string setting, int value, long playerId)
70 | {
71 | if (Session.I.IsServer)
72 | {
73 | SetValue(comp, setting, value, playerId);
74 | }
75 | else if (Session.I.IsClient)
76 | {
77 | Session.I.SendOverRidesClientComp(comp, setting, value);
78 | }
79 | }
80 |
81 | internal static void SetValue(UpgradeComponent comp, string setting, int v, long playerId)
82 | {
83 | var o = comp.Data.Repo.Values.Set.Overrides;
84 | var enabled = v > 0;
85 | var clearTargets = false;
86 |
87 | switch (setting)
88 | {
89 | case "MaxSize":
90 | o.MaxSize = v;
91 | break;
92 | case "MinSize":
93 | o.MinSize = v;
94 | break;
95 | case "SubSystems":
96 | o.SubSystem = (WeaponDefinition.TargetingDef.BlockTypes)v;
97 | break;
98 | case "MovementModes":
99 | o.MoveMode = (ProtoUpgradeOverrides.MoveModes)v;
100 | clearTargets = true;
101 | break;
102 | case "ControlModes":
103 | o.Control = (ProtoUpgradeOverrides.ControlModes)v;
104 | clearTargets = true;
105 | break;
106 | case "FocusSubSystem":
107 | o.FocusSubSystem = enabled;
108 | break;
109 | case "FocusTargets":
110 | o.FocusTargets = enabled;
111 | clearTargets = true;
112 | break;
113 | case "Unowned":
114 | o.Unowned = enabled;
115 | break;
116 | case "Friendly":
117 | o.Friendly = enabled;
118 | clearTargets = true;
119 | break;
120 | case "Meteors":
121 | o.Meteors = enabled;
122 | break;
123 | case "Grids":
124 | o.Grids = enabled;
125 | break;
126 | case "ArmorShowArea":
127 | o.ArmorShowArea = enabled;
128 | break;
129 | case "Biologicals":
130 | o.Biologicals = enabled;
131 | break;
132 | case "Projectiles":
133 | o.Projectiles = enabled;
134 | clearTargets = true;
135 | break;
136 | case "Neutrals":
137 | o.Neutrals = enabled;
138 | clearTargets = true;
139 | break;
140 | }
141 |
142 | ResetCompState(comp, playerId, clearTargets);
143 |
144 | if (Session.I.MpActive)
145 | Session.I.SendComp(comp);
146 | }
147 |
148 | internal static void ResetCompState(UpgradeComponent comp, long playerId, bool resetTarget, Dictionary settings = null)
149 | {
150 | var o = comp.Data.Repo.Values.Set.Overrides;
151 | var userControl = o.Control != ProtoUpgradeOverrides.ControlModes.Auto;
152 |
153 | if (userControl)
154 | {
155 | comp.Data.Repo.Values.State.PlayerId = playerId;
156 | comp.Data.Repo.Values.State.Control = ProtoUpgradeState.ControlMode.Ui;
157 | if (settings != null) settings["ControlModes"] = (int)o.Control;
158 | comp.Data.Repo.Values.State.TerminalActionSetter(comp, Trigger.Off);
159 | }
160 | else
161 | {
162 | comp.Data.Repo.Values.State.PlayerId = -1;
163 | comp.Data.Repo.Values.State.Control = ProtoUpgradeState.ControlMode.None;
164 | }
165 |
166 | if (resetTarget)
167 | ClearParts(comp);
168 | }
169 |
170 | private static void ClearParts(UpgradeComponent comp)
171 | {
172 | for (int i = 0; i < comp.Platform.Upgrades.Count; i++)
173 | {
174 | var part = comp.Platform.Upgrades[i];
175 | }
176 | }
177 | }
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Upgrade/UpgradeData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Sandbox.ModAPI;
3 |
4 | namespace CoreSystems.Platform
5 | {
6 | public partial class Upgrade
7 | {
8 | internal class UpgradeCompData : CompData
9 | {
10 | internal readonly UpgradeComponent Comp;
11 | internal ProtoUpgradeRepo Repo;
12 |
13 | internal UpgradeCompData(UpgradeComponent comp)
14 | {
15 | Init(comp);
16 | Comp = comp;
17 | }
18 |
19 | internal void Load()
20 | {
21 | if (Comp.CoreEntity.Storage == null) return;
22 |
23 | ProtoUpgradeRepo load = null;
24 | string rawData;
25 | bool validData = false;
26 | if (Comp.CoreEntity.Storage.TryGetValue(Session.I.CompDataGuid, out rawData))
27 | {
28 | try
29 | {
30 | var base64 = Convert.FromBase64String(rawData);
31 | load = MyAPIGateway.Utilities.SerializeFromBinary(base64);
32 | validData = load != null;
33 | }
34 | catch (Exception e)
35 | {
36 | //Log.Line("Invalid PartState Loaded, Re-init");
37 | }
38 | }
39 |
40 | if (validData && load.Version == Session.VersionControl)
41 | {
42 | Repo = load;
43 |
44 | for (int i = 0; i < Comp.Platform.Upgrades.Count; i++)
45 | {
46 | var p = Comp.Platform.Upgrades[i];
47 |
48 | p.PartState = Repo.Values.State.Upgrades[i];
49 | }
50 | }
51 | else
52 | {
53 | Repo = new ProtoUpgradeRepo
54 | {
55 | Values = new ProtoUpgradeComp
56 | {
57 | State = new ProtoUpgradeState { Upgrades = new ProtoUpgradePartState[Comp.Platform.Support.Count] },
58 | Set = new ProtoUpgradeSettings(),
59 | },
60 | };
61 |
62 | for (int i = 0; i < Comp.Platform.Support.Count; i++)
63 | {
64 | var state = Repo.Values.State.Upgrades[i] = new ProtoUpgradePartState();
65 | var p = Comp.Platform.Upgrades[i];
66 |
67 | if (p != null)
68 | {
69 | p.PartState = state;
70 | }
71 | }
72 |
73 | Repo.Values.Set.Range = -1;
74 | }
75 | ProtoRepoBase = Repo;
76 | }
77 |
78 | internal void Change(DataState state)
79 | {
80 | switch (state)
81 | {
82 | case DataState.Load:
83 | Load();
84 | break;
85 | case DataState.Reset:
86 | Repo.ResetToFreshLoadState();
87 | break;
88 | }
89 | }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Upgrade/UpgradeFields.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Support;
2 |
3 | namespace CoreSystems.Platform
4 | {
5 | internal class Upgrades : Part
6 | {
7 | internal readonly Upgrade.UpgradeComponent Comp;
8 | internal ProtoUpgradePartState PartState;
9 | internal Upgrades(UpgradeSystem system, Upgrade.UpgradeComponent comp, int partId)
10 | {
11 | Comp = comp;
12 | Init(comp, system, partId);
13 |
14 | Log.Line($"init Upgrades: {system.PartName}");
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/EntityComp/Parts/Upgrade/UpgradeTypes.cs:
--------------------------------------------------------------------------------
1 | namespace CoreSystems.Platform
2 | {
3 | }
4 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Projectiles/Dtree.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using CoreSystems.Projectiles;
3 | using VRageMath;
4 |
5 | namespace CoreSystems.Support
6 | {
7 | internal class DynTrees
8 | {
9 | internal static void RegisterProjectile(Projectile projectile)
10 | {
11 | if (projectile.PruningProxyId != -1)
12 | return;
13 |
14 | var s = Session.I;
15 | BoundingSphereD sphere = new BoundingSphereD(projectile.Position, projectile.Info.AmmoDef.Const.LargestHitSize);
16 | BoundingBoxD result;
17 | BoundingBoxD.CreateFromSphere(ref sphere, out result);
18 | projectile.PruningProxyId = s.ProjectileTree.AddProxy(ref result, projectile, 0U);
19 | }
20 |
21 | internal static void UnregisterProjectile(Projectile projectile)
22 | {
23 | if (projectile.PruningProxyId == -1)
24 | return;
25 | var s = Session.I;
26 | s.ProjectileTree.RemoveProxy(projectile.PruningProxyId);
27 | projectile.PruningProxyId = -1;
28 | }
29 | internal static void GetAllProjectilesInSphere(Session session, ref BoundingSphereD sphere, List result, bool clearList = true)
30 | {
31 | session.ProjectileTree.OverlapAllBoundingSphere(ref sphere, result, clearList);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Session/SessionCharging.cs:
--------------------------------------------------------------------------------
1 | using CoreSystems.Platform;
2 | using CoreSystems.Support;
3 | using VRageMath;
4 |
5 | namespace CoreSystems
6 | {
7 | public partial class Session
8 | {
9 | private void UpdateChargeWeapons() //Fully Inlined due to keen's mod profiler
10 | {
11 | foreach (var charger in ChargingParts) {
12 |
13 | var ai = charger.Ai;
14 | var gridSum = (ai.GridAvailablePower + ai.GridAssignedPower);
15 | var gridAvail = gridSum < ai.GridMaxPower ? gridSum * 0.94f : ai.GridMaxPower * 0.9f;
16 | var availMinusDesired = gridAvail - charger.TotalDesired;
17 | var powerFree = availMinusDesired > 0 || ai.ModOverride;
18 | var rebalance = charger.Rebalance;
19 | charger.Rebalance = false;
20 |
21 | var group0Count = charger.ChargeGroup0.Count;
22 | var group1Count = charger.ChargeGroup1.Count;
23 | var group2Count = charger.ChargeGroup2.Count;
24 |
25 | var g0Power = gridAvail * charger.G0Power[charger.State];
26 | var g1Power = gridAvail * charger.G1Power[charger.State];
27 | var g2Power = gridAvail * charger.G2Power[charger.State];
28 |
29 | var g0Remaining = MathHelper.Clamp(g0Power - charger.GroupRequested0, 0, g0Power);
30 | var g1MixedPower = g0Remaining + g1Power >= gridAvail ? g0Remaining : g1Power + g0Remaining;
31 |
32 | var allRemaining = MathHelper.Clamp(gridAvail - (charger.GroupRequested0 + charger.GroupRequested1), 0, gridAvail);
33 | var g2MixedPower = MathHelper.Clamp(g2Power + allRemaining, 0, gridAvail);
34 |
35 | var group0Budget = group0Count > 0 ? g0Power / group0Count : float.MaxValue;
36 | var group1Budget = group1Count > 0 ? g1MixedPower / group1Count : float.MaxValue;
37 | var group2Budget = group2Count > 0 ? g2MixedPower / group2Count : float.MaxValue;
38 |
39 | for (int i = group0Count - 1; i >= 0; i--)
40 | {
41 | var part = charger.ChargeGroup0[i];
42 |
43 | var assignedPower = powerFree ? part.DesiredPower : group0Budget;
44 |
45 | switch (part.BaseComp.Type)
46 | {
47 | case CoreComponent.CompType.Upgrade:
48 | break;
49 | case CoreComponent.CompType.Support:
50 | break;
51 | case CoreComponent.CompType.Weapon:
52 | if (WeaponCharged(ai, (Weapon)part, assignedPower, rebalance))
53 | charger.Remove(part, i);
54 | break;
55 | }
56 | }
57 |
58 |
59 | for (int i = group1Count - 1; i >= 0; i--)
60 | {
61 | var part = charger.ChargeGroup1[i];
62 |
63 | var assignedPower = powerFree ? part.DesiredPower : group1Budget;
64 |
65 | switch (part.BaseComp.Type)
66 | {
67 | case CoreComponent.CompType.Upgrade:
68 | break;
69 | case CoreComponent.CompType.Support:
70 | break;
71 | case CoreComponent.CompType.Weapon:
72 | if (WeaponCharged(ai, (Weapon)part,assignedPower, rebalance))
73 | charger.Remove(part, i);
74 | break;
75 | }
76 | }
77 |
78 |
79 | for (int i = group2Count - 1; i >= 0; i--)
80 | {
81 | var part = charger.ChargeGroup2[i];
82 |
83 | var assignedPower = powerFree ? part.DesiredPower : group2Budget;
84 |
85 | switch (part.BaseComp.Type)
86 | {
87 | case CoreComponent.CompType.Upgrade:
88 | break;
89 | case CoreComponent.CompType.Support:
90 | break;
91 | case CoreComponent.CompType.Weapon:
92 | if (WeaponCharged(ai, (Weapon)part, assignedPower, rebalance))
93 | charger.Remove(part, i);
94 | break;
95 | }
96 |
97 | }
98 | }
99 | ChargingParts.ApplyRemovals();
100 | }
101 |
102 | private bool WeaponCharged(Ai ai, Weapon w, float assignedPower, bool rebalance = false)
103 | {
104 | var comp = w.Comp;
105 |
106 | if (!w.Charging)
107 | w.DrawPower(assignedPower, ai);
108 | else if (w.NewPowerNeeds || rebalance)
109 | w.AdjustPower(assignedPower, ai);
110 |
111 | w.ProtoWeaponAmmo.CurrentCharge = MathHelper.Clamp(w.ProtoWeaponAmmo.CurrentCharge + w.AssignedPower, 0, w.MaxCharge);
112 |
113 | if (!w.ActiveAmmoDef.AmmoDef.Const.Reloadable && w.IsShooting)
114 | return false;
115 |
116 | var allCharged = w.ProtoWeaponAmmo.CurrentCharge >= w.MaxCharge;
117 | var clientAllDone = IsClient && w.Reload.EndId > w.ClientEndId;
118 | var complete = allCharged || clientAllDone;
119 | var weaponFailure = !ai.HasPower || !comp.IsWorking;
120 | var invalidStates = ai != comp.Ai || comp.Ai.MarkedForClose || comp.Ai.TopEntity.MarkedForClose || comp.Ai.Concealed || comp.CoreEntity.MarkedForClose || comp.Platform.State != CorePlatform.PlatformState.Ready;
121 |
122 | var failed = weaponFailure || invalidStates;
123 | if (complete || failed)
124 | {
125 | var serverFullyLoaded = IsServer && w.ProtoWeaponAmmo.CurrentAmmo == w.Reload.MagsLoaded * w.ActiveAmmoDef.AmmoDef.Const.MagazineSize;
126 |
127 | var clientCharged = IsClient && allCharged && w.ActiveAmmoDef.AmmoDef.HybridRound;
128 |
129 | if (complete && (IsServer && !serverFullyLoaded || IsClient) && w.Loading)
130 | w.Reloaded(IsClient && clientAllDone ? 2 : IsClient && !clientCharged ? 4 : 0);
131 |
132 | w.StopPowerDraw(failed, ai);
133 | return !failed;
134 | }
135 |
136 | if (Tick60) {
137 |
138 | if (w.EstimatedCharge + w.AssignedPower < w.MaxCharge)
139 | w.EstimatedCharge += w.AssignedPower;
140 | else
141 | w.EstimatedCharge = w.MaxCharge;
142 | }
143 | return false;
144 | }
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/Data/Scripts/CoreSystems/Session/SessionFutureEvents.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace CoreSystems.Support
5 | {
6 | internal class FutureEvents
7 | {
8 | internal struct FutureAction
9 | {
10 | internal Action