/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.jme3.animation.AnimChannel
 *  com.jme3.animation.AnimControl
 *  com.jme3.animation.LoopMode
 *  com.jme3.bullet.collision.shapes.CapsuleCollisionShape
 *  com.jme3.bullet.collision.shapes.CollisionShape
 *  com.jme3.bullet.control.BetterCharacterControl
 *  com.jme3.bullet.control.GhostControl
 *  com.jme3.math.Vector3f
 *  com.jme3.scene.Spatial
 *  com.jme3.scene.control.Control
 */
package mygame;

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.LoopMode;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.BetterCharacterControl;
import com.jme3.bullet.control.GhostControl;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;
import mygame.Character;
import mygame.Exchange;
import mygame.Weapon;

public class Player
extends Character {
    public Weapon rightHand;
    public Weapon leftHand;
    public Spatial hat;
    public Spatial model;
    public BetterCharacterControl playerControl;
    public AnimChannel leftHandAnimChannel;
    public AnimControl leftHandAnimControl;
    public AnimChannel rightHandAnimChannel;
    public AnimControl rightHandAnimControl;
    public Vector3f pt;
    public GhostControl collision;
    public float health = 100.0f;
    public static float MAX_HEALTH = 100.0f;

    public Player(String name) {
        super(name);
    }

    public Spatial getRightHand() {
        return this.rightHand;
    }

    public void setRightHand(Weapon rightHand) {
        this.rightHand = rightHand;
        this.setupRightHand();
    }

    public Spatial getLeftHand() {
        return this.leftHand;
    }

    public void setLeftHand(Weapon leftHand) {
        this.leftHand = leftHand;
        this.setupLeftHand();
    }

    public Spatial getHat() {
        return this.hat;
    }

    public void setHat(Spatial hat) {
        this.hat = hat;
        this.setupHat();
    }

    public Spatial getModel() {
        return this.model;
    }

    public void setModel(Spatial model) {
        this.model = model;
        this.setupModel();
        this.setupControl();
        this.setupModelControl();
        this.wholeBody.attachChild(this.model);
    }

    public void switchHands() {
        this.wholeBody.detachChild((Spatial)this.leftHand);
        this.wholeBody.detachChild((Spatial)this.rightHand);
        Weapon temp = this.rightHand;
        this.setRightHand(this.leftHand);
        this.setLeftHand(temp);
    }

    public void die() {
        this.modelAnimChannel.setAnim("die");
        this.modelAnimChannel.setLoopMode(LoopMode.DontLoop);
        this.wholeBody.setLocalTranslation(0.0f, 0.5f, 0.0f);
        this.wholeBody.detachChild(this.hat);
        this.wholeBody.detachChild((Spatial)this.rightHand);
        this.wholeBody.detachChild((Spatial)this.leftHand);
    }

    private void setupLeftHand() {
        this.leftHand.setLocalTranslation(0.4f, 0.3f, 0.4f);
        this.leftHand.setLocalScale(0.35f);
        this.wholeBody.attachChild((Spatial)this.leftHand);
    }

    private void setupRightHand() {
        this.rightHand.setLocalTranslation(-0.4f, 0.3f, 0.4f);
        this.rightHand.setLocalScale(0.35f);
        this.wholeBody.attachChild((Spatial)this.rightHand);
    }

    private void setupHat() {
        this.hat.setLocalScale(0.35f);
        this.hat.setLocalTranslation(0.0f, 0.9f, -0.2f);
        this.hat.rotate(-0.4f, 0.0f, 0.0f);
        this.wholeBody.attachChild(this.hat);
    }

    public void setupModel() {
        this.model.setLocalScale(0.5f);
        this.wholeBody.attachChild(this.model);
    }

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

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

    public void heal(float amount) {
        this.health = amount + this.health > MAX_HEALTH ? MAX_HEALTH : (this.health += amount);
    }
}
