OOP changes to EffectMaker

= Conversion of EffectHandler to a class
This commit is contained in:
loplkc loplkc 2022-02-04 21:43:51 -05:00
parent 79202b9034
commit b1a1bb6013
2 changed files with 84 additions and 81 deletions

View file

@ -1,5 +1,5 @@
const TweenService = game.GetService("TweenService");
type effectKeypoint = [number, Color3, Vector3, CFrame, number, Enum.EasingStyle?, Enum.EasingDirection?];
export type effectKeypoint = [time: number, color: Color3, size: Vector3, cframe: CFrame, transparency: number, easingStyle?: Enum.EasingStyle, easingDirection?: Enum.EasingDirection];
type effect = [number, effectKeypoint[], MeshPart, number] // Time since last keypoint, effect keypoints, effect meshPart, effect priority
export interface effectMaker {
@ -13,19 +13,19 @@ export interface effectMaker {
}
export interface effectRunner {
runEffects: (
timeSinceLastFrame: number
) => void;//(timeSinceLastFrame: number, effectsToRun: effect[]) => effect[]
runEffects: (timeSinceLastFrame: number) => void;
}
/*
interface effectHandler extends effectMaker, effectRunner {
EFFECT_FOLDER: Folder;
effectsToRun: effect[]
}
export function makeEffectHandler(effectFolder: Folder) {
return {
meshPartEffect: function(meshPart: MeshPart, material: Enum.Material, effectKeypoints: effectKeypoint[], priority?: number) {
*/
class effectHandler implements effectMaker, effectRunner {
constructor(effectFolder: Folder) {
this.EFFECT_FOLDER = effectFolder
}
meshPartEffect(meshPart: MeshPart, material: Enum.Material, effectKeypoints: effectKeypoint[], priority?: number) {
const effectMeshPart = meshPart.Clone();
effectMeshPart.Material = material;
effectMeshPart.Color = effectKeypoints[0][1];
@ -54,9 +54,9 @@ export function makeEffectHandler(effectFolder: Folder) {
}
}
effectsToRun.insert(effectsToRun.size(), [0, effectKeypoints, effectMeshPart, priority || 0] as effect);
},
particleEffect: function() {},
runEffects: function(timeSinceLastFrame: number) {
}
particleEffect() {}
runEffects(timeSinceLastFrame: number) {
let effectsToRun = this.effectsToRun
for (const effect of effectsToRun) {
// Update the effect time
@ -98,11 +98,14 @@ export function makeEffectHandler(effectFolder: Folder) {
meshPart.Transparency = currentKeypoint[4] + (nextKeypoint[4] - currentKeypoint[4]) * alpha;
}
//this = effectsToRun;
},
}
EFFECT_FOLDER: effectFolder,
effectsToRun: [],
} as effectHandler;
EFFECT_FOLDER: Folder;
effectsToRun: effect[] = [];
}
export function makeEffectRunner(effectFolder: Folder): effectRunner {
return new effectHandler(effectFolder);
}
/*
local function horseEffModule(o,typ,a1,a2,a3,a4,a5,a6,a7)

View file

@ -3,7 +3,7 @@ const Players = game.GetService("Players");
const RunService = game.GetService("RunService");
import { bindToServerMessage, messageServer } from "./ClientMessenger";
import { handleGuiInput, drawGui, closeGui } from "./GuiHandler";
import { makeEffectHandler, effectRunner } from "./EffectMaker";
import { makeEffectRunner, effectRunner } from "./EffectMaker";
const LOCALPLAYER = Players.LocalPlayer;
const PLAYERGUI = LOCALPLAYER.WaitForChild("PlayerGui", 1) as PlayerGui;
assert(