更改文件架构

This commit is contained in:
CortexCore
2023-06-07 18:38:07 +08:00
parent 93292b1a59
commit ed84166723
720 changed files with 297 additions and 65 deletions

View File

@@ -0,0 +1,61 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using Sirenix.OdinInspector;
using DG.Tweening;
namespace BITKit.Entities
{
public class EntityCharacter : EntityComponent
{
[Header(Constant.Header.Components)]
public List<Renderer> fpvRenderer = new();
public List<Renderer> tpvRenderer = new();
[Header(Constant.Header.Reference)]
[SerializeReference, SubclassSelector] public References _isAlive;
[SerializeReference, SubclassSelector] public References _getDamage;
public override void OnStart()
{
entity.AddListener<bool>(nameof(OnSetAlive), OnSetAlive);
entity.AddListener<int>(nameof(OnSetHP), OnSetHP);
}
public override void OnSpawn()
{
if (isLocalPlayer)
{
OnSetAlive(true);
}
else
{
SetFPV(false);
}
}
public override void OnDespawn()
{
SetFPV(false);
}
void OnSetAlive(bool alive)
{
SetFPV(isLocalPlayer ? alive : false);
}
void OnSetHP(int hp)
{
entity.Invoke<string>(Constant.Animation.Play, _getDamage);
}
void SetFPV(bool isFpv)
{
var shadowMode = isFpv ?
ShadowCastingMode.ShadowsOnly :
ShadowCastingMode.On;
foreach (var x in fpvRenderer)
{
x.enabled = isFpv;
}
foreach (var x in tpvRenderer)
{
x.shadowCastingMode = shadowMode;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c8cf20e38c0584247ab1573e085274d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: