Skip to content

Commit

Permalink
[FIXES] Bug fixing and improvements of stalker move/patrol manager. (#38
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Neloreck authored Sep 16, 2023
2 parents 39430a5 + 8941c3a commit bead567
Show file tree
Hide file tree
Showing 76 changed files with 1,525 additions and 1,162 deletions.
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
Thank you for your pull request. Please provide a description and review the requirements below.
Not needed sections can be removed from final description. Commented strings can be removed too.
-->

## Changes
<!-- Update items to match actual changes. -->

- Something is changed
- Something else is fixed

## Screenshots
<!-- Add screenshots if possible or remove the section. -->

## Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [ ] tests are included
- [ ] documentation is changed or added

## Links / references
<!-- Add related links and references if possible or remove the section. -->
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"help": "ts-node -P ./cli/tsconfig.json cli/run.ts -h"
},
"dependencies": {
"xray16": "1.0.7"
"xray16": "1.0.9"
},
"devDependencies": {
"@jest/globals": "^29.6.4",
Expand Down
6 changes: 3 additions & 3 deletions src/engine/core/database/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { registry } from "@/engine/core/database/registry";

describe("registry storage", () => {
it("storage to contain all fields", () => {
expect(Object.keys(registry)).toHaveLength(40);
expect(Object.keys(registry)).toHaveLength(41);
});

it("storage to initialize with correct data", () => {
Expand Down Expand Up @@ -50,8 +50,8 @@ describe("registry storage", () => {
expect(registry.saveMarkers instanceof LuaTable).toBeTruthy();
expect(registry.signalLights instanceof LuaTable).toBeTruthy();
expect(registry.spawnedVertexes instanceof LuaTable).toBeTruthy();
expect(registry.patrols.generic instanceof LuaTable).toBeTruthy();
expect(registry.patrols.reachTask instanceof LuaTable).toBeTruthy();
expect(registry.patrols).toEqualLuaTables({ generic: {}, reachTask: {} });
expect(registry.patrolSynchronization instanceof LuaTable).toBeTruthy();
expect(registry.sounds.musicVolume).toBe(0);
expect(registry.sounds.effectsVolume).toBe(0);
expect(registry.sounds.generic instanceof LuaTable).toBeTruthy();
Expand Down
5 changes: 5 additions & 0 deletions src/engine/core/database/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ export const registry = {
generic: new LuaTable<TStringId, PatrolManager>(),
reachTask: new LuaTable<TNumberId, ReachTaskPatrolManager>(),
},
/**
* List of synchronization groups for game patrols.
* Related to stalkers patrol manager.
*/
patrolSynchronization: new LuaTable<TName, LuaTable<TNumberId, boolean>>(),
/**
* State of active sounds.
*/
Expand Down
18 changes: 13 additions & 5 deletions src/engine/core/database/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ObjectRestrictionsManager } from "@/engine/core/objects/ai/restriction";
import { StalkerMoveManager } from "@/engine/core/objects/ai/state/StalkerMoveManager";
import { StalkerPatrolManager } from "@/engine/core/objects/ai/state/StalkerPatrolManager";
import { StalkerStateManager } from "@/engine/core/objects/ai/state/StalkerStateManager";
import { ISchemePostCombatIdleState } from "@/engine/core/schemes/combat_idle/ISchemePostCombatIdleState";
import { IActionSchemeHearState } from "@/engine/core/schemes/hear";
Expand Down Expand Up @@ -30,6 +30,12 @@ export interface IBaseSchemeLogic {
p2: Optional<string | number>;
}

/**
* List of scheme logics signal.
* Used to set / check in some script scenarios.
*/
export type TSchemeSignals = LuaTable<TName, boolean>;

/**
* todo;
*/
Expand All @@ -44,7 +50,7 @@ export interface IBaseSchemeState {
* List of signals in active scheme state.
* Signals are flags indicating whether some action/thing happened.
*/
signals: Optional<LuaTable<TName, boolean>>; // Rework with LuaSet?
signals: Optional<TSchemeSignals>;
scheme: EScheme;
section: Optional<TSection>;
actions?: LuaTable<AnyObject, boolean>;
Expand Down Expand Up @@ -133,11 +139,13 @@ export interface IRegistryObjectState extends Record<EScheme, Optional<IBaseSche
*/
portableStore: Optional<LuaTable<TName>>;
/**
* todo;
* Patrol manager for stalker objects.
* Handles patrols selection/logics/waypoints etc.
*/
moveManager: Optional<StalkerMoveManager>;
patrolManager: Optional<StalkerPatrolManager>;
/**
* todo;
* State manager class for stalker objects.
* Handles current animation/animstate logics and adjust stalker object to match required logics.
*/
stateManager: Optional<StalkerStateManager>;
/**
Expand Down
6 changes: 2 additions & 4 deletions src/engine/core/managers/debug/ProfilingManager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { profile_timer } from "xray16";
import { flush, profile_timer } from "xray16";

import { AbstractManager } from "@/engine/core/managers/base/AbstractManager";
import { abort } from "@/engine/core/utils/assertion";
import { executeConsoleCommand } from "@/engine/core/utils/game/game_console";
import { LuaLogger } from "@/engine/core/utils/logging";
import { gameConfig } from "@/engine/lib/configs/GameConfig";
import { consoleCommands } from "@/engine/lib/constants/console_commands";
import { AnyCallable, Optional, ProfileTimer, TCount, TName } from "@/engine/lib/types";

const logger: LuaLogger = new LuaLogger($filename);
Expand Down Expand Up @@ -168,7 +166,7 @@ export class ProfilingManager extends AbstractManager {
logger.info("==================================================================================================");
logger.pushEmptyLine();

executeConsoleCommand(consoleCommands.flush);
flush();

this.setupHook(this.mode, true);
}
Expand Down
15 changes: 15 additions & 0 deletions src/engine/core/managers/notifications/NotificationManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,21 @@ describe("NotificationManager class", () => {
0
);

notificationManager.onPlayPdaNotificationSound = jest.fn();
notificationManager.onSendGenericNotification = jest.fn();
notificationManager.sendTipNotification("test_simple", "can_resupply", 200, 555, "test");

expect(notificationManager.onPlayPdaNotificationSound).toHaveBeenCalledTimes(1);
expect(notificationManager.onSendGenericNotification).toHaveBeenCalledWith(
false,
"translated_st_tip",
"translated_test_simple",
"ui_inGame2_Pered_zadaniyami_voennih",
200,
555,
0
);

registerStoryLink(registry.actor.id(), "test-sid");

MockAlifeSimulator.addToRegistry(
Expand Down
12 changes: 9 additions & 3 deletions src/engine/core/managers/notifications/NotificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class NotificationManager extends AbstractManager {
*/
public sendTipNotification(
caption: TLabel,
sender: Optional<TNotificationIcon | ClientObject> = null,
sender: Optional<TNotificationIcon | TNotificationIconKey | ClientObject> = null,
delay: Optional<TDuration> = 0,
showtime: Optional<TTimestamp> = NotificationManager.DEFAULT_NOTIFICATION_SHOW_DURATION,
senderId: Optional<TStringId> = null
Expand Down Expand Up @@ -272,8 +272,12 @@ export class NotificationManager extends AbstractManager {

// If sender is game object, check sender character icon to display instead of generic one.
if (sender !== null) {
notificationIcon =
type(sender) === "string" ? (sender as TNotificationIcon) : (sender as ClientObject).character_icon();
// In case of string check if it is name of icon (original schemas use it) or fallback to just string.
if (type(sender) === "string") {
notificationIcon = notificationsIcons[sender as TNotificationIconKey] || (sender as TNotificationIcon);
} else {
notificationIcon = (sender as ClientObject).character_icon();
}
}

this.onPlayPdaNotificationSound();
Expand Down Expand Up @@ -384,6 +388,8 @@ export class NotificationManager extends AbstractManager {
showTime: TDuration,
type: Optional<TNumberId> = null
): void {
logger.format("Send generic notification: '%s', '%s', '%s'", notificationTitle, notificationText, notificationIcon);

if (isFlexible && registry.actor.is_talking()) {
registry.actor.give_talk_message2(notificationTitle, notificationText, notificationIcon, "iconed_answer_item");
} else {
Expand Down
Loading

0 comments on commit bead567

Please sign in to comment.