/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.jme3.animation.AnimControl
 *  com.jme3.bullet.collision.shapes.CapsuleCollisionShape
 *  com.jme3.bullet.collision.shapes.CollisionShape
 *  com.jme3.bullet.control.GhostControl
 *  com.jme3.effect.ParticleEmitter
 *  com.jme3.effect.ParticleMesh$Type
 *  com.jme3.light.Light
 *  com.jme3.light.PointLight
 *  com.jme3.material.Material
 *  com.jme3.math.ColorRGBA
 *  com.jme3.math.Vector3f
 *  com.jme3.scene.Spatial
 *  com.jme3.scene.control.Control
 */
package mygame;

import com.jme3.animation.AnimControl;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.GhostControl;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.light.Light;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import mygame.Character;
import mygame.CrossControl;
import mygame.Exchange;

public class Cross
extends Character {
    public GhostControl collision;
    public CrossControl control;
    private PointLight light;

    public Cross(String name) {
        super(name);
        this.setModel();
        this.setupControl();
    }

    public void setupModelControl() {
        this.modelAnimControl = (AnimControl)this.model.getControl(AnimControl.class);
        this.modelAnimChannel = this.modelAnimControl.createChannel();
        this.modelAnimChannel.setAnim("normal");
        this.modelAnimChannel.setSpeed(0.5f);
    }

    void setupModel() {
        this.wholeBody.attachChild(this.model);
    }

    public void setupControl() {
        this.collision = new GhostControl((CollisionShape)new CapsuleCollisionShape(1.0f, 0.5f));
        this.collision.addCollideWithGroup(2);
        this.addControl((Control)this.collision);
        this.control = new CrossControl();
        this.addControl((Control)this.control);
        Exchange.bulletAppState.getPhysicsSpace().add((Object)this.collision);
    }

    public void setModel() {
        this.model = Exchange.assetManager.loadModel("Models/kross/kross.mesh.j3o");
        this.setLocalScale(0.25f);
        this.setupModel();
        this.setupModelControl();
        this.wholeBody.attachChild(this.model);
        ParticleEmitter funken = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 50);
        Material mat_red = new Material(Exchange.assetManager, "Common/MatDefs/Misc/Particle.j3md");
        mat_red.setTexture("Texture", Exchange.assetManager.loadTexture("Effects/flame.png"));
        funken.setMaterial(mat_red);
        funken.setImagesX(2);
        funken.setImagesY(2);
        funken.setEndColor(new ColorRGBA(0.0f, 1.0f, 0.0f, 1.0f));
        funken.setStartColor(new ColorRGBA(0.0f, 1.0f, 0.0f, 1.0f));
        funken.getParticleInfluencer().setInitialVelocity(new Vector3f(0.25f, 2.0f, 0.25f));
        funken.setStartSize(0.1f);
        funken.setEndSize(0.1f);
        funken.setGravity(0.0f, 0.0f, 0.0f);
        funken.setLowLife(1.0f);
        funken.setHighLife(2.0f);
        funken.getParticleInfluencer().setVelocityVariation(1.0f);
        this.attachChild((Spatial)funken);
    }

    public void kill() {
        this.removeFromParent();
        Exchange.rootNode.removeLight((Light)this.light);
    }

    public void setLight() {
        this.light = new PointLight();
        this.light.setPosition(this.getLocalTranslation().add(new Vector3f(0.0f, 1.0f, 0.0f)));
        this.light.setColor(ColorRGBA.Green);
        this.light.setRadius(10.0f);
        Exchange.rootNode.addLight((Light)this.light);
    }
}
