CP-Dev-Team / CannabisPlus

Other
2 stars 1 forks source link

Unsafe Downcasting #84

Open iceblade122 opened 1 year ago

iceblade122 commented 1 year ago

SCRIPT (W): @"CannabisPlus/scripts/4_World/classes\useractionscomponent\actions\continuous\tearopenbrickorbag.c,46": Unsafe down-casting, use 'CP_CannabisBags.Cast' for safe down-casting SCRIPT (W): @"CannabisPlus/scripts/4_World/classes\useractionscomponent\actions\continuous\tearopenbrickorbag.c,47": Unsafe down-casting, use 'CP_CoreClass.Cast' for safe down-casting

kotori commented 5 days ago

Would this not be as simple as something like this?

    override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
    {
        CP_CannabisBags Bag = CP_CannabisBags.Cast(item);
                CP_CoreClass CPCORE = CP_CoreClass.Cast(item);

        if(Bag && Bag.GetQuantity() <= 1)
        {
            TendancyText = CPCORE.GetCPitemTendancyText();

            return true;
        }   
        return false;

    };