---@class BP_PlaceItemBase_C:AActor ---@field ItemRoot USceneComponent ---@field DefaultSceneRoot USceneComponent ---@field PlaceItemType TEnumAsByte ---@field PlaceSound UAkAudioEvent ---@field RemoveSound UAkAudioEvent -- 继承拷贝 ------------------------------------------------------------------------------------- --[[ local PlaceItemBase = require("Script.Blueprint.PlaceItems.BP_PlaceItemBase") local BP_LandMine = setmetatable( { }, { __index = PlaceItemBase, __metatable = PlaceItemBase } ) function BP_LandMine:ReceiveBeginPlay() self.SuperClass.ReceiveBeginPlay(self); PlaceItemBase.ParentBeginPlay(self) if self:HasAuthority() then UGCSystemLibrary.BindBeginOverlapFunc(self.Sphere, self.OnBeginOverlap, self) end end function BP_LandMine:ReceiveEndPlay() PlaceItemBase.ParentEndPlay(self) self.SuperClass.ReceiveEndPlay(self); end function BP_LandMine:SetActive(InActive) PlaceItemBase.SetActive(self, InActive) end ]] -- 继承拷贝 End --------------------------------------------------------------------------------- --Edit Below-- local BP_PlaceItemBase = { ItemTFInfo = { Pos = { X = 0, Y = 0, Z = -300 }; Rot = { Roll = 0, Pitch = 0, Yaw = 0 }; }, CmpList = {}; bIsPlaced = false; bEnableActive = false; bCanClimb = true; ID = 0; }; -- 这个先关闭 function BP_PlaceItemBase:GetReplicatedProperties() return "bEnableActive" --"ItemTFInfo", --"ID" end function BP_PlaceItemBase:ParentBeginPlay() self:AddSetMobilityComponent({self.DefaultSceneRoot, self.ItemRoot}) if UGCGameSystem.IsServer() then if PlacementModeConfig.IsPlaceMode() then else self:SetActive(true) end else self:OnRep_ItemTFInfo() if PlacementModeConfig.IsPlaceMode() then if UE.IsValid(self.PlaceSound) then UGCLogSystem.Log("[BP_PlaceItemBase_ParentBeginPlay]") UGCSoundManagerSystem.PlaySoundAtLocation(self.PlaceSound, self:K2_GetActorLocation(), self:K2_GetActorRotation()) end else end end end function BP_PlaceItemBase:ParentEndPlay() if UGCGameSystem.IsServer() then else if PlacementModeConfig.IsPlaceMode() then if UE.IsValid(self.RemoveSound) then UGCSoundManagerSystem.PlaySoundAtLocation(self.RemoveSound, self:K2_GetActorLocation(), self.K2_GetActorRotation()) end end end end function BP_PlaceItemBase:SetActive(InActive) self.bEnableActive = InActive end function BP_PlaceItemBase:GetPlaceItemType() return self.PlaceItemType end function BP_PlaceItemBase:AddSetMobilityComponent(InCmp) if type(InCmp) == "table" then for i, v in pairs(InCmp) do self.CmpList[#self.CmpList + 1] = v end else self.CmpList[#self.CmpList + 1] = InCmp end end function BP_PlaceItemBase:SetID(InID) self.ID = InID end function BP_PlaceItemBase:GetID() return self.ID end function BP_PlaceItemBase:GetIsPlaced() return self.bIsPlaced or not PlacementModeConfig.PlacingAttr.IsObjectPoolPlace end function BP_PlaceItemBase:PlaceItem(Pos, Rot) self.bIsPlaced = true self.ItemTFInfo.Pos = Pos self.ItemTFInfo.Rot = Rot if PlacementModeConfig.PlacingAttr.IsObjectPoolPlace then self:SetCmpListMobility(EComponentMobility.Movable) local TargetPos = PlacementModeConfig.UnitVectorToVector(self.ItemTFInfo.Pos) local TargetRot = PlacementModeConfig.UnitRotatorToRotator(self.ItemTFInfo.Rot) self:K2_SetActorLocation(TargetPos) self:K2_SetActorRotation(TargetRot) UGCEventSystem.SetTimer(self, function() self:SetCmpListMobility(EComponentMobility.Static) UGCLogSystem.Log("[BP_PlaceItemBase_PlaceItem]") end, 1) if UGCGameSystem.IsServer() then UGCSendRPCSystem.ActorRPCNotify(nil, self, "PlaceItem", self.ItemTFInfo.Pos, self.ItemTFInfo.Rot) end end end --function BP_PlaceItemBase:GetPlacePosAndRot() -- return self.ItemTFInfo.Pos, self.ItemTFInfo.Rot --end function BP_PlaceItemBase:GetPlacePosAndRot() return PlacementModeConfig.VectorToUnitVector(self:K2_GetActorLocation()), PlacementModeConfig.RotatorToUnitRotator(self:K2_GetActorRotation()) end --- @param InMobilityType:EComponentMobility function BP_PlaceItemBase:SetCmpListMobility(InMobilityType) if not self.bCanClimb then InMobilityType = EComponentMobility.Movable end UGCLogSystem.Log("[BP_PlaceItemBase_SetCmpListMobility] InMobilityType:%s", tostring(InMobilityType)) for i, v in pairs(self.CmpList) do v:K2_SetMobility(InMobilityType) UGCLogSystem.Log("[BP_PlaceItemBase_SetCmpListMobility] CmpName:%s", KismetSystemLibrary.GetObjectName(v)) end end function BP_PlaceItemBase:OnRep_ItemTFInfo() if self then self:PlaceItem(self.ItemTFInfo.Pos, self.ItemTFInfo.Rot) end end function BP_PlaceItemBase:RecoveryItem() self.bIsPlaced = false if PlacementModeConfig.PlacingAttr.IsObjectPoolPlace then self:SetCmpListMobility(EComponentMobility.Movable) self:K2_SetActorLocation(PlacementModeConfig.PlacingAttr.SpawnPos) if UGCGameSystem.IsServer() then UGCSendRPCSystem.ActorRPCNotify(nil, self, "RecoveryItem") end else UGCLogSystem.Log("[BP_PlaceItemBase_RecoveryItem]") self:K2_DestroyActor() UGCLogSystem.Log("[BP_PlaceItemBase_RecoveryItem] Finish") end end --[[ function BP_PlaceItemBase:GetAvailableServerRPCs() return end --]] return BP_PlaceItemBase;