def Touch(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: if not self.UpdatingOption.CurrentValue: return True if str(caller).split(" ")[0] != "WillowVendingMachine": return True self.TouchingActors.add(params.Other) if self.UpdatingOption.CurrentValue and len( self.TouchingActors) == 1: AsyncUtil.RunEvery(self.UPDATE_DELAY, self.OnUpdate, self.Name) return True
def ModOptionChanged(self, option: unrealsdk.Options.Boolean, new_value: bool) -> None: if option != self.UpdatingOption: return # If you turn on updating and there are people close to vendors, start updating if new_value: if len(self.TouchingActors) > 0: AsyncUtil.RunEvery(self.UPDATE_DELAY, self.OnUpdate, self.Name) # If you turn off updating, stop updating and make sure all vendors are usable at no cost else: AsyncUtil.CancelFutureCallbacks(self.Name) for vendor in unrealsdk.FindAll("WillowVendingMachine"): if vendor.ShopType == 1 or vendor.ShopType == 2: vendor.SetUsability(True, 1) vendor.Behavior_ChangeUsabilityCost(1, 0, 0, 1)
def Touch(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: if caller.Class.Name != "WillowVendingMachine": return True if params.Other.Class.Name != "WillowPlayerPawn": return True # If no one's currently near a vendor, but is about to be, and if updating costs are on, # start the update loop if self.UpdatingOption.CurrentValue and len(self.TouchingActors) == 0: AsyncUtil.RunEvery(self.UPDATE_DELAY, self.OnUpdate, self.Name) if caller not in self.TouchingActors: self.TouchingActors[caller] = set() self.TouchingActors[caller].add(params.Other) return True