desire
This commit is contained in:
parent
54aff02658
commit
8bd4405fe8
33 changed files with 2478 additions and 610 deletions
|
|
@ -52,17 +52,34 @@ class Tarinai { constructor(world, opts = {}) {
|
|||
this.hasPaired = opts.hasPaired ?? false;
|
||||
this.hunger = opts.hunger ?? rand(16, 45);
|
||||
this.loneliness = opts.loneliness ?? rand(18, 62);
|
||||
this.energy = opts.energy ?? rand(54, 98);
|
||||
this.needs = opts.needs && typeof opts.needs === "object" && typeof createDefaultNeeds === "function" ? { ...createDefaultNeeds(), ...opts.needs } : (typeof createDefaultNeeds === "function" ? createDefaultNeeds() : { food: 0, sleep: 0, health: 0, safety: 0, social: 0, fulfill: 0 });
|
||||
this.stress = typeof calculateStressFromNeeds === "function" ? calculateStressFromNeeds(this.needs) : 0;
|
||||
this.previousNeeds = opts.previousNeeds && typeof opts.previousNeeds === "object" && typeof createDefaultNeeds === "function" ? { ...createDefaultNeeds(), ...opts.previousNeeds } : { ...this.needs };
|
||||
const initialDayP = world?.dayProgress?.() || 0;
|
||||
const initialNight = initialDayP >= 0.66 || initialDayP < 0.18;
|
||||
const initialAfternoon = initialDayP >= 0.46 && initialDayP < 0.58;
|
||||
this.energy = opts.energy ?? (initialNight ? rand(34, 68) : (initialAfternoon ? rand(50, 82) : rand(66, 98)));
|
||||
this.circadianSleepPressure = Number.isFinite(opts.circadianSleepPressure) ? opts.circadianSleepPressure : (initialNight ? rand(58, 78) : (initialAfternoon ? rand(8, 18) : rand(0, 5)));
|
||||
const defaultNeeds = typeof createDefaultNeeds === "function" ? createDefaultNeeds() : { food: 0, sleep: 0, health: 0, safety: 0, social: 0, fulfill: 0 };
|
||||
this.needs = opts.needs && typeof opts.needs === "object" ? { ...defaultNeeds, ...opts.needs } : { ...defaultNeeds };
|
||||
this.needDisplay = opts.needDisplay && typeof opts.needDisplay === "object" ? { ...defaultNeeds, ...opts.needDisplay } : { ...this.needs };
|
||||
this.needRaw = opts.needRaw && typeof opts.needRaw === "object" ? { ...defaultNeeds, ...opts.needRaw } : { ...this.needs };
|
||||
this.needRawBase = opts.needRawBase && typeof opts.needRawBase === "object" ? { ...defaultNeeds, ...opts.needRawBase } : { ...this.needRaw };
|
||||
this.needSatisfaction = opts.needSatisfaction && typeof opts.needSatisfaction === "object" ? { ...defaultNeeds, ...opts.needSatisfaction } : { ...defaultNeeds };
|
||||
this.lastSatisfiedAt = opts.lastSatisfiedAt && typeof opts.lastSatisfiedAt === "object" ? { ...opts.lastSatisfiedAt } : {};
|
||||
this.lastSatisfactionSource = opts.lastSatisfactionSource || "";
|
||||
this.stress = typeof calculateStressFromNeeds === "function" ? calculateStressFromNeeds(this.needRaw || this.needs) : 0;
|
||||
this.previousNeeds = opts.previousNeeds && typeof opts.previousNeeds === "object" ? { ...defaultNeeds, ...opts.previousNeeds } : { ...this.needs };
|
||||
this.intent = opts.intent && typeof opts.intent === "object" ? { ...opts.intent } : null;
|
||||
this.currentAction = opts.currentAction && typeof opts.currentAction === "object" ? { ...opts.currentAction } : null;
|
||||
this.activeBehavior = opts.activeBehavior && typeof opts.activeBehavior === "object" ? { ...opts.activeBehavior } : null;
|
||||
this.forcedBehaviorQueue = Array.isArray(opts.forcedBehaviorQueue) ? opts.forcedBehaviorQueue.map(v => ({ ...(v || {}) })).slice(-8) : [];
|
||||
this.behaviorSerial = opts.behaviorSerial ?? 0;
|
||||
this.actionCooldowns = opts.actionCooldowns && typeof opts.actionCooldowns === "object" ? { ...opts.actionCooldowns } : {};
|
||||
this.needShock = opts.needShock && typeof opts.needShock === "object" ? { ...opts.needShock } : {};
|
||||
this.buildPlan = opts.buildPlan && typeof opts.buildPlan === "object" ? { ...opts.buildPlan } : null;
|
||||
this.sleepSession = opts.sleepSession && typeof opts.sleepSession === "object" ? { ...opts.sleepSession } : null;
|
||||
this.hpBarTimer = opts.hpBarTimer ?? 0;
|
||||
this.stressBarTimer = opts.stressBarTimer ?? 0;
|
||||
this.affection = opts.affection ?? rand(0, 30);
|
||||
this.need = opts.need || pick(NEEDS);
|
||||
this.need = "";
|
||||
this.state = opts.state || "idle";
|
||||
this.dead = !!opts.dead;
|
||||
this.deathReason = opts.deathReason || "";
|
||||
|
|
@ -83,6 +100,7 @@ class Tarinai { constructor(world, opts = {}) {
|
|||
this.panicTargetUntil = opts.panicTargetUntil ?? 0;
|
||||
this.panicStuckTimer = opts.panicStuckTimer ?? 0;
|
||||
this.wanderAngle = rand(0, Math.PI * 2);
|
||||
this.wanderTarget = opts.wanderTarget && typeof opts.wanderTarget === "object" ? { ...opts.wanderTarget } : null;
|
||||
this.reproductionTimer = rand(4, CONFIG.reproductionCooldown);
|
||||
this.lastLog = 0;
|
||||
this.sleeping = false;
|
||||
|
|
@ -95,7 +113,9 @@ class Tarinai { constructor(world, opts = {}) {
|
|||
this.visualFacing = opts.visualFacing ?? this.facing;
|
||||
this.facingLockUntil = opts.facingLockUntil ?? 0;
|
||||
this.eatTimer = opts.eatTimer ?? 0;
|
||||
this.eatCooldown = 0;
|
||||
this.eatCooldown = opts.eatCooldown ?? 0;
|
||||
this.lastAteAt = Number.isFinite(opts.lastAteAt) ? opts.lastAteAt : (this.world?.time || 0);
|
||||
this.mealCooldownUntil = Number.isFinite(opts.mealCooldownUntil) ? opts.mealCooldownUntil : 0;
|
||||
this.foodReactTimer = opts.foodReactTimer ?? 0;
|
||||
this.surpriseTimer = opts.surpriseTimer ?? 0;
|
||||
this.fearTimer = opts.fearTimer ?? 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue