示例#1
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            GizmoAmmoStatus ammoStatusGizmo = new GizmoAmmoStatus {
                compAmmo = this
            };

            yield return(ammoStatusGizmo);

            var mannableComp = turret?.GetMannable();

            if ((IsEquippedGun && Wielder.Faction == Faction.OfPlayer) || (turret != null && turret.Faction == Faction.OfPlayer && (mannableComp != null || UseAmmo)))
            {
                Action action = null;
                if (IsEquippedGun)
                {
                    action = TryStartReload;
                }
                else if (mannableComp != null)
                {
                    action = turret.TryForceReload;
                }

                // Check for teaching opportunities
                string tag;
                if (turret == null)
                {
                    if (HasMagazine)
                    {
                        tag = "CE_Reload";              // Teach reloading weapons with magazines
                    }
                    else
                    {
                        tag = "CE_ReloadNoMag";     // Teach about mag-less weapons
                    }
                }
                else
                {
                    if (mannableComp == null)
                    {
                        tag = "CE_ReloadAuto";                        // Teach about auto-turrets
                    }
                    else
                    {
                        tag = "CE_ReloadManned";     // Teach about reloading manned turrets
                    }
                }
                LessonAutoActivator.TeachOpportunity(ConceptDef.Named(tag), turret, OpportunityType.GoodToKnow);

                Command_Reload reloadCommandGizmo = new Command_Reload
                {
                    compAmmo     = this,
                    action       = action,
                    defaultLabel = HasMagazine ? (string)"CE_ReloadLabel".Translate() : "",
                    defaultDesc  = "CE_ReloadDesc".Translate(),
                    icon         = CurrentAmmo == null ? ContentFinder <Texture2D> .Get("UI/Buttons/Reload", true) : selectedAmmo.IconTexture(),
                    tutorTag     = tag
                };
                yield return(reloadCommandGizmo);
            }
        }
示例#2
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            GizmoAmmoStatus ammoStatusGizmo = new GizmoAmmoStatus {
                compAmmo = this
            };

            yield return(ammoStatusGizmo);

            if ((wielder != null && wielder.Faction == Faction.OfPlayer) || (turret != null && turret.Faction == Faction.OfPlayer))
            {
                Action action = null;
                if (wielder != null)
                {
                    action = TryStartReload;
                }
                else if (turret != null && turret.GetMannableComp() != null)
                {
                    action = turret.OrderReload;
                }

                Command_Reload reloadCommandGizmo = new Command_Reload
                {
                    compAmmo     = this,
                    action       = action,
                    defaultLabel = hasMagazine ? "CE_ReloadLabel".Translate() : "",
                    defaultDesc  = "CE_ReloadDesc".Translate(),
                    icon         = currentAmmo == null ? ContentFinder <Texture2D> .Get("UI/Buttons/Reload", true) : Def_Extensions.IconTexture(selectedAmmo)
                };
                yield return(reloadCommandGizmo);
            }
        }