Skip to content

Commit

Permalink
Generic docblocks. Update scheme related to wounded help.
Browse files Browse the repository at this point in the history
  • Loading branch information
Neloreck committed Aug 20, 2023
1 parent 09b5c96 commit b67d47e
Show file tree
Hide file tree
Showing 67 changed files with 470 additions and 279 deletions.
2 changes: 1 addition & 1 deletion src/engine/configs/misc/items.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ boost_radiation_restore = 0.01
use_sound = interface\inv_pills
;medikits new
[medkit_script]:booster ;Do not use! Used in xr_wounded
[medkit_script]:booster ; Do not use! Used in xr_wounded for helping wounded stalkers only
;$spawn = "food and drugs\medkit_script"
visual = dynamics\devices\dev_aptechka\dev_aptechka_low.ogf
inv_name = st_medkit
Expand Down
2 changes: 0 additions & 2 deletions src/engine/core/database/managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ export function initializeManager(managerClass: TAbstractCoreManagerConstructor)
registry.managers.set(managerClass, instance);

instance.initialize();
} else {
logger.info("Manager already initialized, skip:", managerClass.name);
}
}

Expand Down
21 changes: 20 additions & 1 deletion src/engine/core/database/objects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { setPortableStoreValue } from "@/engine/core/database/portable_store";
import { registry } from "@/engine/core/database/registry";
import { IRegistryObjectState } from "@/engine/core/database/types";
import { ClientObject, Optional } from "@/engine/lib/types";
import { HELPING_WOUNDED_OBJECT_KEY } from "@/engine/lib/constants/portable_store_keys";
import { ClientObject, Optional, TNumberId } from "@/engine/lib/types";

/**
* Register client object in RAM registry.
Expand Down Expand Up @@ -47,3 +49,20 @@ export function resetObject(object: ClientObject, state: Partial<IRegistryObject

return state as IRegistryObjectState;
}

/**
* todo;
*/
export function registerWoundedObject(object: ClientObject): void {
const objectId: TNumberId = object.id();

registry.objectsWounded.set(objectId, registry.objects.get(objectId));
}

/**
* todo;
*/
export function unRegisterWoundedObject(object: ClientObject): void {
setPortableStoreValue(object, HELPING_WOUNDED_OBJECT_KEY, null);
registry.objectsWounded.delete(object.id());
}
1 change: 1 addition & 0 deletions src/engine/core/database/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("registry storage", () => {
expect(registry.cache.conditionLists instanceof LuaTable).toBeTruthy();
expect(registry.actorCombat instanceof LuaTable).toBeTruthy();
expect(registry.objects instanceof LuaTable).toBeTruthy();
expect(registry.objectsWounded instanceof LuaTable).toBeTruthy();
expect(registry.offlineObjects instanceof LuaTable).toBeTruthy();
expect(registry.simulationObjects instanceof LuaTable).toBeTruthy();
expect(registry.storyLink.sidById instanceof LuaTable).toBeTruthy();
Expand Down
4 changes: 4 additions & 0 deletions src/engine/core/database/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export const registry = {
* List of offline objects.
*/
offlineObjects: new LuaTable<TNumberId, IStoredOfflineObject>(),
/**
* List of wounded objects.
*/
objectsWounded: new LuaTable<TNumberId, IRegistryObjectState>(),
/**
* List of objects participating in alife simulation.
*/
Expand Down
6 changes: 1 addition & 5 deletions src/engine/core/database/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,12 @@ export interface IRegistryObjectState extends Record<EScheme, Optional<IBaseSche
*/
mute: Optional<boolean>;
/**
* ID of object currently looting object.
* ID of object currently looting this object.
* Used to prevent looting of same object by multiple objects at once.
*
* todo: Move to loot scheme state, not store it in global. Probaly pstore is correct place.
*/
lootedByObject: Optional<TNumberId>;
/**
* todo;
*/
wounded_already_selected: Optional<TNumberId>;
/**
* todo;
*/
Expand Down
8 changes: 4 additions & 4 deletions src/engine/core/managers/base/SaveManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class SaveManager extends AbstractCoreManager {
* Save core managers data.
*/
public clientSave(packet: NetPacket): void {
logger.info("Saving client");
logger.info("Saving client data");

WeatherManager.getInstance().save(packet);
ReleaseBodyManager.getInstance().save(packet);
Expand All @@ -52,7 +52,7 @@ export class SaveManager extends AbstractCoreManager {
* Load core managers data.
*/
public clientLoad(reader: NetProcessor): void {
logger.info("Loading client");
logger.info("Loading client data");

WeatherManager.getInstance().load(reader);
ReleaseBodyManager.getInstance().load(reader);
Expand All @@ -71,7 +71,7 @@ export class SaveManager extends AbstractCoreManager {
* Write state for core managers.
*/
public serverSave(packet: NetPacket): void {
logger.info("Saving server");
logger.info("Saving server data");

SimulationBoardManager.getInstance().save(packet);
}
Expand All @@ -80,7 +80,7 @@ export class SaveManager extends AbstractCoreManager {
* Read state for core managers.
*/
public serverLoad(reader: NetProcessor): void {
logger.info("Loading server");
logger.info("Loading server data");

SimulationBoardManager.getInstance().load(reader);
}
Expand Down
4 changes: 2 additions & 2 deletions src/engine/core/managers/events/EventsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class EventsManager extends AbstractTimersManager {
callback: (this: T, ...args: AnyArgs) => void,
context: Optional<AnyObject> = null
): void {
logger.info("Register callback:", EGameEvent[event]);
// logger.info("Register callback:", EGameEvent[event]);

this.assertEventIsDeclared(event);
this.callbacks[event].set(callback as any, { context: context });
Expand All @@ -63,7 +63,7 @@ export class EventsManager extends AbstractTimersManager {
*/
public unregisterCallback<T>(event: EGameEvent, callback: AnyContextualCallable<unknown>): void;
public unregisterCallback<T>(event: EGameEvent, callback: AnyCallable): void {
logger.info("Unregister callback:", EGameEvent[event]);
// logger.info("Unregister callback:", EGameEvent[event]);

this.assertEventIsDeclared(event);
this.callbacks[event].delete(callback as AnyCallable);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/core/managers/interaction/TradeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class TradeManager extends AbstractCoreManager {
* todo: Do not reuse data variable.
*/
public initializeForObject(object: ClientObject, configFilePath: TPath): void {
logger.info("Initialize trade for:", object.name(), configFilePath);
// logger.info("Initialize trade for:", object.name(), configFilePath);

const objectId: TNumberId = object.id();

Expand Down
2 changes: 1 addition & 1 deletion src/engine/core/managers/interface/ActorInputManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export class ActorInputManager extends AbstractCoreManager {
* Handle first update from actor input perspective.
*/
public onFirstUpdate(delta: TDuration): void {
logger.info("Apply active item slot:", this.activeItemSlot);
// logger.info("Apply active item slot:", this.activeItemSlot);
registry.actor.activate_slot(this.activeItemSlot);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export class ActorInventoryMenuManager extends AbstractCoreManager {
* todo: Description.
*/
public override initialize(): void {
logger.info("Initialize actor inventory quick items slots");

const ini: IniFile = system_ini();

executeConsoleCommand(consoleCommands.slot_0, readIniString(ini, ACTOR, "quick_item_1", false, "", ""));
Expand Down
2 changes: 1 addition & 1 deletion src/engine/core/managers/interface/MapDisplayManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class MapDisplayManager extends AbstractCoreManager {
state: IRegistryObjectState,
section: TSection
): void {
logger.info("Update npc spot:", object.name());
// logger.info("Update npc spot:", object.name());

const objectId: TNumberId = object.id();
const simulator: AlifeSimulator = alife();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class NotificationManager extends AbstractCoreManager {
* Send notification about task state update.
*/
public sendTaskNotification(newState: ETaskState, task: GameTask): void {
logger.info("Show task notification:", newState, task.get_id(), task.get_title());
// logger.info("Show task notification:", newState, task.get_id(), task.get_title());

const notificationTaskDescription: Record<ETaskState, TLabel> = {
[ETaskState.NEW]: "general_new_task",
Expand Down Expand Up @@ -303,7 +303,7 @@ export class NotificationManager extends AbstractCoreManager {
soundCaption: Optional<TLabel> = null,
delay: TDuration = 0
): void {
logger.info("Send sound notification:", object?.name(), soundPath, soundCaption, faction);
// logger.info("Send sound notification:", object?.name(), soundPath, soundCaption, faction);

let pointName: TName = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export class SimulationBoardManager extends AbstractCoreManager {
smartTerrain.m_game_vertex_id
);

logger.info("Creating squad in smart:", squad.name(), smartTerrain.name());
// logger.info("Creating squad in smart:", squad.name(), smartTerrain.name());

squad.createSquadMembers(smartTerrain);

Expand Down
2 changes: 0 additions & 2 deletions src/engine/core/managers/sounds/DynamicMusicManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ export class DynamicMusicManager extends AbstractCoreManager {
public nextTrackStartTime: TTimestamp = 0;

public override initialize(): void {
logger.info("Initialize dynamic music manager");

const eventsManager: EventsManager = EventsManager.getInstance();

eventsManager.registerCallback(EGameEvent.ACTOR_UPDATE, this.onActorUpdate, this);
Expand Down
12 changes: 6 additions & 6 deletions src/engine/core/managers/world/DropManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class DropManager extends AbstractCoreManager {
* @param object - target object to create release items.
*/
public createCorpseReleaseItems(object: ClientObject): void {
logger.info("Create corpse release items:", object.name());
// logger.info("Create corpse release items:", object.name());

const alifeObject: Optional<Stalker> = alife().object<Stalker>(object.id());

Expand Down Expand Up @@ -229,7 +229,7 @@ export class DropManager extends AbstractCoreManager {
const ini: IniFile = object.spawn_ini();

if (ini !== null && ini.section_exist("keep_items")) {
logger.info("Keep item, listed in config:", object.name(), item.name(), section);
// logger.info("Keep item, listed in config:", object.name(), item.name(), section);

return;
}
Expand All @@ -245,7 +245,7 @@ export class DropManager extends AbstractCoreManager {
}

if (this.itemsAlwaysKept.get(section)) {
logger.info("Keep item, always keep listed:", object.name(), item.name(), section);
// logger.info("Keep item, always keep listed:", object.name(), item.name(), section);

return;
}
Expand All @@ -265,18 +265,18 @@ export class DropManager extends AbstractCoreManager {
);
}

logger.info("Keep item, weapon", object.name(), item.name(), item.clsid(), section);
// logger.info("Keep item, weapon", object.name(), item.name(), item.clsid(), section);

return;
}

if (isLootableItemSection(item.section()) && !isAmmoSection(item.section())) {
logger.info("Keep item, misc lootable:", object.name(), item.name(), section);
// logger.info("Keep item, misc lootable:", object.name(), item.name(), section);

return;
}

logger.info("Release loot item:", object.name(), item.name(), section);
// logger.info("Release loot item:", object.name(), item.name(), section);
alife().release(alife().object(item.id()), true);
}

Expand Down
6 changes: 3 additions & 3 deletions src/engine/core/managers/world/ReleaseBodyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,20 @@ export class ReleaseBodyManager extends AbstractCoreManager {
*/
protected inspectionResult(object: ClientObject): boolean {
if (getStoryIdByObjectId(object.id()) !== null) {
logger.info("Ignore corpse release, present in story:", object.name());
// logger.info("Ignore corpse release, present in story:", object.name());

return false;
}

if (this.checkForKnownInfo(object)) {
logger.info("Ignore corpse release, present in known info:", object.name());
// logger.info("Ignore corpse release, present in known info:", object.name());

return false;
}

for (const [k, v] of this.keepItemsRegistry) {
if (object.object(this.keepItemsRegistry.get(k)) !== null) {
logger.info("Ignore corpse release, contains keep item:", object.name(), k);
// logger.info("Ignore corpse release, contains keep item:", object.name(), k);

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/core/managers/world/SurgeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class SurgeManager extends AbstractCoreManager {
* todo: Description.
*/
public initializeSurgeCovers(): void {
logger.info("Initialize surge covers");
// logger.info("Initialize surge covers");
this.surgeCovers = new LuaTable();

const levelName: TLevel = level.name();
Expand Down
4 changes: 2 additions & 2 deletions src/engine/core/managers/world/TreasureManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ export class TreasureManager extends AbstractCoreManager {
* todo: Description.
*/
protected spawnTreasure(treasureId: TTreasure): void {
logger.info("Spawn treasure ID:", treasureId);
// logger.info("Spawn treasure ID:", treasureId);

assertDefined(this.secrets.get(treasureId), "There is no stored secret:", treasureId);

if (this.secrets.get(treasureId).given) {
logger.info("Secret already given:", treasureId);
logger.info("Spawned secret is already given:", treasureId);

return;
}
Expand Down
2 changes: 0 additions & 2 deletions src/engine/core/managers/world/WeatherManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ export class WeatherManager extends AbstractCoreManager {
? DYNAMIC_WEATHER_GRAPHS.line_count("weather_periods")
: 0;

logger.info("Initialize weather periods:", weatherPeriodsLines);

// Reset lists.
this.weatherPeriods = new LuaTable();
this.weatherPeriodsInverse = new LuaTable();
Expand Down
5 changes: 3 additions & 2 deletions src/engine/core/objects/animation/animations/base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IAnimationDescriptor } from "@/engine/core/objects/animation/animation_types";
import { EStalkerState } from "@/engine/core/objects/animation/state_types";
import { finishCorpseLooting } from "@/engine/core/schemes/corpse_detection/utils";
import { finishHelpWounded } from "@/engine/core/schemes/help_wounded/utils";
import { finishObjectHelpWounded } from "@/engine/core/schemes/help_wounded/utils";
import { createSequence } from "@/engine/core/utils/animation";
import { getExtern } from "@/engine/core/utils/binding";
import { startPlayingGuitar, startPlayingHarmonica } from "@/engine/core/utils/camp";
Expand Down Expand Up @@ -1017,8 +1017,9 @@ export const baseAnimations: LuaTable<TName, IAnimationDescriptor> = $fromObject
"dinamit_1",
{
// When animation ends, finish help wounded and heal up.
// todo: Probably just handle as callback in action object? Why setting globally?
f: (object: ClientObject) => {
finishHelpWounded(object);
finishObjectHelpWounded(object);
},
},
]),
Expand Down
4 changes: 2 additions & 2 deletions src/engine/core/objects/binders/camp/CampBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class CampBinder extends object_binder {
return false;
}

logger.info("Spawn camp:", this.object.name());
// logger.info("Spawn camp:", this.object.name());

const ini: IniFile = this.object.spawn_ini();

Expand All @@ -62,7 +62,7 @@ export class CampBinder extends object_binder {
* Handle net destroy event.
*/
public override net_destroy(): void {
logger.info("Destroy camp:", this.object.name());
// logger.info("Destroy camp:", this.object.name());

unregisterCamp(this.object);
super.net_destroy();
Expand Down
2 changes: 1 addition & 1 deletion src/engine/core/objects/binders/creature/StalkerBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ export class StalkerBinder extends object_binder {
* todo: Description.
*/
public onUse(object: ClientObject, who: ClientObject): void {
logger.info("Stalker use:", this.object.name(), "by", who.name());
logger.info("Stalker used:", this.object.name(), "by", who.name());

if (this.object.alive()) {
EventsManager.emitEvent(EGameEvent.STALKER_INTERACTION, object, who);
Expand Down
Loading

0 comments on commit b67d47e

Please sign in to comment.