public ParticleController(String name, Emitter emitter, ParticleControllerRenderer<?, ?> renderer, Influencer...influencers){ this(); this.name = name; this.emitter = emitter; this.renderer = renderer; this.particleChannels = new ParticleChannels(); this.influencers = new Array<Influencer>(influencers); }
/** @return a copy of this controller*/ public ParticleController copy () { Emitter emitter = (Emitter)this.emitter.copy(); Influencer[] influencers = new Influencer[this.influencers.size]; int i=0; for(Influencer influencer : this.influencers){ influencers[i++] = (Influencer)influencer.copy(); } return new ParticleController(new String(this.name), emitter, (ParticleControllerRenderer<?, ?>)renderer.copy(), influencers); }
@Override public void write (Json json) { json.writeValue("name", name); json.writeValue("emitter", emitter, Emitter.class); json.writeValue("influencers", influencers, Array.class, Influencer.class); json.writeValue("renderer", renderer, ParticleControllerRenderer.class); }
@Override public void read (Json json, JsonValue jsonMap) { name = json.readValue("name", String.class, jsonMap); emitter = json.readValue("emitter", Emitter.class, jsonMap); influencers.addAll(json.readValue("influencers", Array.class, Influencer.class, jsonMap)); renderer = json.readValue("renderer", ParticleControllerRenderer.class, jsonMap); }