Skip to content

Commit 71b585a

Browse files
committed
new methods, they are untested for now
1 parent bae2f20 commit 71b585a

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

scripts/ArluqTools2/services/AnimalService.lua

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ include "scenario/scripts/entity.lua"
33
include "scenario/scripts/misc.lua"
44
include "scenario/scripts/token.lua"
55
include "scenario/scripts/ui.lua"
6+
include "scripts/canreproduce.lua"
67

78
--- Service for modifiying animals.
89
AnimalService = {}
@@ -70,6 +71,22 @@ function AnimalService.setBathroom (animal, bathroom)
7071
setNeed(animal, "bathroom", bathroom)
7172
end
7273

74+
---- BREATH ----
75+
76+
--- Get animal breath
77+
--- @param animal animal
78+
--- @return float
79+
function AnimalService.getBreath (animal)
80+
return animal:BFG_GET_ATTR_FLOAT("breath")
81+
end
82+
83+
--- Set animal breath
84+
--- @param animal animal
85+
--- @param breath float
86+
function AnimalService.setBreath (animal, breath)
87+
setNeed(animal, "breath", breath)
88+
end
89+
7390
---- CRATE ----
7491

7592
--- Set animal crated status
@@ -83,6 +100,20 @@ function AnimalService.setCrated (animal, isCrated)
83100
end
84101
end
85102

103+
--- Get whether or not an animal can be crated
104+
--- @param animal animal
105+
--- @return bool
106+
function AnimalService.getCrateOption (animal)
107+
return animal:BFG_GET_ATTR_BOOLEAN("b_showCrate")
108+
end
109+
110+
--- Set whether or not an animal can be crated
111+
--- @param animal animal
112+
--- @param canBeCrated bool
113+
function AnimalService.setCrateOption (animal, canBeCrated)
114+
animal:BFG_SET_ATTR_BOOLEAN("b_showCrate", canBeCrated)
115+
end
116+
86117
---- DELETE ----
87118

88119
--- Delete animal
@@ -123,6 +154,18 @@ function AnimalService.setExercise (animal, exercise)
123154
setNeed(animal, "exercise", exercise)
124155
end
125156

157+
---- FAMILY ----
158+
159+
--- Get an animal's children
160+
--- @param animal animal
161+
--- @return animalList
162+
function AnimalService.getChildren (animal)
163+
local childrenList = animal:sendMessage("BFAI_GET_RELATED_ENTITIES", "child")
164+
if childrenList ~= nil and type(childrenList) == "table" then
165+
return childrenList
166+
end
167+
end
168+
126169
---- GENDER ----
127170

128171
--- Get animal gender, returns true if male, false if female
@@ -245,6 +288,13 @@ function AnimalService.setPregnant (animal, isPregnant)
245288
end
246289
end
247290

291+
--- Get if animal has pregnancy token
292+
--- @param animal animal
293+
--- @return bool
294+
function AnimalService.getPregnancyToken (animal)
295+
return checkforpregnant(animal)
296+
end
297+
248298
---- PRIVACY ----
249299

250300
--- Get animal privacy
@@ -293,6 +343,29 @@ function AnimalService.setReleaseOption (animal, canBeReleased)
293343
animal:BFG_SET_ATTR_BOOLEAN("b_showRelease", canBeReleased)
294344
end
295345

346+
---- REPRODUCTION ----
347+
348+
--- Get animal reproduction stat
349+
--- @param animal animal
350+
--- @return float
351+
function AnimalService.getReproduction (animal)
352+
return animal:BFG_GET_ATTR_FLOAT("reproduction")
353+
end
354+
355+
--- Set animal reproduction stat
356+
--- @param animal animal
357+
--- @param reproduction float
358+
function AnimalService.setReproduction (animal, reproduction)
359+
setNeed(animal, "reproduction", reproduction)
360+
end
361+
362+
--- Get if animal can reproduce
363+
--- @param animal animal
364+
--- @return bool
365+
function AnimalService.getCanReproduce (animal)
366+
return canreproduce(animal)
367+
end
368+
296369
---- REST ----
297370

298371
--- Get animal rest status

0 commit comments

Comments
 (0)