OOP changes to EffectMaker
= Conversion of EffectHandler to a class
This commit is contained in:
parent
79202b9034
commit
b1a1bb6013
2 changed files with 84 additions and 81 deletions
|
@ -1,5 +1,5 @@
|
||||||
const TweenService = game.GetService("TweenService");
|
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
|
type effect = [number, effectKeypoint[], MeshPart, number] // Time since last keypoint, effect keypoints, effect meshPart, effect priority
|
||||||
|
|
||||||
export interface effectMaker {
|
export interface effectMaker {
|
||||||
|
@ -13,19 +13,19 @@ export interface effectMaker {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface effectRunner {
|
export interface effectRunner {
|
||||||
runEffects: (
|
runEffects: (timeSinceLastFrame: number) => void;
|
||||||
timeSinceLastFrame: number
|
|
||||||
) => void;//(timeSinceLastFrame: number, effectsToRun: effect[]) => effect[]
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
interface effectHandler extends effectMaker, effectRunner {
|
interface effectHandler extends effectMaker, effectRunner {
|
||||||
EFFECT_FOLDER: Folder;
|
EFFECT_FOLDER: Folder;
|
||||||
effectsToRun: effect[]
|
effectsToRun: effect[]
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
export function makeEffectHandler(effectFolder: Folder) {
|
class effectHandler implements effectMaker, effectRunner {
|
||||||
return {
|
constructor(effectFolder: Folder) {
|
||||||
meshPartEffect: function(meshPart: MeshPart, material: Enum.Material, effectKeypoints: effectKeypoint[], priority?: number) {
|
this.EFFECT_FOLDER = effectFolder
|
||||||
|
}
|
||||||
|
meshPartEffect(meshPart: MeshPart, material: Enum.Material, effectKeypoints: effectKeypoint[], priority?: number) {
|
||||||
const effectMeshPart = meshPart.Clone();
|
const effectMeshPart = meshPart.Clone();
|
||||||
effectMeshPart.Material = material;
|
effectMeshPart.Material = material;
|
||||||
effectMeshPart.Color = effectKeypoints[0][1];
|
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);
|
effectsToRun.insert(effectsToRun.size(), [0, effectKeypoints, effectMeshPart, priority || 0] as effect);
|
||||||
},
|
}
|
||||||
particleEffect: function() {},
|
particleEffect() {}
|
||||||
runEffects: function(timeSinceLastFrame: number) {
|
runEffects(timeSinceLastFrame: number) {
|
||||||
let effectsToRun = this.effectsToRun
|
let effectsToRun = this.effectsToRun
|
||||||
for (const effect of effectsToRun) {
|
for (const effect of effectsToRun) {
|
||||||
// Update the effect time
|
// Update the effect time
|
||||||
|
@ -98,11 +98,14 @@ export function makeEffectHandler(effectFolder: Folder) {
|
||||||
meshPart.Transparency = currentKeypoint[4] + (nextKeypoint[4] - currentKeypoint[4]) * alpha;
|
meshPart.Transparency = currentKeypoint[4] + (nextKeypoint[4] - currentKeypoint[4]) * alpha;
|
||||||
}
|
}
|
||||||
//this = effectsToRun;
|
//this = effectsToRun;
|
||||||
},
|
}
|
||||||
|
|
||||||
EFFECT_FOLDER: effectFolder,
|
EFFECT_FOLDER: Folder;
|
||||||
effectsToRun: [],
|
effectsToRun: effect[] = [];
|
||||||
} as effectHandler;
|
}
|
||||||
|
|
||||||
|
export function makeEffectRunner(effectFolder: Folder): effectRunner {
|
||||||
|
return new effectHandler(effectFolder);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
local function horseEffModule(o,typ,a1,a2,a3,a4,a5,a6,a7)
|
local function horseEffModule(o,typ,a1,a2,a3,a4,a5,a6,a7)
|
||||||
|
|
|
@ -3,7 +3,7 @@ const Players = game.GetService("Players");
|
||||||
const RunService = game.GetService("RunService");
|
const RunService = game.GetService("RunService");
|
||||||
import { bindToServerMessage, messageServer } from "./ClientMessenger";
|
import { bindToServerMessage, messageServer } from "./ClientMessenger";
|
||||||
import { handleGuiInput, drawGui, closeGui } from "./GuiHandler";
|
import { handleGuiInput, drawGui, closeGui } from "./GuiHandler";
|
||||||
import { makeEffectHandler, effectRunner } from "./EffectMaker";
|
import { makeEffectRunner, effectRunner } from "./EffectMaker";
|
||||||
const LOCALPLAYER = Players.LocalPlayer;
|
const LOCALPLAYER = Players.LocalPlayer;
|
||||||
const PLAYERGUI = LOCALPLAYER.WaitForChild("PlayerGui", 1) as PlayerGui;
|
const PLAYERGUI = LOCALPLAYER.WaitForChild("PlayerGui", 1) as PlayerGui;
|
||||||
assert(
|
assert(
|
||||||
|
|
Loading…
Reference in a new issue