protected override Boolean TrySetScalarValue(SegmentEntity entity, Single value) { LaserPowerTransmitter lpt = entity as LaserPowerTransmitter; if (lpt == null) { return(false); } lpt.mrPowerPacketSize = value; return(true); }
//Executing the namesake of the mod. //Function will confirm that all needs are met for swapping a lens. //Proper care needs to be taken here to never delete an "old lens", as the ALS has no //internal storage for oldLenses. //Must not have any mIssue or checkReady checks in this funtion; lest it become recursive/unreachable. private bool runSwapLens(LaserPowerTransmitter lpt) { if (lpt == null) { return(false); } ItemBase oldLens = lpt.GetLens(); bool hasLens = (oldLens != null); if (mbOnlySwap && !hasLens) { ++mnTrackLPTs; return(false); } if (hasLens) { if (oldLens.mnItemID == mStoredLenses.mnItemID) { ++mnTrackLPTs; return(false); } else { if (!CommunityUtil.GiveToSurrounding((MachineEntity)this, oldLens)) { Debug.LogWarning("[Auto Lens Swapper][issue] Could not find a surrounding machine to drop an old lens into! Lens was not removed."); mIssue = eIssues.Output; mLastLPT = lpt; return(false); } } } lpt.SwapLens(mTargetLens); AddLenses(-1); mrCurrentPower -= mrPowerPerSwap; ++mnTrackLPTs; ++mnTrackSwaps; MarkDirtyDelayed(); return(true); }