Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using QuestEngine.Players;
- using UnityEngine;
- using Zenject;
- namespace QuestEngine.Installers
- {
- public class GameplayInstaller : MonoInstaller
- {
- [SerializeField] private GameObject _playerPrefab;
- public override void InstallBindings()
- {
- Container.Bind<Player>().FromSubContainerResolve().ByNewPrefabInstaller<PlayerInstaller>(_playerPrefab).AsSingle();
- }
- }
- public class PlayerInstaller : Installer
- {
- public override void InstallBindings()
- {
- Container.Bind<Player>().AsSingle();
- Container.Bind<Transform>().FromComponentOnRoot().AsSingle();
- Container.Bind<Rigidbody>().FromComponentOnRoot().AsSingle();
- }
- }
- }
- namespace QuestEngine.Players
- {
- public class Player
- {
- private readonly Transform _transform;
- private readonly Rigidbody _rigidbody;
- public Player(Transform transform,Rigidbody rigidbody)
- {
- _transform = transform;
- _rigidbody = rigidbody;
- }
- public Vector3 Position
- {
- get => _transform.position;
- set => _transform.position = value;
- }
- public Vector3 Forward => _transform.forward;
- public static implicit operator Transform(Player player) => player._transform;
- public static implicit operator Rigidbody(Player player) => player._rigidbody;
- }
- }
Add Comment
Please, Sign In to add comment