Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace DuckGame
  5. {
  6. // Token: 0x0200002E RID: 46
  7. public abstract class Gun : Holdable
  8. {
  9. // Token: 0x0600031D RID: 797 RVA: 0x00003411 File Offset: 0x00001611
  10. public bool CanSpawnInfinite()
  11. {
  12. return true;
  13. }
  14.  
  15. // Token: 0x17000119 RID: 281
  16. // (get) Token: 0x0600031E RID: 798 RVA: 0x00005533 File Offset: 0x00003733
  17. public AmmoType ammoType
  18. {
  19. get
  20. {
  21. return this._ammoType;
  22. }
  23. }
  24.  
  25. // Token: 0x1700011A RID: 282
  26. // (get) Token: 0x0600031F RID: 799 RVA: 0x0000553B File Offset: 0x0000373B
  27. // (set) Token: 0x06000320 RID: 800 RVA: 0x00005544 File Offset: 0x00003744
  28. public sbyte netAmmo
  29. {
  30. get
  31. {
  32. return (sbyte)this.ammo;
  33. }
  34. set
  35. {
  36. this.ammo = (int)value;
  37. }
  38. }
  39.  
  40. // Token: 0x1700011B RID: 283
  41. // (get) Token: 0x06000321 RID: 801 RVA: 0x0000554D File Offset: 0x0000374D
  42. public bool lowerOnFire
  43. {
  44. get
  45. {
  46. return this._lowerOnFire;
  47. }
  48. }
  49.  
  50. // Token: 0x1700011C RID: 284
  51. // (get) Token: 0x06000322 RID: 802 RVA: 0x00005555 File Offset: 0x00003755
  52. public string bio
  53. {
  54. get
  55. {
  56. return this._bio;
  57. }
  58. }
  59.  
  60. // Token: 0x1700011D RID: 285
  61. // (get) Token: 0x06000323 RID: 803 RVA: 0x0000555D File Offset: 0x0000375D
  62. public Vec2 barrelPosition
  63. {
  64. get
  65. {
  66. return this.Offset(this.barrelOffset);
  67. }
  68. }
  69.  
  70. // Token: 0x1700011E RID: 286
  71. // (get) Token: 0x06000324 RID: 804 RVA: 0x0000556B File Offset: 0x0000376B
  72. public Vec2 barrelOffset
  73. {
  74. get
  75. {
  76. return this._barrelOffsetTL - this.center + this._extraOffset;
  77. }
  78. }
  79.  
  80. // Token: 0x1700011F RID: 287
  81. // (get) Token: 0x06000325 RID: 805 RVA: 0x00005589 File Offset: 0x00003789
  82. public Vec2 laserOffset
  83. {
  84. get
  85. {
  86. return this._laserOffsetTL - this.center;
  87. }
  88. }
  89.  
  90. // Token: 0x17000120 RID: 288
  91. // (get) Token: 0x06000326 RID: 806 RVA: 0x0000559C File Offset: 0x0000379C
  92. public Vec2 barrelVector
  93. {
  94. get
  95. {
  96. return this.Offset(this.barrelOffset) - this.Offset(this.barrelOffset + new Vec2(-1f, 0f));
  97. }
  98. }
  99.  
  100. // Token: 0x17000121 RID: 289
  101. // (get) Token: 0x06000327 RID: 807 RVA: 0x000055CF File Offset: 0x000037CF
  102. // (set) Token: 0x06000328 RID: 808 RVA: 0x00003255 File Offset: 0x00001455
  103. public override float angle
  104. {
  105. get
  106. {
  107. return this._angle + this._accuracyWave * (this._accuracyLost * 0.5f);
  108. }
  109. set
  110. {
  111. this._angle = value;
  112. }
  113. }
  114.  
  115. // Token: 0x17000122 RID: 290
  116. // (get) Token: 0x06000329 RID: 809 RVA: 0x000055F0 File Offset: 0x000037F0
  117. public float barrelAngleOffset
  118. {
  119. get
  120. {
  121. return this._barrelAngleOffset;
  122. }
  123. }
  124.  
  125. // Token: 0x17000123 RID: 291
  126. // (get) Token: 0x0600032A RID: 810 RVA: 0x000055F8 File Offset: 0x000037F8
  127. public float barrelAngle
  128. {
  129. get
  130. {
  131. return Maths.DegToRad(Maths.PointDirection(Vec2.Zero, this.barrelVector) + this._barrelAngleOffset * (float)this.offDir);
  132. }
  133. }
  134.  
  135. // Token: 0x0600032B RID: 811 RVA: 0x0000561E File Offset: 0x0000381E
  136. public bool CanSpin()
  137. {
  138. return this.weight <= 5f;
  139. }
  140.  
  141. // Token: 0x0600032C RID: 812 RVA: 0x00005630 File Offset: 0x00003830
  142. public override void EditorPropertyChanged(object property)
  143. {
  144. this.infiniteAmmoVal = this.infinite.value;
  145. this.UpdateMaterial();
  146. }
  147.  
  148. // Token: 0x0600032D RID: 813 RVA: 0x00003424 File Offset: 0x00001624
  149. public virtual void OnNetworkBulletsFired(Vec2 pos)
  150. {
  151. }
  152.  
  153. // Token: 0x0600032E RID: 814 RVA: 0x0002A134 File Offset: 0x00028334
  154. public void UpdateMaterial()
  155. {
  156. if (this.infinite.value)
  157. {
  158. this.infiniteAmmoVal = true;
  159. }
  160. if (this.infiniteAmmoVal)
  161. {
  162. if (base.material == null)
  163. {
  164. base.material = new MaterialGold(this);
  165. return;
  166. }
  167. }
  168. else
  169. {
  170. if (base.material == null && this.heat > 0.1f && this.physicsMaterial == PhysicsMaterial.Metal)
  171. {
  172. base.material = new MaterialRedHot(this);
  173. return;
  174. }
  175. if (base.material is MaterialRedHot)
  176. {
  177. if (this.heat < 0.1f)
  178. {
  179. base.material = null;
  180. return;
  181. }
  182. (base.material as MaterialRedHot).intensity = Math.Min(this.heat - 0.1f, 1f);
  183. }
  184. }
  185. }
  186.  
  187. // Token: 0x17000124 RID: 292
  188. // (get) Token: 0x0600032F RID: 815 RVA: 0x00005649 File Offset: 0x00003849
  189. public bool fullAuto
  190. {
  191. get
  192. {
  193. return this._fullAuto;
  194. }
  195. }
  196.  
  197. // Token: 0x06000330 RID: 816 RVA: 0x0002A1E8 File Offset: 0x000283E8
  198. public Gun(float xval, float yval) : base(xval, yval)
  199. {
  200. this._flare = new SpriteMap("smallFlare", 11, 10, false);
  201. this._flare.center = new Vec2(0f, 5f);
  202. this._barrelSmoke = new SpriteMap("barrelSmoke", 8, 8, false);
  203. this._barrelSmoke.center = new Vec2(1f, 8f);
  204. this._barrelSmoke.ClearAnimations();
  205. this._barrelSmoke.AddAnimation("puff", 1f, false, new int[]
  206. {
  207. 0,
  208. 1,
  209. 2
  210. });
  211. this._barrelSmoke.AddAnimation("loop", 1f, true, new int[]
  212. {
  213. 3,
  214. 4,
  215. 5,
  216. 6,
  217. 7,
  218. 8
  219. });
  220. this._barrelSmoke.AddAnimation("finish", 1f, false, new int[]
  221. {
  222. 9,
  223. 10,
  224. 11,
  225. 12
  226. });
  227. this._barrelSmoke.SetAnimation("puff");
  228. this._barrelSmoke.speed = 0f;
  229. this._translucent = true;
  230. this.physicsMaterial = PhysicsMaterial.Metal;
  231. this._dontCrush = true;
  232. this._clickPuff = new SpriteMap("clickPuff", 16, 16, false);
  233. this._clickPuff.AddAnimation("puff", 0.3f, false, new int[]
  234. {
  235. 0,
  236. 1,
  237. 2,
  238. 3
  239. });
  240. this._clickPuff.center = new Vec2(0f, 12f);
  241. this._sightHit = new Sprite("laserSightHit", 0f, 0f);
  242. this._sightHit.CenterOrigin();
  243. base.depth = -0.1f;
  244. this.infinite = new EditorProperty<bool>(false, this, 0f, 1f, 0.1f, null, false, false);
  245. base.collideSounds.Add("smallMetalCollide");
  246. base.impactVolume = 0.3f;
  247. }
  248.  
  249. // Token: 0x06000331 RID: 817 RVA: 0x0002A4B4 File Offset: 0x000286B4
  250. public void DoAmmoClick()
  251. {
  252. this._doPuff = true;
  253. this._clickPuff.frame = 0;
  254. this._clickPuff.SetAnimation("puff");
  255. this._barrelHeat = 0f;
  256. this._barrelSmoke.SetAnimation("finish");
  257. SFX.Play(this._clickSound, 1f, 0f, 0f, false);
  258. for (int i = 0; i < 2; i++)
  259. {
  260. SmallSmoke smallSmoke = SmallSmoke.New(this.barrelPosition.x, this.barrelPosition.y);
  261. smallSmoke.scale = new Vec2(0.3f, 0.3f);
  262. smallSmoke.hSpeed = Rando.Float(-0.1f, 0.1f);
  263. smallSmoke.vSpeed = -Rando.Float(0.05f, 0.2f);
  264. smallSmoke.alpha = 0.6f;
  265. Level.Add(smallSmoke);
  266. }
  267. }
  268.  
  269. // Token: 0x06000332 RID: 818 RVA: 0x0002A594 File Offset: 0x00028794
  270. public override void HeatUp(Vec2 location)
  271. {
  272. if (this._ammoType != null && this._ammoType.combustable && this.ammo > 0 && this.heat > 1f && Rando.Float(1f) > 0.8f)
  273. {
  274. this.heat -= 0.05f;
  275. this.PressAction();
  276. if (Rando.Float(1f) > 0.4f)
  277. {
  278. SFX.Play("bulletPop", Rando.Float(0.5f, 1f), Rando.Float(-1f, 1f), 0f, false);
  279. }
  280. }
  281. }
  282.  
  283. // Token: 0x06000333 RID: 819 RVA: 0x00005651 File Offset: 0x00003851
  284. public override void DoUpdate()
  285. {
  286. if (this.laserSight && this._laserTex == null)
  287. {
  288. this._additiveMaterial = new Material("Shaders/basicAdd");
  289. this._laserTex = Content.Load<Tex2D>("pointerLaser");
  290. }
  291. base.DoUpdate();
  292. }
  293.  
  294. // Token: 0x06000334 RID: 820 RVA: 0x0002A638 File Offset: 0x00028838
  295. public override void Update()
  296. {
  297. if (this.infiniteAmmoVal)
  298. {
  299. this.ammo = 99;
  300. }
  301. if (TeamSelect2.Enabled("INFAMMO", false))
  302. {
  303. this.infinite.value = true;
  304. this.infiniteAmmoVal = true;
  305. }
  306. this.UpdateMaterial();
  307. base.Update();
  308. if (this._clickPuff.finished)
  309. {
  310. this._doPuff = false;
  311. }
  312. this._accuracyLost = Maths.CountDown(this._accuracyLost, 0.015f, 0f);
  313. if (this._flareAlpha > 0f)
  314. {
  315. this._flareAlpha -= 0.5f;
  316. }
  317. else
  318. {
  319. this._flareAlpha = 0f;
  320. }
  321. if (this._barrelHeat > 0f)
  322. {
  323. this._barrelHeat -= 0.01f;
  324. }
  325. else
  326. {
  327. this._barrelHeat = 0f;
  328. }
  329. if (this._barrelHeat > 10f)
  330. {
  331. this._barrelHeat = 10f;
  332. }
  333. if (this._smokeWait > 0f)
  334. {
  335. this._smokeWait -= 0.1f;
  336. }
  337. else
  338. {
  339. if (this._barrelHeat > 0.1f && this._barrelSmoke.speed == 0f)
  340. {
  341. this._barrelSmoke.SetAnimation("puff");
  342. this._barrelSmoke.speed = 0.1f;
  343. }
  344. if (this._barrelSmoke.speed > 0f && this._barrelSmoke.currentAnimation == "puff" && this._barrelSmoke.finished)
  345. {
  346. this._barrelSmoke.SetAnimation("loop");
  347. }
  348. if (this._barrelSmoke.speed > 0f && this._barrelSmoke.currentAnimation == "loop" && this._barrelSmoke.frame == 5 && this._barrelHeat < 0.1f)
  349. {
  350. this._barrelSmoke.SetAnimation("finish");
  351. }
  352. }
  353. if (this._smokeWait > 0f && this._barrelSmoke.speed > 0f)
  354. {
  355. this._barrelSmoke.SetAnimation("finish");
  356. }
  357. if (this._barrelSmoke.currentAnimation == "finish" && this._barrelSmoke.finished)
  358. {
  359. this._barrelSmoke.speed = 0f;
  360. }
  361. if (this.owner != null)
  362. {
  363. if (this.owner.hSpeed > 0.1f)
  364. {
  365. this._smokeAngle -= 0.1f;
  366. }
  367. else if (this.owner.hSpeed < -0.1f)
  368. {
  369. this._smokeAngle += 0.1f;
  370. }
  371. if (this._smokeAngle > 0.4f)
  372. {
  373. this._smokeAngle = 0.4f;
  374. }
  375. if (this._smokeAngle < -0.4f)
  376. {
  377. this._smokeAngle = -0.4f;
  378. }
  379. if (this.owner.vSpeed > 0.1f)
  380. {
  381. this._smokeFlatten -= 0.1f;
  382. }
  383. else if (this.owner.vSpeed < -0.1f)
  384. {
  385. this._smokeFlatten += 0.1f;
  386. }
  387. if (this._smokeFlatten > 0.5f)
  388. {
  389. this._smokeFlatten = 0.5f;
  390. }
  391. if (this._smokeFlatten < -0.5f)
  392. {
  393. this._smokeFlatten = -0.5f;
  394. }
  395. this._framesSinceThrown = 0;
  396. }
  397. else
  398. {
  399. this._framesSinceThrown += 1;
  400. if (this._framesSinceThrown > 15)
  401. {
  402. this._framesSinceThrown = 15;
  403. }
  404. }
  405. if (!(this is Sword) && this.owner == null && this.CanSpin() && Level.current.simulatePhysics)
  406. {
  407. bool flag = false;
  408. bool flag2 = false;
  409. if ((Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) > 2f || !base.grounded) && this.gravMultiplier > 0f && !flag2 && !this._grounded)
  410. {
  411. if (this.offDir > 0)
  412. {
  413. base.angleDegrees += (Math.Abs(this.hSpeed * 2f) + Math.Abs(this.vSpeed)) * 1f + 5f;
  414. }
  415. else
  416. {
  417. base.angleDegrees -= (Math.Abs(this.hSpeed * 2f) + Math.Abs(this.vSpeed)) * 1f + 5f;
  418. }
  419. flag = true;
  420. }
  421. if (!flag || flag2)
  422. {
  423. base.angleDegrees %= 360f;
  424. if (base.angleDegrees < 0f)
  425. {
  426. base.angleDegrees += 360f;
  427. }
  428. if (flag2)
  429. {
  430. if (Math.Abs(base.angleDegrees - 90f) < Math.Abs(base.angleDegrees + 90f))
  431. {
  432. base.angleDegrees = Lerp.Float(base.angleDegrees, 90f, 16f);
  433. }
  434. else
  435. {
  436. base.angleDegrees = Lerp.Float(-90f, 0f, 16f);
  437. }
  438. }
  439. else if (base.angleDegrees > 90f && base.angleDegrees < 270f)
  440. {
  441. base.angleDegrees = Lerp.Float(base.angleDegrees, 180f, 14f);
  442. }
  443. else
  444. {
  445. if (base.angleDegrees > 180f)
  446. {
  447. base.angleDegrees -= 360f;
  448. }
  449. else if (base.angleDegrees < -180f)
  450. {
  451. base.angleDegrees += 360f;
  452. }
  453. base.angleDegrees = Lerp.Float(base.angleDegrees, 0f, 14f);
  454. }
  455. }
  456. }
  457. float num = 1f - ((float)Math.Sin((double)Maths.DegToRad(base.angleDegrees + 90f)) + 1f) / 2f;
  458. if (this._owner == null)
  459. {
  460. this._extraOffset.y = num * (this._collisionOffset.y + this._collisionSize.y + this._collisionOffset.y);
  461. }
  462. else
  463. {
  464. this._extraOffset.y = 0f;
  465. }
  466. if (this.owner == null || (this.owner.hSpeed > -0.1f && this.owner.hSpeed < 0.1f))
  467. {
  468. if (this._smokeAngle >= 0.1f)
  469. {
  470. this._smokeAngle -= 0.1f;
  471. }
  472. else if (this._smokeAngle <= -0.1f)
  473. {
  474. this._smokeAngle += 0.1f;
  475. }
  476. else
  477. {
  478. this._smokeAngle = 0f;
  479. }
  480. }
  481. if (this.owner == null || (this.owner.vSpeed > -0.1f && this.owner.vSpeed < 0.1f))
  482. {
  483. if (this._smokeFlatten >= 0.1f)
  484. {
  485. this._smokeFlatten -= 0.1f;
  486. }
  487. else if (this._smokeFlatten <= -0.1f)
  488. {
  489. this._smokeFlatten += 0.1f;
  490. }
  491. else
  492. {
  493. this._smokeFlatten = 0f;
  494. }
  495. }
  496. if (this.kick > 0f)
  497. {
  498. this.kick -= 0.2f;
  499. }
  500. else
  501. {
  502. this.kick = 0f;
  503. }
  504. if (this.owner == null)
  505. {
  506. if (this.ammo <= 0 && (base.alpha < 0.99f || (base.grounded && Math.Abs(this.hSpeed) + Math.Abs(this.vSpeed) < 0.3f)))
  507. {
  508. this.canPickUp = false;
  509. base.alpha -= 10.2f;
  510. this.weight = 0.01f;
  511. }
  512. if ((double)base.alpha < 0.0)
  513. {
  514. Level.Remove(this);
  515. }
  516. }
  517. if (this.owner != null)
  518. {
  519. this.graphic.flipH = this.owner.graphic.flipH;
  520. }
  521. if (this._wait > 0f)
  522. {
  523. this._wait -= 0.15f;
  524. }
  525. if (this._wait < 0f)
  526. {
  527. this._wait = 0f;
  528. }
  529. }
  530.  
  531. // Token: 0x06000335 RID: 821 RVA: 0x0002AE40 File Offset: 0x00029040
  532. public override void Terminate()
  533. {
  534. if (!(Level.current is Editor))
  535. {
  536. Level.Add(SmallSmoke.New(base.x, base.y));
  537. Level.Add(SmallSmoke.New(base.x + 4f, base.y));
  538. Level.Add(SmallSmoke.New(base.x - 4f, base.y));
  539. Level.Add(SmallSmoke.New(base.x, base.y + 4f));
  540. Level.Add(SmallSmoke.New(base.x, base.y - 4f));
  541. }
  542. base.Terminate();
  543. }
  544.  
  545. // Token: 0x06000336 RID: 822 RVA: 0x0002AEE8 File Offset: 0x000290E8
  546. public override void PressAction()
  547. {
  548. if (base.isServerForObject && TeamSelect2.Enabled("GUNEXPL", false) && this.ammo <= 0)
  549. {
  550. if (base.duck != null)
  551. {
  552. base.duck.ThrowItem(true);
  553. Level.Remove(this);
  554. for (int i = 0; i < 1; i++)
  555. {
  556. ExplosionPart explosionPart = new ExplosionPart(base.x - 8f + Rando.Float(16f), base.y - 8f + Rando.Float(16f), true);
  557. explosionPart.xscale *= 0.7f;
  558. explosionPart.yscale *= 0.7f;
  559. Level.Add(explosionPart);
  560. }
  561. SFX.Play("explode", 1f, 0f, 0f, false);
  562. List<Bullet> list = new List<Bullet>();
  563. for (int j = 0; j < 12; j++)
  564. {
  565. float num = (float)j * 30f - 10f + Rando.Float(20f);
  566. ATShrapnel atshrapnel = new ATShrapnel();
  567. atshrapnel.range = 25f + Rando.Float(10f);
  568. Bullet bullet = new Bullet(base.x + (float)(Math.Cos((double)Maths.DegToRad(num)) * 8.0), base.y - (float)(Math.Sin((double)Maths.DegToRad(num)) * 8.0), atshrapnel, num, null, false, -1f, false, true);
  569. bullet.firedFrom = this;
  570. list.Add(bullet);
  571. Level.Add(bullet);
  572. }
  573. if (Network.isActive)
  574. {
  575. Send.Message(new NMExplodingProp(list), NetMessagePriority.ReliableOrdered, null);
  576. list.Clear();
  577. return;
  578. }
  579. }
  580. }
  581. else
  582. {
  583. base.PressAction();
  584. }
  585. }
  586.  
  587. // Token: 0x06000337 RID: 823 RVA: 0x00005689 File Offset: 0x00003889
  588. public override void OnPressAction()
  589. {
  590. if (!this._fullAuto)
  591. {
  592. this.Fire();
  593. }
  594. }
  595.  
  596. // Token: 0x06000338 RID: 824 RVA: 0x00005699 File Offset: 0x00003899
  597. public override void OnHoldAction()
  598. {
  599. if (this._fullAuto)
  600. {
  601. this.Fire();
  602. }
  603. }
  604.  
  605. // Token: 0x06000339 RID: 825 RVA: 0x0002B098 File Offset: 0x00029298
  606. public void ApplyKick()
  607. {
  608. if (this.owner != null)
  609. {
  610. if (this._kickForce > 0f)
  611. {
  612. if (this.owner is Duck && (this.owner as Duck).ragdoll != null && (this.owner as Duck).HasEquipment(typeof(FancyShoes)) && (this.owner as Duck).ragdoll.part2 != null)
  613. {
  614. Duck duck = this.owner as Duck;
  615. Vec2 vec = -this.barrelVector * this._kickForce;
  616. duck.ragdoll.part2.hSpeed += vec.x;
  617. duck.ragdoll.part2.vSpeed += vec.y;
  618. }
  619. else
  620. {
  621. Vec2 vec2 = -this.barrelVector * this._kickForce;
  622. if (Math.Sign(this.owner.hSpeed) != Math.Sign(vec2.x) || Math.Abs(vec2.x) > Math.Abs(this.owner.hSpeed))
  623. {
  624. this.owner.hSpeed = vec2.x;
  625. }
  626. Duck duck2 = this.owner as Duck;
  627. if (duck2 != null)
  628. {
  629. if (duck2.crouch)
  630. {
  631. duck2.sliding = true;
  632. }
  633. this.owner.vSpeed += vec2.y - this._kickForce * 0.333f;
  634. }
  635. else
  636. {
  637. this.owner.vSpeed += vec2.y - this._kickForce * 0.333f;
  638. }
  639. }
  640. }
  641. this.kick = 1f;
  642. }
  643. }
  644.  
  645. // Token: 0x0600033A RID: 826 RVA: 0x0002B250 File Offset: 0x00029450
  646. public virtual void Fire()
  647. {
  648. if (!this.loaded)
  649. {
  650. return;
  651. }
  652. this.firedBullets.Clear();
  653. if (this.ammo > 0 && this._wait == 0f)
  654. {
  655. this.ApplyKick();
  656. for (int i = 0; i < this._numBulletsPerFire; i++)
  657. {
  658. float accuracy = this._ammoType.accuracy;
  659. this._ammoType.accuracy *= 1f - this._accuracyLost;
  660. this._ammoType.bulletColor = this._bulletColor;
  661. float num = base.angleDegrees;
  662. if (this.offDir < 0)
  663. {
  664. num += 180f;
  665. num -= this._ammoType.barrelAngleDegrees;
  666. }
  667. else
  668. {
  669. num += this._ammoType.barrelAngleDegrees;
  670. }
  671. if (!this.receivingPress)
  672. {
  673. if (this._ammoType is ATDart)
  674. {
  675. if (base.isServerForObject)
  676. {
  677. Vec2 vec = this.Offset(this.barrelOffset);
  678. Dart dart = new Dart(vec.x, vec.y, this.owner as Duck, -num);
  679. base.Fondle(dart);
  680. if (base.onFire || this._barrelHeat > 6f)
  681. {
  682. Level.Add(SmallFire.New(0f, 0f, 0f, 0f, false, dart, true, this, false));
  683. dart.burning = true;
  684. dart.onFire = true;
  685. base.Burn(this.position, this);
  686. }
  687. Vec2 vec2 = Maths.AngleToVec(Maths.DegToRad(-num));
  688. dart.hSpeed = vec2.x * 10f;
  689. dart.vSpeed = vec2.y * 10f;
  690. Level.Add(dart);
  691. }
  692. }
  693. else
  694. {
  695. Bullet bullet = this._ammoType.FireBullet(this.Offset(this.barrelOffset), this.owner, num, this);
  696. if (Network.isActive && base.isServerForObject)
  697. {
  698. this.firedBullets.Add(bullet);
  699. if (base.duck != null && base.duck.profile.connection != null)
  700. {
  701. bullet.connection = base.duck.profile.connection;
  702. }
  703. }
  704. if (base.isServerForObject && (this is LaserRifle || this is PewPewLaser || this is Phaser))
  705. {
  706. StatBinding laserBulletsFired = Global.data.laserBulletsFired;
  707. int valueInt = laserBulletsFired.valueInt;
  708. laserBulletsFired.valueInt = valueInt + 1;
  709. }
  710. }
  711. }
  712. this.bulletFireIndex += 1;
  713. this._ammoType.accuracy = accuracy;
  714. this._barrelHeat += 0.3f;
  715. }
  716. this._smokeWait = 3f;
  717. this.loaded = false;
  718. this._flareAlpha = 1.5f;
  719. if (!this._manualLoad)
  720. {
  721. this.Reload(true);
  722. }
  723. this.firing = true;
  724. this._wait = this._fireWait;
  725. this.PlayFireSound();
  726. if (this.owner == null)
  727. {
  728. Vec2 vec3 = this.barrelVector * Rando.Float(1f, 3f);
  729. vec3.y += Rando.Float(2f);
  730. this.hSpeed -= vec3.x;
  731. this.vSpeed -= vec3.y;
  732. }
  733. this._accuracyLost += this.loseAccuracy;
  734. if (this._accuracyLost > this.maxAccuracyLost)
  735. {
  736. this._accuracyLost = this.maxAccuracyLost;
  737. return;
  738. }
  739. }
  740. else if (this.ammo <= 0 && this._wait == 0f)
  741. {
  742. this.DoAmmoClick();
  743. this._wait = this._fireWait;
  744. }
  745. }
  746.  
  747. // Token: 0x0600033B RID: 827 RVA: 0x000056A9 File Offset: 0x000038A9
  748. protected virtual void PlayFireSound()
  749. {
  750. SFX.Play(this._fireSound, 1f, -0.1f + Rando.Float(0.2f) + this._fireSoundPitch, 0f, false);
  751. }
  752.  
  753. // Token: 0x0600033C RID: 828 RVA: 0x000056D9 File Offset: 0x000038D9
  754. public virtual void Reload(bool shell = true)
  755. {
  756. if (this.ammo != 0)
  757. {
  758. if (shell)
  759. {
  760. this._ammoType.PopShell(base.x, base.y, (int)(-(int)this.offDir));
  761. }
  762. this.ammo--;
  763. }
  764. this.loaded = true;
  765. }
  766.  
  767. // Token: 0x0600033D RID: 829 RVA: 0x0002B5E0 File Offset: 0x000297E0
  768. public override void Draw()
  769. {
  770. if (this.laserSight && this.owner != null)
  771. {
  772. ATTracer attracer = new ATTracer();
  773. attracer.range = 2000f;
  774. float num = base.angleDegrees;
  775. num *= -1f;
  776. if (this.offDir < 0)
  777. {
  778. num += 180f;
  779. }
  780. Vec2 vec = this.Offset(this.laserOffset);
  781. attracer.penetration = 0.4f;
  782. Bullet bullet = new Bullet(vec.x, vec.y, attracer, num, this.owner, false, -1f, true, true);
  783. this._wallPoint = bullet.end;
  784. this._laserInit = true;
  785. }
  786. Graphics.material = null;
  787. if (this.owner != null)
  788. {
  789. this.graphic.flipH = this.owner.graphic.flipH;
  790. }
  791. else
  792. {
  793. this.graphic.flipH = (this.offDir <= 0);
  794. }
  795. if (this._doPuff)
  796. {
  797. this._clickPuff.alpha = 0.6f;
  798. this._clickPuff.angle = this.angle + this._smokeAngle;
  799. this._clickPuff.flipH = (this.offDir < 0);
  800. base.Draw(this._clickPuff, this.barrelOffset, 1);
  801. }
  802. if (!VirtualTransition.active)
  803. {
  804. Graphics.material = base.material;
  805. }
  806. base.Draw();
  807. Graphics.material = null;
  808. if (this._flareAlpha > 0f)
  809. {
  810. base.Draw(this._flare, this.barrelOffset, 1);
  811. }
  812. if (this._barrelSmoke.speed > 0f && !base.raised)
  813. {
  814. this._barrelSmoke.alpha = 0.7f;
  815. this._barrelSmoke.angle = this._smokeAngle;
  816. this._barrelSmoke.flipH = (this.offDir < 0);
  817. if (this.offDir > 0 && base.angleDegrees > 90f && base.angleDegrees < 270f)
  818. {
  819. this._barrelSmoke.flipH = true;
  820. }
  821. if (this.offDir < 0 && base.angleDegrees > 90f && base.angleDegrees < 270f)
  822. {
  823. this._barrelSmoke.flipH = false;
  824. }
  825. this._barrelSmoke.yscale = 1f - this._smokeFlatten;
  826. base.DrawIgnoreAngle(this._barrelSmoke, this.barrelOffset, 1);
  827. }
  828. if (!VirtualTransition.active)
  829. {
  830. Graphics.material = base.material;
  831. }
  832. }
  833.  
  834. // Token: 0x0600033E RID: 830 RVA: 0x0002B844 File Offset: 0x00029A44
  835. public override void DrawGlow()
  836. {
  837. if (this.laserSight && this.owner != null && this._laserTex != null && this._laserInit)
  838. {
  839. Vec2 vec = this.Offset(this.laserOffset);
  840. float length = (vec - this._wallPoint).length;
  841. float num = 100f;
  842. if (this.ammoType != null)
  843. {
  844. num = this.ammoType.range;
  845. }
  846. Vec2 normalized = (this._wallPoint - vec).normalized;
  847. Vec2 vec2 = vec + normalized * Math.Min(num, length);
  848. Graphics.DrawTexturedLine(this._laserTex, vec, vec2, Color.Turquoise, 0.5f, base.depth - 1);
  849. if (length > num)
  850. {
  851. for (int i = 1; i < 4; i++)
  852. {
  853. Graphics.DrawTexturedLine(this._laserTex, vec2, vec2 + normalized * 2f, Color.Turquoise * (1f - (float)i * 0.2f), 0.5f, base.depth - 1);
  854. vec2 += normalized * 2f;
  855. }
  856. }
  857. if (this._sightHit != null && length < num)
  858. {
  859. this._sightHit.alpha = 1f;
  860. this._sightHit.color = Color.Turquoise;
  861. Graphics.Draw(this._sightHit, this._wallPoint.x, this._wallPoint.y);
  862. }
  863. }
  864. base.DrawGlow();
  865. }
  866.  
  867. // Token: 0x04000211 RID: 529
  868. public AmmoType _ammoType;
  869.  
  870. // Token: 0x04000212 RID: 530
  871. public StateBinding _ammoBinding = new StateBinding("netAmmo", -1, false, false);
  872.  
  873. // Token: 0x04000213 RID: 531
  874. public StateBinding _waitBinding = new StateBinding("_wait", -1, false, false);
  875.  
  876. // Token: 0x04000214 RID: 532
  877. public StateBinding _loadedBinding = new StateBinding("loaded", -1, false, false);
  878.  
  879. // Token: 0x04000215 RID: 533
  880. public StateBinding _bulletFireIndexBinding = new StateBinding("bulletFireIndex", -1, false, false);
  881.  
  882. // Token: 0x04000216 RID: 534
  883. public StateBinding _heatBinding = new StateBinding("heat", -1, false, false);
  884.  
  885. // Token: 0x04000217 RID: 535
  886. public StateBinding _infiniteAmmoValBinding = new StateBinding("infiniteAmmoVal", -1, false, false);
  887.  
  888. // Token: 0x04000218 RID: 536
  889. public byte bulletFireIndex;
  890.  
  891. // Token: 0x04000219 RID: 537
  892. public bool held;
  893.  
  894. // Token: 0x0400021A RID: 538
  895. public float kick;
  896.  
  897. // Token: 0x0400021B RID: 539
  898. public float _kickForce = 3f;
  899.  
  900. // Token: 0x0400021C RID: 540
  901. public int ammo;
  902.  
  903. // Token: 0x0400021D RID: 541
  904. public bool firing;
  905.  
  906. // Token: 0x0400021E RID: 542
  907. public bool tamping;
  908.  
  909. // Token: 0x0400021F RID: 543
  910. public float tampPos;
  911.  
  912. // Token: 0x04000220 RID: 544
  913. public float loseAccuracy;
  914.  
  915. // Token: 0x04000221 RID: 545
  916. public float _accuracyLost;
  917.  
  918. // Token: 0x04000222 RID: 546
  919. public float maxAccuracyLost;
  920.  
  921. // Token: 0x04000223 RID: 547
  922. protected Color _bulletColor = Color.Gold;
  923.  
  924. // Token: 0x04000224 RID: 548
  925. protected bool _lowerOnFire = true;
  926.  
  927. // Token: 0x04000225 RID: 549
  928. public bool receivingPress;
  929.  
  930. // Token: 0x04000226 RID: 550
  931. public bool hasFireEvents;
  932.  
  933. // Token: 0x04000227 RID: 551
  934. public bool onlyFireAction;
  935.  
  936. // Token: 0x04000228 RID: 552
  937. protected float _fireSoundPitch;
  938.  
  939. // Token: 0x04000229 RID: 553
  940. public EditorProperty<bool> infinite;
  941.  
  942. // Token: 0x0400022A RID: 554
  943. public bool infiniteAmmoVal;
  944.  
  945. // Token: 0x0400022B RID: 555
  946. protected string _bio = "No Info.";
  947.  
  948. // Token: 0x0400022C RID: 556
  949. protected Vec2 _barrelOffsetTL;
  950.  
  951. // Token: 0x0400022D RID: 557
  952. protected Vec2 _laserOffsetTL;
  953.  
  954. // Token: 0x0400022E RID: 558
  955. public float _barrelAngleOffset;
  956.  
  957. // Token: 0x0400022F RID: 559
  958. protected string _fireSound = "pistol";
  959.  
  960. // Token: 0x04000230 RID: 560
  961. protected string _clickSound = "click";
  962.  
  963. // Token: 0x04000231 RID: 561
  964. public float _wait;
  965.  
  966. // Token: 0x04000232 RID: 562
  967. public float _fireWait = 1f;
  968.  
  969. // Token: 0x04000233 RID: 563
  970. public bool loaded = true;
  971.  
  972. // Token: 0x04000234 RID: 564
  973. private bool _laserInit;
  974.  
  975. // Token: 0x04000235 RID: 565
  976. public bool _fullAuto;
  977.  
  978. // Token: 0x04000236 RID: 566
  979. public int _numBulletsPerFire = 1;
  980.  
  981. // Token: 0x04000237 RID: 567
  982. protected bool _manualLoad;
  983.  
  984. // Token: 0x04000238 RID: 568
  985. public bool laserSight;
  986.  
  987. // Token: 0x04000239 RID: 569
  988. protected SpriteMap _flare;
  989.  
  990. // Token: 0x0400023A RID: 570
  991. protected float _flareAlpha;
  992.  
  993. // Token: 0x0400023B RID: 571
  994. private SpriteMap _barrelSmoke;
  995.  
  996. // Token: 0x0400023C RID: 572
  997. public float _barrelHeat;
  998.  
  999. // Token: 0x0400023D RID: 573
  1000. protected float _smokeWait;
  1001.  
  1002. // Token: 0x0400023E RID: 574
  1003. protected float _smokeAngle;
  1004.  
  1005. // Token: 0x0400023F RID: 575
  1006. protected float _smokeFlatten;
  1007.  
  1008. // Token: 0x04000240 RID: 576
  1009. public SinWave _accuracyWave = 0.3f;
  1010.  
  1011. // Token: 0x04000241 RID: 577
  1012. private SpriteMap _clickPuff;
  1013.  
  1014. // Token: 0x04000242 RID: 578
  1015. private Tex2D _laserTex;
  1016.  
  1017. // Token: 0x04000243 RID: 579
  1018. protected Vec2 _wallPoint;
  1019.  
  1020. // Token: 0x04000244 RID: 580
  1021. protected Sprite _sightHit;
  1022.  
  1023. // Token: 0x04000245 RID: 581
  1024. public bool _doPuff;
  1025.  
  1026. // Token: 0x04000246 RID: 582
  1027. public byte _framesSinceThrown;
  1028.  
  1029. // Token: 0x04000247 RID: 583
  1030. public List<Bullet> firedBullets = new List<Bullet>();
  1031.  
  1032. // Token: 0x04000248 RID: 584
  1033. private Material _additiveMaterial;
  1034. }
  1035. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement