-
Notifications
You must be signed in to change notification settings - Fork 9
/
Objects.simba
124 lines (112 loc) · 2.6 KB
/
Objects.simba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
type
TRSObject = record
ID: Int32;
Tile: RSTile;
ObjectType: RSObjectType;
Name: String;
end;
{*
R_FindObject
~~~~~~~~~~~~~~~~~~~~~~
Returns a TRSObject of object on a specific tile.
RSObjectTypes:
- GAME_OBJECT
- WALL_DECORATION
- BOUNDARY_OBJECT
- FLOOR_DECORATION
Example:
Bank := R_FindObject(GAME_OBJECT, 2403, 3452);
*}
Function R_FindObject(ObjectType: RSObjectType; X, Y: Int32): TRSObject;
var
Obj: RSObject;
Definition: RSObjectDefinition;
begin
Obj := RSObject.Get(ObjectType, X, Y);
if Obj.ref <> nil then
begin
Definition := Obj.Definition;
Result.ID := Obj.ID;
Result.Tile := Obj.Tile;
Result.ObjectType := ObjectType;
if Definition.ref <> nil then
begin
Result.Name := Definition.Name;
Definition.Free;
end;
Obj.Free;
end;
end;
{*
R_FindObject
~~~~~~~~~~~~~~~~~~~~~~
Returns an array of TRSObject of the specified ID and Object Type.
RSObjectTypes:
- GAME_OBJECT
- WALL_DECORATION
- BOUNDARY_OBJECT
- FLOOR_DECORATION
Example:
Trees := R_FindObject(1342, GAME_OBJECT);
*}
Function R_FindObjects(ID: Int32; ObjectType: RSObjectType): Array of TRSObject; overload;
var
I, J: Int32;
Objects: Array of RSObject;
Definition: RSObjectDefinition;
begin
Objects := RSObject.Get(ObjectType);
SetLength(Result, Length(Objects));
For I := 0 to High(Objects) do
begin
If Objects[I].ID = ID then
begin
Definition := Objects[I].Definition;
Result[J].ID := ID;
Result[J].Tile := Objects[I].Tile;
Result[J].ObjectType := ObjectType;
if Definition.ref <> nil then
begin
Result[J].Name := Definition.Name;
Definition.Free;
end;
Inc(J);
end;
Objects[I].Free;
end;
SetLength(Result, J);
end;
{*
R_FindObject
~~~~~~~~~~~~~~~~~~~~~~
Returns an array of TRSObject of the specified Object Type.
RSObjectTypes:
- GAME_OBJECT
- WALL_DECORATION
- BOUNDARY_OBJECT
- FLOOR_DECORATION
Example:
AllObjects := R_FindObject(GAME_OBJECT);
*}
Function R_FindObjects(ObjectType: RSObjectType): Array of TRSObject; overload;
var
I: Int32;
Objects: Array of RSObject;
Definition: RSObjectDefinition;
begin
Objects := RSObject.Get(ObjectType);
SetLength(Result, Length(Objects));
For I := 0 to High(Objects) do
begin
Definition := Objects[I].Definition;
Result[I].ID := Objects[I].ID;
Result[I].Tile := Objects[I].Tile;
Result[I].ObjectType := ObjectType;
if Definition.ref <> nil then
begin
Result[I].Name := Definition.Name;
Definition.Free;
end;
Objects[I].Free;
end;
end;