rock-mod 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ import { AltVCuboidColshape } from "./AltVCuboidColshape";
6
6
  import { AltVCylinderColshape } from "./AltVCylinderColshape";
7
7
  import { AltVRectangleColshape } from "./AltVRectangleColshape";
8
8
  import { AltVSphereColshape } from "./AltVSphereColshape";
9
+ import { type AltVPlayer } from "../player/AltVPlayer";
9
10
  export interface IAltVCircleColshapeCreateOptions extends ICircleColshapeCreateOptions {
10
11
  }
11
12
  export interface IAltVCuboidColshapeCreateOptions extends ICuboidColshapeCreateOptions {
@@ -17,10 +18,12 @@ export interface IAltVRectangleColshapeCreateOptions extends IRectangleColshapeC
17
18
  export interface IAltVSphereColshapeCreateOptions extends ISphereColshapeCreateOptions {
18
19
  }
19
20
  export declare class AltVColshapesManager extends AltVWorldObjectsManager<AltVColshape> implements IColshapesManager {
21
+ private readonly _colshapesParticipants;
20
22
  constructor();
21
23
  createCircle(options: IAltVCircleColshapeCreateOptions): AltVCircleColshape;
22
24
  createCuboid(options: IAltVCuboidColshapeCreateOptions): AltVCuboidColshape;
23
25
  createCylinder(options: IAltVCylinderColshapeCreateOptions): AltVCylinderColshape;
24
26
  createRectangle(options: IAltVRectangleColshapeCreateOptions): AltVRectangleColshape;
25
27
  createSphere(options: IAltVSphereColshapeCreateOptions): AltVSphereColshape;
28
+ getParticipants(colshape: AltVColshape): Set<AltVPlayer>;
26
29
  }
@@ -7,16 +7,38 @@ const AltVCuboidColshape_1 = require("./AltVCuboidColshape");
7
7
  const AltVCylinderColshape_1 = require("./AltVCylinderColshape");
8
8
  const AltVRectangleColshape_1 = require("./AltVRectangleColshape");
9
9
  const AltVSphereColshape_1 = require("./AltVSphereColshape");
10
+ const RockMod_1 = require("../../../RockMod");
11
+ const types_1 = require("../../../net/common/events/types");
10
12
  var ColshapeCircle = AltVServer.ColshapeCircle;
11
13
  var ColshapeCuboid = AltVServer.ColshapeCuboid;
12
14
  var ColshapeCylinder = AltVServer.ColshapeCylinder;
13
15
  var ColshapeRectangle = AltVServer.ColshapeRectangle;
14
16
  var ColshapeSphere = AltVServer.ColshapeSphere;
17
+ var BaseObjectType = AltVShared.BaseObjectType;
15
18
  class AltVColshapesManager extends AltVWorldObjectsManager_1.AltVWorldObjectsManager {
19
+ _colshapesParticipants = new Map();
16
20
  constructor() {
17
21
  super({
18
22
  baseObjectsType: "colshape",
19
23
  });
24
+ AltVServer.on("entityEnterColshape", (mpColshape, mpEntity) => {
25
+ if (mpEntity.type === BaseObjectType.Player) {
26
+ const player = RockMod_1.RockMod.instance.players.getByID(mpEntity.id);
27
+ const colshape = this.getByID(mpColshape.id);
28
+ const participants = this.getParticipants(colshape);
29
+ participants.add(player);
30
+ RockMod_1.RockMod.instance.net.events.emitInternal(types_1.ServerInternalEventName.PlayerEnteredColshape, player, colshape);
31
+ }
32
+ });
33
+ AltVServer.on("entityLeaveColshape", (mpColshape, mpEntity) => {
34
+ if (mpEntity.type === BaseObjectType.Player) {
35
+ const player = RockMod_1.RockMod.instance.players.getByID(mpEntity.id);
36
+ const colshape = this.getByID(mpColshape.id);
37
+ const participants = this.getParticipants(colshape);
38
+ participants.delete(player);
39
+ RockMod_1.RockMod.instance.net.events.emitInternal(types_1.ServerInternalEventName.PlayerLeftColshape, player, colshape);
40
+ }
41
+ });
20
42
  }
21
43
  createCircle(options) {
22
44
  const { range, position, dimension } = options;
@@ -63,5 +85,13 @@ class AltVColshapesManager extends AltVWorldObjectsManager_1.AltVWorldObjectsMan
63
85
  this.registerBaseObject(colshape);
64
86
  return colshape;
65
87
  }
88
+ getParticipants(colshape) {
89
+ let participants = this._colshapesParticipants.get(colshape);
90
+ if (!participants) {
91
+ participants = new Set();
92
+ this._colshapesParticipants.set(colshape, participants);
93
+ }
94
+ return participants;
95
+ }
66
96
  }
67
97
  exports.AltVColshapesManager = AltVColshapesManager;
@@ -6,6 +6,7 @@ import { type ICuboidColshape } from "./ICuboidColshape";
6
6
  import { type ICylinderColshape } from "./ICylinderColshape";
7
7
  import { type IRectangleColshape } from "./IRectangleColshape";
8
8
  import { type ISphereColshape } from "./ISphereColshape";
9
+ import { type IPlayer } from "../player";
9
10
  export interface ICircleColshapeCreateOptions extends Omit<IWorldObjectCreateOptions, "position"> {
10
11
  position: IVector2D;
11
12
  range: number;
@@ -32,4 +33,5 @@ export interface IColshapesManager extends IWorldObjectsManager<IColshape> {
32
33
  createCylinder(options: ICylinderColshapeCreateOptions): ICylinderColshape;
33
34
  createRectangle(options: IRectangleColshapeCreateOptions): IRectangleColshape;
34
35
  createSphere(options: ISphereColshapeCreateOptions): ISphereColshape;
36
+ getParticipants(colshape: IColshape): Set<IPlayer>;
35
37
  }
@@ -6,6 +6,7 @@ import { MockCylinderColshape } from "./MockCylinderColshape";
6
6
  import { MockRectangleColshape } from "./MockRectangleColshape";
7
7
  import { MockSphereColshape } from "./MockSphereColshape";
8
8
  import { type MockColshape } from "./MockColshape";
9
+ import { type MockPlayer } from "../player/MockPlayer";
9
10
  export interface IMockCircleColshapeCreateOptions extends ICircleColshapeCreateOptions {
10
11
  }
11
12
  export interface IMockCuboidColshapeCreateOptions extends ICuboidColshapeCreateOptions {
@@ -24,4 +25,5 @@ export declare class MockColshapesManager extends MockWorldObjectsManager<MockCo
24
25
  createCylinder(options: IMockCylinderColshapeCreateOptions): MockCylinderColshape;
25
26
  createRectangle(options: IMockRectangleColshapeCreateOptions): MockRectangleColshape;
26
27
  createSphere(options: IMockSphereColshapeCreateOptions): MockSphereColshape;
28
+ getParticipants(): Set<MockPlayer>;
27
29
  }
@@ -86,5 +86,8 @@ class MockColshapesManager extends MockWorldObjectsManager_1.MockWorldObjectsMan
86
86
  this.registerBaseObject(colshape);
87
87
  return colshape;
88
88
  }
89
+ getParticipants() {
90
+ return new Set();
91
+ }
89
92
  }
90
93
  exports.MockColshapesManager = MockColshapesManager;
@@ -6,6 +6,7 @@ import { RageCuboidColshape } from "./RageCuboidColshape";
6
6
  import { RageCylinderColshape } from "./RageCylinderColshape";
7
7
  import { RageRectangleColshape } from "./RageRectangleColshape";
8
8
  import { RageSphereColshape } from "./RageSphereColshape";
9
+ import { type RagePlayer } from "../player/RagePlayer";
9
10
  export interface IRageCircleColshapeCreateOptions extends ICircleColshapeCreateOptions {
10
11
  }
11
12
  export interface IRageCuboidColshapeCreateOptions extends ICuboidColshapeCreateOptions {
@@ -17,10 +18,12 @@ export interface IRageRectangleColshapeCreateOptions extends IRectangleColshapeC
17
18
  export interface IRageSphereColshapeCreateOptions extends ISphereColshapeCreateOptions {
18
19
  }
19
20
  export declare class RageColshapesManager extends RageWorldObjectsManager<RageColshape> implements IColshapesManager {
21
+ private readonly _colshapesParticipants;
20
22
  constructor();
21
23
  createCircle(options: IRageCircleColshapeCreateOptions): RageCircleColshape;
22
24
  createCuboid(options: IRageCuboidColshapeCreateOptions): RageCuboidColshape;
23
25
  createCylinder(options: IRageCylinderColshapeCreateOptions): RageCylinderColshape;
24
26
  createRectangle(options: IRageRectangleColshapeCreateOptions): RageRectangleColshape;
25
27
  createSphere(options: IRageSphereColshapeCreateOptions): RageSphereColshape;
28
+ getParticipants(colshape: RageColshape): Set<RagePlayer>;
26
29
  }
@@ -7,11 +7,28 @@ const RageCuboidColshape_1 = require("./RageCuboidColshape");
7
7
  const RageCylinderColshape_1 = require("./RageCylinderColshape");
8
8
  const RageRectangleColshape_1 = require("./RageRectangleColshape");
9
9
  const RageSphereColshape_1 = require("./RageSphereColshape");
10
+ const RockMod_1 = require("../../../RockMod");
11
+ const types_1 = require("../../../net/common/events/types");
10
12
  class RageColshapesManager extends RageWorldObjectsManager_1.RageWorldObjectsManager {
13
+ _colshapesParticipants = new Map();
11
14
  constructor() {
12
15
  super({
13
16
  baseObjectsType: "colshape",
14
17
  });
18
+ mp.events.add("playerEnterColshape", (mpPlayer, mpColshape) => {
19
+ const player = RockMod_1.RockMod.instance.players.getByID(mpPlayer.id);
20
+ const colshape = this.getByID(mpColshape.id);
21
+ const participants = this.getParticipants(colshape);
22
+ participants.add(player);
23
+ RockMod_1.RockMod.instance.net.events.emitInternal(types_1.ServerInternalEventName.PlayerEnteredColshape, player, colshape);
24
+ });
25
+ mp.events.add("playerExitColshape", (mpPlayer, mpColshape) => {
26
+ const player = RockMod_1.RockMod.instance.players.getByID(mpPlayer.id);
27
+ const colshape = this.getByID(mpColshape.id);
28
+ const participants = this.getParticipants(colshape);
29
+ participants.delete(player);
30
+ RockMod_1.RockMod.instance.net.events.emitInternal(types_1.ServerInternalEventName.PlayerLeftColshape, player, colshape);
31
+ });
15
32
  }
16
33
  createCircle(options) {
17
34
  const { range, position, dimension } = options;
@@ -58,5 +75,13 @@ class RageColshapesManager extends RageWorldObjectsManager_1.RageWorldObjectsMan
58
75
  this.registerBaseObject(colshape);
59
76
  return colshape;
60
77
  }
78
+ getParticipants(colshape) {
79
+ let participants = this._colshapesParticipants.get(colshape);
80
+ if (!participants) {
81
+ participants = new Set();
82
+ this._colshapesParticipants.set(colshape, participants);
83
+ }
84
+ return participants;
85
+ }
61
86
  }
62
87
  exports.RageColshapesManager = RageColshapesManager;
@@ -1,13 +1,17 @@
1
- import { type IBaseObject, type IPlayer } from "../../../entities";
1
+ import { type IBaseObject, type IColshape, type IPlayer } from "../../../entities";
2
2
  export declare enum ServerInternalEventName {
3
3
  PlayerConnected = "rm::playerConnected",
4
4
  PlayerDisconnected = "rm::playerDisconnected",
5
+ PlayerEnteredColshape = "rm::playerEnteredColshape",
6
+ PlayerLeftColshape = "rm::playerLeftColshape",
5
7
  EntityCreated = "rm::entityCreated",
6
8
  EntityDestroyed = "rm::entityDestroyed"
7
9
  }
8
10
  export interface IServerInternalEvents {
9
11
  [ServerInternalEventName.PlayerConnected]: (player: IPlayer) => void;
10
12
  [ServerInternalEventName.PlayerDisconnected]: (player: IPlayer) => void;
13
+ [ServerInternalEventName.PlayerEnteredColshape]: (player: IPlayer, colshape: IColshape) => void;
14
+ [ServerInternalEventName.PlayerLeftColshape]: (player: IPlayer, colshape: IColshape) => void;
11
15
  [ServerInternalEventName.EntityCreated]: (object: IBaseObject) => void;
12
16
  [ServerInternalEventName.EntityDestroyed]: (object: IBaseObject) => void;
13
17
  }
@@ -5,6 +5,8 @@ var ServerInternalEventName;
5
5
  (function (ServerInternalEventName) {
6
6
  ServerInternalEventName["PlayerConnected"] = "rm::playerConnected";
7
7
  ServerInternalEventName["PlayerDisconnected"] = "rm::playerDisconnected";
8
+ ServerInternalEventName["PlayerEnteredColshape"] = "rm::playerEnteredColshape";
9
+ ServerInternalEventName["PlayerLeftColshape"] = "rm::playerLeftColshape";
8
10
  ServerInternalEventName["EntityCreated"] = "rm::entityCreated";
9
11
  ServerInternalEventName["EntityDestroyed"] = "rm::entityDestroyed";
10
12
  })(ServerInternalEventName || (exports.ServerInternalEventName = ServerInternalEventName = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rock-mod",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",