Example #1
0
        internal Weapon(
            GameObject gameObject,
            WeaponTemplate weaponTemplate,
            int weaponIndex,
            WeaponSlot slot,
            AudioSystem audioSystem,
            AssetLoadContext assetLoadContext)
        {
            _gameObject     = gameObject;
            _weaponTemplate = weaponTemplate;
            _weaponIndex    = weaponIndex;

            Slot = slot;

            FillClip();

            var nuggets = new List <WeaponEffectNugget>();

            foreach (var nuggetData in weaponTemplate.Nuggets)
            {
                var nugget = nuggetData.CreateNugget(this);
                if (nugget != null) // TODO: This should never be null.
                {
                    nuggets.Add(nugget);
                }
            }
            Nuggets = nuggets.ToArray();

            _stateMachine = new WeaponStateMachine(
                new WeaponStateContext(
                    gameObject,
                    this,
                    weaponTemplate,
                    weaponIndex,
                    audioSystem,
                    assetLoadContext));

            _usingFlag = ModelConditionFlagUtility.GetUsingWeaponFlag(weaponIndex);
        }
Example #2
0
        internal Weapon(
            GameObject gameObject,
            WeaponTemplate weaponTemplate,
            int weaponIndex,
            WeaponSlot slot,
            GameContext gameContext)
        {
            ParentGameObject = gameObject;
            Template         = weaponTemplate;
            WeaponIndex      = weaponIndex;

            Slot = slot;

            FillClip();

            _stateMachine = new WeaponStateMachine(
                new WeaponStateContext(
                    gameObject,
                    this,
                    gameContext));

            _usingFlag = ModelConditionFlagUtility.GetUsingWeaponFlag(weaponIndex);
        }