111 lines
3.3 KiB
Ucode
111 lines
3.3 KiB
Ucode
/**
|
|
* Author: dkanus
|
|
* Home repo: https://www.insultplayers.ru/git/AcediaFramework/AcediaCore
|
|
* License: GPL
|
|
* Copyright 2025 Anton Tarasenko
|
|
*------------------------------------------------------------------------------
|
|
* This file is part of Acedia.
|
|
*
|
|
* Acedia is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Acedia is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Acedia. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
class ZedTimeComponent extends Object;
|
|
|
|
var private bool zedTimeActive;
|
|
var private float zedTimeRemainder;
|
|
var private int zedTimeStack;
|
|
|
|
var array<float> slowDownLevels;
|
|
|
|
const ZED_TIME_SPEED = 0.8;//0.2;
|
|
const DEFAULT_ZED_TIME_DURATION = 30.0;
|
|
|
|
//var float ZedTimeSlomoScale;
|
|
//var float LastZedTimeEvent;
|
|
//var int ZedTimeExtensionsUsed;
|
|
//var bool bSpeedingBackUp;
|
|
|
|
public function ActivateZedTime(optional float duration) {
|
|
local GameInfo game;
|
|
local Controller nextController;
|
|
local KFPlayerController kfPlayerController;
|
|
|
|
if (zedTimeActive) return;
|
|
game = GetGameInfo();
|
|
if (game == none) return;
|
|
|
|
if (duration <= 0) {
|
|
duration = DEFAULT_ZED_TIME_DURATION;
|
|
}
|
|
zedTimeActive = true;
|
|
zedTimeRemainder = duration;
|
|
zedTimeStack += 1;
|
|
game.SetGameSpeed(ZED_TIME_SPEED);
|
|
|
|
nextController = game.level.controllerList;
|
|
while (nextController != none) {
|
|
kfPlayerController = KFPlayerController(nextController);
|
|
if(kfPlayerController != none) {
|
|
kfPlayerController.ClientEnterZedTime();
|
|
}
|
|
nextController = nextController.nextController;
|
|
}
|
|
}
|
|
|
|
public function DeactivateZedTime() {
|
|
local GameInfo game;
|
|
local Controller nextController;
|
|
local KFPlayerController kfPlayerController;
|
|
|
|
if (!zedTimeActive) return;
|
|
game = GetGameInfo();
|
|
if (game == none) return;
|
|
|
|
zedTimeActive = false;
|
|
zedTimeStack = 0;
|
|
game.SetGameSpeed(1.0);
|
|
|
|
nextController = game.level.controllerList;
|
|
while (nextController != none) {
|
|
kfPlayerController = KFPlayerController(nextController);
|
|
if(kfPlayerController != none) {
|
|
kfPlayerController.ClientExitZedTime();
|
|
}
|
|
nextController = nextController.nextController;
|
|
}
|
|
}
|
|
|
|
public function ProcessTick(float realDeltaTime) {
|
|
if (zedTimeActive && zedTimeRemainder > 0) {
|
|
zedTimeRemainder -= realDeltaTime;
|
|
if (zedTimeRemainder <= 0) {
|
|
DeactivateZedTime();
|
|
}
|
|
}
|
|
}
|
|
|
|
private function GameInfo GetGameInfo() {
|
|
local NicePack mutator;
|
|
|
|
mutator = class'NicePack'.static.Myself(none);
|
|
if (mutator != none) {
|
|
return mutator.level.game;
|
|
}
|
|
return none;
|
|
}
|
|
|
|
defaultproperties {
|
|
slowDownLevels(0) = 0.9
|
|
slowDownLevels(1) = 0.8
|
|
slowDownLevels(2) = 0.7
|
|
} |