162 lines
4.3 KiB
C#
162 lines
4.3 KiB
C#
using System.Collections.Generic;
|
|
using Cielonos.MainGame.Characters;
|
|
using MoreMountains.Feedbacks;
|
|
using MoreMountains.FeedbacksForThirdParty;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Inventory
|
|
{
|
|
public abstract partial class MainWeaponBase : ItemBase
|
|
{
|
|
public BaseAnimationGroup baseAnimationGroup;
|
|
}
|
|
|
|
public partial class MainWeaponBase
|
|
{
|
|
public virtual void OnEquipped()
|
|
{
|
|
baseAnimationGroup.SetUp(animationSc);
|
|
foreach (ViewObjectData.ViewObjectDataUnit unit in viewObjectData.viewObjectUnits)
|
|
{
|
|
Transform attachPoint = !unit.isCustomAttachPoint ?
|
|
player.bodyPartsSc.GetPart(unit.normalAttachBodyPart) :
|
|
player.bodyPartsSc.GetPart(unit.customAttachPartName);
|
|
if (attachPoint != null)
|
|
{
|
|
ItemViewObject view = Instantiate(unit.objectPrefab, attachPoint).GetComponent<ItemViewObject>();
|
|
if (unit.applyOffset)
|
|
{
|
|
view.transform.localPosition = unit.positionOffset;
|
|
view.transform.localEulerAngles = unit.rotationOffset;
|
|
}
|
|
viewObjects[unit.objectName] = view;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual void OnUnequipped()
|
|
{
|
|
RemoveAllRegisteredFunctions();
|
|
|
|
foreach (ItemViewObject view in viewObjects.Values)
|
|
{
|
|
Destroy(view.gameObject);
|
|
}
|
|
viewObjects.Clear();
|
|
}
|
|
}
|
|
|
|
public partial class MainWeaponBase
|
|
{
|
|
protected override void Update()
|
|
{
|
|
if (player.inventorySc.equipmentSm.currentMainWeapon == this)
|
|
{
|
|
functionSm?.Update(player.selfTimeSm.DeltaTime);
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class MainWeaponBase
|
|
{
|
|
public bool disablePrimaryPreinput;
|
|
public bool disableSecondaryPreinput;
|
|
public bool disableSpecialAPreinput;
|
|
public bool disableSpecialBPreinput;
|
|
|
|
public virtual void OnPrimaryPress()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnPrimaryHold()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnPrimaryRelease()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSecondaryPress()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSecondaryHold()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSecondaryRelease()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSpecialAPress()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSpecialAHold()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSpecialARelease()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSpecialBPress()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSpecialBHold()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnSpecialBRelease()
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public partial class MainWeaponBase
|
|
{
|
|
protected void Swing(string swingAudio, string feedBackName)
|
|
{
|
|
if (!string.IsNullOrEmpty(swingAudio))
|
|
{
|
|
audioContainer.PlaySoundFX(swingAudio, null, true);
|
|
}
|
|
|
|
feedbackSc[feedBackName].Play();
|
|
}
|
|
|
|
protected void Swing(string swingAudio, string feedBackName, Vector3 swingRotation, Vector3 swingVelocity = default)
|
|
{
|
|
if (!string.IsNullOrEmpty(swingAudio))
|
|
{
|
|
audioContainer.PlaySoundFX(swingAudio, null, true);
|
|
}
|
|
|
|
MMF_CinemachineRotation cinemachineRotation = feedbackSc[feedBackName].feedback.GetFeedbackOfType<MMF_CinemachineRotation>();
|
|
if (cinemachineRotation != null)
|
|
{
|
|
cinemachineRotation.RotationAmplitude = swingRotation != default ? swingRotation : Vector3.zero;
|
|
}
|
|
|
|
MMF_CinemachineImpulse cinemachineImpulse = feedbackSc[feedBackName].feedback.GetFeedbackOfType<MMF_CinemachineImpulse>();
|
|
if (cinemachineImpulse != null)
|
|
{
|
|
cinemachineImpulse.Velocity = swingVelocity != default ? swingVelocity : Vector3.zero;
|
|
}
|
|
|
|
feedbackSc[feedBackName].Play();
|
|
}
|
|
}
|
|
} |